// Generated by Futhark 0.22.0
// git: e8b7244 (Wed Jan 12 23:26:03 2022 +0100)

// We need to define _GNU_SOURCE before
// _any_ headers files are imported to get
// the usage statistics of a thread (i.e. have RUSAGE_THREAD) on GNU/Linux
// https://manpages.courier-mta.org/htmlman2/getrusage.2.html
#ifndef _GNU_SOURCE // Avoid possible double-definition warning.
#define _GNU_SOURCE
#endif

#ifdef __clang__
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wparentheses"
#pragma clang diagnostic ignored "-Wunused-label"
#elif __GNUC__
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif

// Headers\n")
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <float.h>

#ifdef __cplusplus
extern "C" {
#endif

// Initialisation
struct futhark_context_config;
struct futhark_context_config *futhark_context_config_new(void);
void futhark_context_config_free(struct futhark_context_config *cfg);
void futhark_context_config_set_debugging(struct futhark_context_config *cfg,
                                          int flag);
void futhark_context_config_set_profiling(struct futhark_context_config *cfg,
                                          int flag);
void futhark_context_config_set_logging(struct futhark_context_config *cfg,
                                        int flag);
void futhark_context_config_set_num_threads(struct futhark_context_config *cfg,
                                            int n);
struct futhark_context;
struct futhark_context *futhark_context_new(struct futhark_context_config *cfg);
void futhark_context_free(struct futhark_context *ctx);
int futhark_context_sync(struct futhark_context *ctx);
int futhark_context_config_set_tuning_param(struct futhark_context_config *cfg,
                                            const char *param_name,
                                            size_t param_value);
int futhark_get_tuning_param_count(void);
const char *futhark_get_tuning_param_name(int);
const char *futhark_get_tuning_param_class(int);

// Arrays
struct futhark_f64_2d;
struct futhark_f64_2d *futhark_new_f64_2d(struct futhark_context *ctx, const
                                          double *data, int64_t dim0,
                                          int64_t dim1);
struct futhark_f64_2d *futhark_new_raw_f64_2d(struct futhark_context *ctx, const
                                              unsigned char *data,
                                              int64_t offset, int64_t dim0,
                                              int64_t dim1);
int futhark_free_f64_2d(struct futhark_context *ctx,
                        struct futhark_f64_2d *arr);
int futhark_values_f64_2d(struct futhark_context *ctx,
                          struct futhark_f64_2d *arr, double *data);
unsigned char *futhark_values_raw_f64_2d(struct futhark_context *ctx,
                                         struct futhark_f64_2d *arr);
const int64_t *futhark_shape_f64_2d(struct futhark_context *ctx,
                                    struct futhark_f64_2d *arr);

// Opaque values


// Entry points
int futhark_entry_main(struct futhark_context *ctx,
                       struct futhark_f64_2d **out0, const
                       struct futhark_f64_2d *in0, const int64_t in1, const
                       int64_t in2, const int64_t in3, const int64_t in4, const
                       int64_t in5);

// Miscellaneous
char *futhark_context_report(struct futhark_context *ctx);
char *futhark_context_get_error(struct futhark_context *ctx);
void futhark_context_set_logging_file(struct futhark_context *ctx, FILE *f);
void futhark_context_pause_profiling(struct futhark_context *ctx);
void futhark_context_unpause_profiling(struct futhark_context *ctx);
int futhark_context_clear_caches(struct futhark_context *ctx);
#define FUTHARK_BACKEND_multicore

#ifdef __cplusplus
}
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <stdint.h>
// If NDEBUG is set, the assert() macro will do nothing. Since Futhark
// (unfortunately) makes use of assert() for error detection (and even some
// side effects), we want to avoid that.
#undef NDEBUG
#include <assert.h>
#include <stdarg.h>
// Start of util.h.
//
// Various helper functions that are useful in all generated C code.

#include <errno.h>
#include <string.h>

static const char *fut_progname = "(embedded Futhark)";

static void futhark_panic(int eval, const char *fmt, ...) __attribute__((noreturn));
static char* msgprintf(const char *s, ...);
static void* slurp_file(const char *filename, size_t *size);
static int dump_file(const char *file, const void *buf, size_t n);
struct str_builder;
static void str_builder_init(struct str_builder *b);
static void str_builder(struct str_builder *b, const char *s, ...);

static void futhark_panic(int eval, const char *fmt, ...) {
  va_list ap;
  va_start(ap, fmt);
  fprintf(stderr, "%s: ", fut_progname);
  vfprintf(stderr, fmt, ap);
  va_end(ap);
  exit(eval);
}

// For generating arbitrary-sized error messages.  It is the callers
// responsibility to free the buffer at some point.
static char* msgprintf(const char *s, ...) {
  va_list vl;
  va_start(vl, s);
  size_t needed = 1 + (size_t)vsnprintf(NULL, 0, s, vl);
  char *buffer = (char*) malloc(needed);
  va_start(vl, s); // Must re-init.
  vsnprintf(buffer, needed, s, vl);
  return buffer;
}

static inline void check_err(int errval, int sets_errno, const char *fun, int line,
                            const char *msg, ...) {
  if (errval) {
    char errnum[10];

    va_list vl;
    va_start(vl, msg);

    fprintf(stderr, "ERROR: ");
    vfprintf(stderr, msg, vl);
    fprintf(stderr, " in %s() at line %d with error code %s\n",
            fun, line,
            sets_errno ? strerror(errno) : errnum);
    exit(errval);
  }
}

#define CHECK_ERR(err, ...) check_err(err, 0, __func__, __LINE__, __VA_ARGS__)
#define CHECK_ERRNO(err, ...) check_err(err, 1, __func__, __LINE__, __VA_ARGS__)

// Read the rest of an open file into a NUL-terminated string; returns
// NULL on error.
static void* fslurp_file(FILE *f, size_t *size) {
  long start = ftell(f);
  fseek(f, 0, SEEK_END);
  long src_size = ftell(f)-start;
  fseek(f, start, SEEK_SET);
  unsigned char *s = (unsigned char*) malloc((size_t)src_size + 1);
  if (fread(s, 1, (size_t)src_size, f) != (size_t)src_size) {
    free(s);
    s = NULL;
  } else {
    s[src_size] = '\0';
  }

  if (size) {
    *size = (size_t)src_size;
  }

  return s;
}

// Read a file into a NUL-terminated string; returns NULL on error.
static void* slurp_file(const char *filename, size_t *size) {
  FILE *f = fopen(filename, "rb"); // To avoid Windows messing with linebreaks.
  if (f == NULL) return NULL;
  unsigned char *s = fslurp_file(f, size);
  fclose(f);
  return s;
}

// Dump 'n' bytes from 'buf' into the file at the designated location.
// Returns 0 on success.
static int dump_file(const char *file, const void *buf, size_t n) {
  FILE *f = fopen(file, "w");

  if (f == NULL) {
    return 1;
  }

  if (fwrite(buf, sizeof(char), n, f) != n) {
    return 1;
  }

  if (fclose(f) != 0) {
    return 1;
  }

  return 0;
}

struct str_builder {
  char *str;
  size_t capacity; // Size of buffer.
  size_t used; // Bytes used, *not* including final zero.
};

static void str_builder_init(struct str_builder *b) {
  b->capacity = 10;
  b->used = 0;
  b->str = malloc(b->capacity);
  b->str[0] = 0;
}

static void str_builder(struct str_builder *b, const char *s, ...) {
  va_list vl;
  va_start(vl, s);
  size_t needed = (size_t)vsnprintf(NULL, 0, s, vl);

  while (b->capacity < b->used + needed + 1) {
    b->capacity *= 2;
    b->str = realloc(b->str, b->capacity);
  }

  va_start(vl, s); // Must re-init.
  vsnprintf(b->str+b->used, b->capacity-b->used, s, vl);
  b->used += needed;
}

// End of util.h.
// Start of half.h.

// Conversion functions are from http://half.sourceforge.net/, but
// translated to C.
//
// Copyright (c) 2012-2021 Christian Rau
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef __OPENCL_VERSION__
#define __constant
#endif

__constant static const uint16_t base_table[512] = {
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100,
  0x0200, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x2400, 0x2800, 0x2C00, 0x3000, 0x3400, 0x3800, 0x3C00,
  0x4000, 0x4400, 0x4800, 0x4C00, 0x5000, 0x5400, 0x5800, 0x5C00, 0x6000, 0x6400, 0x6800, 0x6C00, 0x7000, 0x7400, 0x7800, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00, 0x7C00,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001, 0x8002, 0x8004, 0x8008, 0x8010, 0x8020, 0x8040, 0x8080, 0x8100,
  0x8200, 0x8400, 0x8800, 0x8C00, 0x9000, 0x9400, 0x9800, 0x9C00, 0xA000, 0xA400, 0xA800, 0xAC00, 0xB000, 0xB400, 0xB800, 0xBC00,
  0xC000, 0xC400, 0xC800, 0xCC00, 0xD000, 0xD400, 0xD800, 0xDC00, 0xE000, 0xE400, 0xE800, 0xEC00, 0xF000, 0xF400, 0xF800, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00,
  0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00 };

__constant static const unsigned char shift_table[512] = {
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
  13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 13,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
  13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
  24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 13 };

__constant static const uint32_t mantissa_table[2048] = {
  0x00000000, 0x33800000, 0x34000000, 0x34400000, 0x34800000, 0x34A00000, 0x34C00000, 0x34E00000, 0x35000000, 0x35100000, 0x35200000, 0x35300000, 0x35400000, 0x35500000, 0x35600000, 0x35700000,
  0x35800000, 0x35880000, 0x35900000, 0x35980000, 0x35A00000, 0x35A80000, 0x35B00000, 0x35B80000, 0x35C00000, 0x35C80000, 0x35D00000, 0x35D80000, 0x35E00000, 0x35E80000, 0x35F00000, 0x35F80000,
  0x36000000, 0x36040000, 0x36080000, 0x360C0000, 0x36100000, 0x36140000, 0x36180000, 0x361C0000, 0x36200000, 0x36240000, 0x36280000, 0x362C0000, 0x36300000, 0x36340000, 0x36380000, 0x363C0000,
  0x36400000, 0x36440000, 0x36480000, 0x364C0000, 0x36500000, 0x36540000, 0x36580000, 0x365C0000, 0x36600000, 0x36640000, 0x36680000, 0x366C0000, 0x36700000, 0x36740000, 0x36780000, 0x367C0000,
  0x36800000, 0x36820000, 0x36840000, 0x36860000, 0x36880000, 0x368A0000, 0x368C0000, 0x368E0000, 0x36900000, 0x36920000, 0x36940000, 0x36960000, 0x36980000, 0x369A0000, 0x369C0000, 0x369E0000,
  0x36A00000, 0x36A20000, 0x36A40000, 0x36A60000, 0x36A80000, 0x36AA0000, 0x36AC0000, 0x36AE0000, 0x36B00000, 0x36B20000, 0x36B40000, 0x36B60000, 0x36B80000, 0x36BA0000, 0x36BC0000, 0x36BE0000,
  0x36C00000, 0x36C20000, 0x36C40000, 0x36C60000, 0x36C80000, 0x36CA0000, 0x36CC0000, 0x36CE0000, 0x36D00000, 0x36D20000, 0x36D40000, 0x36D60000, 0x36D80000, 0x36DA0000, 0x36DC0000, 0x36DE0000,
  0x36E00000, 0x36E20000, 0x36E40000, 0x36E60000, 0x36E80000, 0x36EA0000, 0x36EC0000, 0x36EE0000, 0x36F00000, 0x36F20000, 0x36F40000, 0x36F60000, 0x36F80000, 0x36FA0000, 0x36FC0000, 0x36FE0000,
  0x37000000, 0x37010000, 0x37020000, 0x37030000, 0x37040000, 0x37050000, 0x37060000, 0x37070000, 0x37080000, 0x37090000, 0x370A0000, 0x370B0000, 0x370C0000, 0x370D0000, 0x370E0000, 0x370F0000,
  0x37100000, 0x37110000, 0x37120000, 0x37130000, 0x37140000, 0x37150000, 0x37160000, 0x37170000, 0x37180000, 0x37190000, 0x371A0000, 0x371B0000, 0x371C0000, 0x371D0000, 0x371E0000, 0x371F0000,
  0x37200000, 0x37210000, 0x37220000, 0x37230000, 0x37240000, 0x37250000, 0x37260000, 0x37270000, 0x37280000, 0x37290000, 0x372A0000, 0x372B0000, 0x372C0000, 0x372D0000, 0x372E0000, 0x372F0000,
  0x37300000, 0x37310000, 0x37320000, 0x37330000, 0x37340000, 0x37350000, 0x37360000, 0x37370000, 0x37380000, 0x37390000, 0x373A0000, 0x373B0000, 0x373C0000, 0x373D0000, 0x373E0000, 0x373F0000,
  0x37400000, 0x37410000, 0x37420000, 0x37430000, 0x37440000, 0x37450000, 0x37460000, 0x37470000, 0x37480000, 0x37490000, 0x374A0000, 0x374B0000, 0x374C0000, 0x374D0000, 0x374E0000, 0x374F0000,
  0x37500000, 0x37510000, 0x37520000, 0x37530000, 0x37540000, 0x37550000, 0x37560000, 0x37570000, 0x37580000, 0x37590000, 0x375A0000, 0x375B0000, 0x375C0000, 0x375D0000, 0x375E0000, 0x375F0000,
  0x37600000, 0x37610000, 0x37620000, 0x37630000, 0x37640000, 0x37650000, 0x37660000, 0x37670000, 0x37680000, 0x37690000, 0x376A0000, 0x376B0000, 0x376C0000, 0x376D0000, 0x376E0000, 0x376F0000,
  0x37700000, 0x37710000, 0x37720000, 0x37730000, 0x37740000, 0x37750000, 0x37760000, 0x37770000, 0x37780000, 0x37790000, 0x377A0000, 0x377B0000, 0x377C0000, 0x377D0000, 0x377E0000, 0x377F0000,
  0x37800000, 0x37808000, 0x37810000, 0x37818000, 0x37820000, 0x37828000, 0x37830000, 0x37838000, 0x37840000, 0x37848000, 0x37850000, 0x37858000, 0x37860000, 0x37868000, 0x37870000, 0x37878000,
  0x37880000, 0x37888000, 0x37890000, 0x37898000, 0x378A0000, 0x378A8000, 0x378B0000, 0x378B8000, 0x378C0000, 0x378C8000, 0x378D0000, 0x378D8000, 0x378E0000, 0x378E8000, 0x378F0000, 0x378F8000,
  0x37900000, 0x37908000, 0x37910000, 0x37918000, 0x37920000, 0x37928000, 0x37930000, 0x37938000, 0x37940000, 0x37948000, 0x37950000, 0x37958000, 0x37960000, 0x37968000, 0x37970000, 0x37978000,
  0x37980000, 0x37988000, 0x37990000, 0x37998000, 0x379A0000, 0x379A8000, 0x379B0000, 0x379B8000, 0x379C0000, 0x379C8000, 0x379D0000, 0x379D8000, 0x379E0000, 0x379E8000, 0x379F0000, 0x379F8000,
  0x37A00000, 0x37A08000, 0x37A10000, 0x37A18000, 0x37A20000, 0x37A28000, 0x37A30000, 0x37A38000, 0x37A40000, 0x37A48000, 0x37A50000, 0x37A58000, 0x37A60000, 0x37A68000, 0x37A70000, 0x37A78000,
  0x37A80000, 0x37A88000, 0x37A90000, 0x37A98000, 0x37AA0000, 0x37AA8000, 0x37AB0000, 0x37AB8000, 0x37AC0000, 0x37AC8000, 0x37AD0000, 0x37AD8000, 0x37AE0000, 0x37AE8000, 0x37AF0000, 0x37AF8000,
  0x37B00000, 0x37B08000, 0x37B10000, 0x37B18000, 0x37B20000, 0x37B28000, 0x37B30000, 0x37B38000, 0x37B40000, 0x37B48000, 0x37B50000, 0x37B58000, 0x37B60000, 0x37B68000, 0x37B70000, 0x37B78000,
  0x37B80000, 0x37B88000, 0x37B90000, 0x37B98000, 0x37BA0000, 0x37BA8000, 0x37BB0000, 0x37BB8000, 0x37BC0000, 0x37BC8000, 0x37BD0000, 0x37BD8000, 0x37BE0000, 0x37BE8000, 0x37BF0000, 0x37BF8000,
  0x37C00000, 0x37C08000, 0x37C10000, 0x37C18000, 0x37C20000, 0x37C28000, 0x37C30000, 0x37C38000, 0x37C40000, 0x37C48000, 0x37C50000, 0x37C58000, 0x37C60000, 0x37C68000, 0x37C70000, 0x37C78000,
  0x37C80000, 0x37C88000, 0x37C90000, 0x37C98000, 0x37CA0000, 0x37CA8000, 0x37CB0000, 0x37CB8000, 0x37CC0000, 0x37CC8000, 0x37CD0000, 0x37CD8000, 0x37CE0000, 0x37CE8000, 0x37CF0000, 0x37CF8000,
  0x37D00000, 0x37D08000, 0x37D10000, 0x37D18000, 0x37D20000, 0x37D28000, 0x37D30000, 0x37D38000, 0x37D40000, 0x37D48000, 0x37D50000, 0x37D58000, 0x37D60000, 0x37D68000, 0x37D70000, 0x37D78000,
  0x37D80000, 0x37D88000, 0x37D90000, 0x37D98000, 0x37DA0000, 0x37DA8000, 0x37DB0000, 0x37DB8000, 0x37DC0000, 0x37DC8000, 0x37DD0000, 0x37DD8000, 0x37DE0000, 0x37DE8000, 0x37DF0000, 0x37DF8000,
  0x37E00000, 0x37E08000, 0x37E10000, 0x37E18000, 0x37E20000, 0x37E28000, 0x37E30000, 0x37E38000, 0x37E40000, 0x37E48000, 0x37E50000, 0x37E58000, 0x37E60000, 0x37E68000, 0x37E70000, 0x37E78000,
  0x37E80000, 0x37E88000, 0x37E90000, 0x37E98000, 0x37EA0000, 0x37EA8000, 0x37EB0000, 0x37EB8000, 0x37EC0000, 0x37EC8000, 0x37ED0000, 0x37ED8000, 0x37EE0000, 0x37EE8000, 0x37EF0000, 0x37EF8000,
  0x37F00000, 0x37F08000, 0x37F10000, 0x37F18000, 0x37F20000, 0x37F28000, 0x37F30000, 0x37F38000, 0x37F40000, 0x37F48000, 0x37F50000, 0x37F58000, 0x37F60000, 0x37F68000, 0x37F70000, 0x37F78000,
  0x37F80000, 0x37F88000, 0x37F90000, 0x37F98000, 0x37FA0000, 0x37FA8000, 0x37FB0000, 0x37FB8000, 0x37FC0000, 0x37FC8000, 0x37FD0000, 0x37FD8000, 0x37FE0000, 0x37FE8000, 0x37FF0000, 0x37FF8000,
  0x38000000, 0x38004000, 0x38008000, 0x3800C000, 0x38010000, 0x38014000, 0x38018000, 0x3801C000, 0x38020000, 0x38024000, 0x38028000, 0x3802C000, 0x38030000, 0x38034000, 0x38038000, 0x3803C000,
  0x38040000, 0x38044000, 0x38048000, 0x3804C000, 0x38050000, 0x38054000, 0x38058000, 0x3805C000, 0x38060000, 0x38064000, 0x38068000, 0x3806C000, 0x38070000, 0x38074000, 0x38078000, 0x3807C000,
  0x38080000, 0x38084000, 0x38088000, 0x3808C000, 0x38090000, 0x38094000, 0x38098000, 0x3809C000, 0x380A0000, 0x380A4000, 0x380A8000, 0x380AC000, 0x380B0000, 0x380B4000, 0x380B8000, 0x380BC000,
  0x380C0000, 0x380C4000, 0x380C8000, 0x380CC000, 0x380D0000, 0x380D4000, 0x380D8000, 0x380DC000, 0x380E0000, 0x380E4000, 0x380E8000, 0x380EC000, 0x380F0000, 0x380F4000, 0x380F8000, 0x380FC000,
  0x38100000, 0x38104000, 0x38108000, 0x3810C000, 0x38110000, 0x38114000, 0x38118000, 0x3811C000, 0x38120000, 0x38124000, 0x38128000, 0x3812C000, 0x38130000, 0x38134000, 0x38138000, 0x3813C000,
  0x38140000, 0x38144000, 0x38148000, 0x3814C000, 0x38150000, 0x38154000, 0x38158000, 0x3815C000, 0x38160000, 0x38164000, 0x38168000, 0x3816C000, 0x38170000, 0x38174000, 0x38178000, 0x3817C000,
  0x38180000, 0x38184000, 0x38188000, 0x3818C000, 0x38190000, 0x38194000, 0x38198000, 0x3819C000, 0x381A0000, 0x381A4000, 0x381A8000, 0x381AC000, 0x381B0000, 0x381B4000, 0x381B8000, 0x381BC000,
  0x381C0000, 0x381C4000, 0x381C8000, 0x381CC000, 0x381D0000, 0x381D4000, 0x381D8000, 0x381DC000, 0x381E0000, 0x381E4000, 0x381E8000, 0x381EC000, 0x381F0000, 0x381F4000, 0x381F8000, 0x381FC000,
  0x38200000, 0x38204000, 0x38208000, 0x3820C000, 0x38210000, 0x38214000, 0x38218000, 0x3821C000, 0x38220000, 0x38224000, 0x38228000, 0x3822C000, 0x38230000, 0x38234000, 0x38238000, 0x3823C000,
  0x38240000, 0x38244000, 0x38248000, 0x3824C000, 0x38250000, 0x38254000, 0x38258000, 0x3825C000, 0x38260000, 0x38264000, 0x38268000, 0x3826C000, 0x38270000, 0x38274000, 0x38278000, 0x3827C000,
  0x38280000, 0x38284000, 0x38288000, 0x3828C000, 0x38290000, 0x38294000, 0x38298000, 0x3829C000, 0x382A0000, 0x382A4000, 0x382A8000, 0x382AC000, 0x382B0000, 0x382B4000, 0x382B8000, 0x382BC000,
  0x382C0000, 0x382C4000, 0x382C8000, 0x382CC000, 0x382D0000, 0x382D4000, 0x382D8000, 0x382DC000, 0x382E0000, 0x382E4000, 0x382E8000, 0x382EC000, 0x382F0000, 0x382F4000, 0x382F8000, 0x382FC000,
  0x38300000, 0x38304000, 0x38308000, 0x3830C000, 0x38310000, 0x38314000, 0x38318000, 0x3831C000, 0x38320000, 0x38324000, 0x38328000, 0x3832C000, 0x38330000, 0x38334000, 0x38338000, 0x3833C000,
  0x38340000, 0x38344000, 0x38348000, 0x3834C000, 0x38350000, 0x38354000, 0x38358000, 0x3835C000, 0x38360000, 0x38364000, 0x38368000, 0x3836C000, 0x38370000, 0x38374000, 0x38378000, 0x3837C000,
  0x38380000, 0x38384000, 0x38388000, 0x3838C000, 0x38390000, 0x38394000, 0x38398000, 0x3839C000, 0x383A0000, 0x383A4000, 0x383A8000, 0x383AC000, 0x383B0000, 0x383B4000, 0x383B8000, 0x383BC000,
  0x383C0000, 0x383C4000, 0x383C8000, 0x383CC000, 0x383D0000, 0x383D4000, 0x383D8000, 0x383DC000, 0x383E0000, 0x383E4000, 0x383E8000, 0x383EC000, 0x383F0000, 0x383F4000, 0x383F8000, 0x383FC000,
  0x38400000, 0x38404000, 0x38408000, 0x3840C000, 0x38410000, 0x38414000, 0x38418000, 0x3841C000, 0x38420000, 0x38424000, 0x38428000, 0x3842C000, 0x38430000, 0x38434000, 0x38438000, 0x3843C000,
  0x38440000, 0x38444000, 0x38448000, 0x3844C000, 0x38450000, 0x38454000, 0x38458000, 0x3845C000, 0x38460000, 0x38464000, 0x38468000, 0x3846C000, 0x38470000, 0x38474000, 0x38478000, 0x3847C000,
  0x38480000, 0x38484000, 0x38488000, 0x3848C000, 0x38490000, 0x38494000, 0x38498000, 0x3849C000, 0x384A0000, 0x384A4000, 0x384A8000, 0x384AC000, 0x384B0000, 0x384B4000, 0x384B8000, 0x384BC000,
  0x384C0000, 0x384C4000, 0x384C8000, 0x384CC000, 0x384D0000, 0x384D4000, 0x384D8000, 0x384DC000, 0x384E0000, 0x384E4000, 0x384E8000, 0x384EC000, 0x384F0000, 0x384F4000, 0x384F8000, 0x384FC000,
  0x38500000, 0x38504000, 0x38508000, 0x3850C000, 0x38510000, 0x38514000, 0x38518000, 0x3851C000, 0x38520000, 0x38524000, 0x38528000, 0x3852C000, 0x38530000, 0x38534000, 0x38538000, 0x3853C000,
  0x38540000, 0x38544000, 0x38548000, 0x3854C000, 0x38550000, 0x38554000, 0x38558000, 0x3855C000, 0x38560000, 0x38564000, 0x38568000, 0x3856C000, 0x38570000, 0x38574000, 0x38578000, 0x3857C000,
  0x38580000, 0x38584000, 0x38588000, 0x3858C000, 0x38590000, 0x38594000, 0x38598000, 0x3859C000, 0x385A0000, 0x385A4000, 0x385A8000, 0x385AC000, 0x385B0000, 0x385B4000, 0x385B8000, 0x385BC000,
  0x385C0000, 0x385C4000, 0x385C8000, 0x385CC000, 0x385D0000, 0x385D4000, 0x385D8000, 0x385DC000, 0x385E0000, 0x385E4000, 0x385E8000, 0x385EC000, 0x385F0000, 0x385F4000, 0x385F8000, 0x385FC000,
  0x38600000, 0x38604000, 0x38608000, 0x3860C000, 0x38610000, 0x38614000, 0x38618000, 0x3861C000, 0x38620000, 0x38624000, 0x38628000, 0x3862C000, 0x38630000, 0x38634000, 0x38638000, 0x3863C000,
  0x38640000, 0x38644000, 0x38648000, 0x3864C000, 0x38650000, 0x38654000, 0x38658000, 0x3865C000, 0x38660000, 0x38664000, 0x38668000, 0x3866C000, 0x38670000, 0x38674000, 0x38678000, 0x3867C000,
  0x38680000, 0x38684000, 0x38688000, 0x3868C000, 0x38690000, 0x38694000, 0x38698000, 0x3869C000, 0x386A0000, 0x386A4000, 0x386A8000, 0x386AC000, 0x386B0000, 0x386B4000, 0x386B8000, 0x386BC000,
  0x386C0000, 0x386C4000, 0x386C8000, 0x386CC000, 0x386D0000, 0x386D4000, 0x386D8000, 0x386DC000, 0x386E0000, 0x386E4000, 0x386E8000, 0x386EC000, 0x386F0000, 0x386F4000, 0x386F8000, 0x386FC000,
  0x38700000, 0x38704000, 0x38708000, 0x3870C000, 0x38710000, 0x38714000, 0x38718000, 0x3871C000, 0x38720000, 0x38724000, 0x38728000, 0x3872C000, 0x38730000, 0x38734000, 0x38738000, 0x3873C000,
  0x38740000, 0x38744000, 0x38748000, 0x3874C000, 0x38750000, 0x38754000, 0x38758000, 0x3875C000, 0x38760000, 0x38764000, 0x38768000, 0x3876C000, 0x38770000, 0x38774000, 0x38778000, 0x3877C000,
  0x38780000, 0x38784000, 0x38788000, 0x3878C000, 0x38790000, 0x38794000, 0x38798000, 0x3879C000, 0x387A0000, 0x387A4000, 0x387A8000, 0x387AC000, 0x387B0000, 0x387B4000, 0x387B8000, 0x387BC000,
  0x387C0000, 0x387C4000, 0x387C8000, 0x387CC000, 0x387D0000, 0x387D4000, 0x387D8000, 0x387DC000, 0x387E0000, 0x387E4000, 0x387E8000, 0x387EC000, 0x387F0000, 0x387F4000, 0x387F8000, 0x387FC000,
  0x38000000, 0x38002000, 0x38004000, 0x38006000, 0x38008000, 0x3800A000, 0x3800C000, 0x3800E000, 0x38010000, 0x38012000, 0x38014000, 0x38016000, 0x38018000, 0x3801A000, 0x3801C000, 0x3801E000,
  0x38020000, 0x38022000, 0x38024000, 0x38026000, 0x38028000, 0x3802A000, 0x3802C000, 0x3802E000, 0x38030000, 0x38032000, 0x38034000, 0x38036000, 0x38038000, 0x3803A000, 0x3803C000, 0x3803E000,
  0x38040000, 0x38042000, 0x38044000, 0x38046000, 0x38048000, 0x3804A000, 0x3804C000, 0x3804E000, 0x38050000, 0x38052000, 0x38054000, 0x38056000, 0x38058000, 0x3805A000, 0x3805C000, 0x3805E000,
  0x38060000, 0x38062000, 0x38064000, 0x38066000, 0x38068000, 0x3806A000, 0x3806C000, 0x3806E000, 0x38070000, 0x38072000, 0x38074000, 0x38076000, 0x38078000, 0x3807A000, 0x3807C000, 0x3807E000,
  0x38080000, 0x38082000, 0x38084000, 0x38086000, 0x38088000, 0x3808A000, 0x3808C000, 0x3808E000, 0x38090000, 0x38092000, 0x38094000, 0x38096000, 0x38098000, 0x3809A000, 0x3809C000, 0x3809E000,
  0x380A0000, 0x380A2000, 0x380A4000, 0x380A6000, 0x380A8000, 0x380AA000, 0x380AC000, 0x380AE000, 0x380B0000, 0x380B2000, 0x380B4000, 0x380B6000, 0x380B8000, 0x380BA000, 0x380BC000, 0x380BE000,
  0x380C0000, 0x380C2000, 0x380C4000, 0x380C6000, 0x380C8000, 0x380CA000, 0x380CC000, 0x380CE000, 0x380D0000, 0x380D2000, 0x380D4000, 0x380D6000, 0x380D8000, 0x380DA000, 0x380DC000, 0x380DE000,
  0x380E0000, 0x380E2000, 0x380E4000, 0x380E6000, 0x380E8000, 0x380EA000, 0x380EC000, 0x380EE000, 0x380F0000, 0x380F2000, 0x380F4000, 0x380F6000, 0x380F8000, 0x380FA000, 0x380FC000, 0x380FE000,
  0x38100000, 0x38102000, 0x38104000, 0x38106000, 0x38108000, 0x3810A000, 0x3810C000, 0x3810E000, 0x38110000, 0x38112000, 0x38114000, 0x38116000, 0x38118000, 0x3811A000, 0x3811C000, 0x3811E000,
  0x38120000, 0x38122000, 0x38124000, 0x38126000, 0x38128000, 0x3812A000, 0x3812C000, 0x3812E000, 0x38130000, 0x38132000, 0x38134000, 0x38136000, 0x38138000, 0x3813A000, 0x3813C000, 0x3813E000,
  0x38140000, 0x38142000, 0x38144000, 0x38146000, 0x38148000, 0x3814A000, 0x3814C000, 0x3814E000, 0x38150000, 0x38152000, 0x38154000, 0x38156000, 0x38158000, 0x3815A000, 0x3815C000, 0x3815E000,
  0x38160000, 0x38162000, 0x38164000, 0x38166000, 0x38168000, 0x3816A000, 0x3816C000, 0x3816E000, 0x38170000, 0x38172000, 0x38174000, 0x38176000, 0x38178000, 0x3817A000, 0x3817C000, 0x3817E000,
  0x38180000, 0x38182000, 0x38184000, 0x38186000, 0x38188000, 0x3818A000, 0x3818C000, 0x3818E000, 0x38190000, 0x38192000, 0x38194000, 0x38196000, 0x38198000, 0x3819A000, 0x3819C000, 0x3819E000,
  0x381A0000, 0x381A2000, 0x381A4000, 0x381A6000, 0x381A8000, 0x381AA000, 0x381AC000, 0x381AE000, 0x381B0000, 0x381B2000, 0x381B4000, 0x381B6000, 0x381B8000, 0x381BA000, 0x381BC000, 0x381BE000,
  0x381C0000, 0x381C2000, 0x381C4000, 0x381C6000, 0x381C8000, 0x381CA000, 0x381CC000, 0x381CE000, 0x381D0000, 0x381D2000, 0x381D4000, 0x381D6000, 0x381D8000, 0x381DA000, 0x381DC000, 0x381DE000,
  0x381E0000, 0x381E2000, 0x381E4000, 0x381E6000, 0x381E8000, 0x381EA000, 0x381EC000, 0x381EE000, 0x381F0000, 0x381F2000, 0x381F4000, 0x381F6000, 0x381F8000, 0x381FA000, 0x381FC000, 0x381FE000,
  0x38200000, 0x38202000, 0x38204000, 0x38206000, 0x38208000, 0x3820A000, 0x3820C000, 0x3820E000, 0x38210000, 0x38212000, 0x38214000, 0x38216000, 0x38218000, 0x3821A000, 0x3821C000, 0x3821E000,
  0x38220000, 0x38222000, 0x38224000, 0x38226000, 0x38228000, 0x3822A000, 0x3822C000, 0x3822E000, 0x38230000, 0x38232000, 0x38234000, 0x38236000, 0x38238000, 0x3823A000, 0x3823C000, 0x3823E000,
  0x38240000, 0x38242000, 0x38244000, 0x38246000, 0x38248000, 0x3824A000, 0x3824C000, 0x3824E000, 0x38250000, 0x38252000, 0x38254000, 0x38256000, 0x38258000, 0x3825A000, 0x3825C000, 0x3825E000,
  0x38260000, 0x38262000, 0x38264000, 0x38266000, 0x38268000, 0x3826A000, 0x3826C000, 0x3826E000, 0x38270000, 0x38272000, 0x38274000, 0x38276000, 0x38278000, 0x3827A000, 0x3827C000, 0x3827E000,
  0x38280000, 0x38282000, 0x38284000, 0x38286000, 0x38288000, 0x3828A000, 0x3828C000, 0x3828E000, 0x38290000, 0x38292000, 0x38294000, 0x38296000, 0x38298000, 0x3829A000, 0x3829C000, 0x3829E000,
  0x382A0000, 0x382A2000, 0x382A4000, 0x382A6000, 0x382A8000, 0x382AA000, 0x382AC000, 0x382AE000, 0x382B0000, 0x382B2000, 0x382B4000, 0x382B6000, 0x382B8000, 0x382BA000, 0x382BC000, 0x382BE000,
  0x382C0000, 0x382C2000, 0x382C4000, 0x382C6000, 0x382C8000, 0x382CA000, 0x382CC000, 0x382CE000, 0x382D0000, 0x382D2000, 0x382D4000, 0x382D6000, 0x382D8000, 0x382DA000, 0x382DC000, 0x382DE000,
  0x382E0000, 0x382E2000, 0x382E4000, 0x382E6000, 0x382E8000, 0x382EA000, 0x382EC000, 0x382EE000, 0x382F0000, 0x382F2000, 0x382F4000, 0x382F6000, 0x382F8000, 0x382FA000, 0x382FC000, 0x382FE000,
  0x38300000, 0x38302000, 0x38304000, 0x38306000, 0x38308000, 0x3830A000, 0x3830C000, 0x3830E000, 0x38310000, 0x38312000, 0x38314000, 0x38316000, 0x38318000, 0x3831A000, 0x3831C000, 0x3831E000,
  0x38320000, 0x38322000, 0x38324000, 0x38326000, 0x38328000, 0x3832A000, 0x3832C000, 0x3832E000, 0x38330000, 0x38332000, 0x38334000, 0x38336000, 0x38338000, 0x3833A000, 0x3833C000, 0x3833E000,
  0x38340000, 0x38342000, 0x38344000, 0x38346000, 0x38348000, 0x3834A000, 0x3834C000, 0x3834E000, 0x38350000, 0x38352000, 0x38354000, 0x38356000, 0x38358000, 0x3835A000, 0x3835C000, 0x3835E000,
  0x38360000, 0x38362000, 0x38364000, 0x38366000, 0x38368000, 0x3836A000, 0x3836C000, 0x3836E000, 0x38370000, 0x38372000, 0x38374000, 0x38376000, 0x38378000, 0x3837A000, 0x3837C000, 0x3837E000,
  0x38380000, 0x38382000, 0x38384000, 0x38386000, 0x38388000, 0x3838A000, 0x3838C000, 0x3838E000, 0x38390000, 0x38392000, 0x38394000, 0x38396000, 0x38398000, 0x3839A000, 0x3839C000, 0x3839E000,
  0x383A0000, 0x383A2000, 0x383A4000, 0x383A6000, 0x383A8000, 0x383AA000, 0x383AC000, 0x383AE000, 0x383B0000, 0x383B2000, 0x383B4000, 0x383B6000, 0x383B8000, 0x383BA000, 0x383BC000, 0x383BE000,
  0x383C0000, 0x383C2000, 0x383C4000, 0x383C6000, 0x383C8000, 0x383CA000, 0x383CC000, 0x383CE000, 0x383D0000, 0x383D2000, 0x383D4000, 0x383D6000, 0x383D8000, 0x383DA000, 0x383DC000, 0x383DE000,
  0x383E0000, 0x383E2000, 0x383E4000, 0x383E6000, 0x383E8000, 0x383EA000, 0x383EC000, 0x383EE000, 0x383F0000, 0x383F2000, 0x383F4000, 0x383F6000, 0x383F8000, 0x383FA000, 0x383FC000, 0x383FE000,
  0x38400000, 0x38402000, 0x38404000, 0x38406000, 0x38408000, 0x3840A000, 0x3840C000, 0x3840E000, 0x38410000, 0x38412000, 0x38414000, 0x38416000, 0x38418000, 0x3841A000, 0x3841C000, 0x3841E000,
  0x38420000, 0x38422000, 0x38424000, 0x38426000, 0x38428000, 0x3842A000, 0x3842C000, 0x3842E000, 0x38430000, 0x38432000, 0x38434000, 0x38436000, 0x38438000, 0x3843A000, 0x3843C000, 0x3843E000,
  0x38440000, 0x38442000, 0x38444000, 0x38446000, 0x38448000, 0x3844A000, 0x3844C000, 0x3844E000, 0x38450000, 0x38452000, 0x38454000, 0x38456000, 0x38458000, 0x3845A000, 0x3845C000, 0x3845E000,
  0x38460000, 0x38462000, 0x38464000, 0x38466000, 0x38468000, 0x3846A000, 0x3846C000, 0x3846E000, 0x38470000, 0x38472000, 0x38474000, 0x38476000, 0x38478000, 0x3847A000, 0x3847C000, 0x3847E000,
  0x38480000, 0x38482000, 0x38484000, 0x38486000, 0x38488000, 0x3848A000, 0x3848C000, 0x3848E000, 0x38490000, 0x38492000, 0x38494000, 0x38496000, 0x38498000, 0x3849A000, 0x3849C000, 0x3849E000,
  0x384A0000, 0x384A2000, 0x384A4000, 0x384A6000, 0x384A8000, 0x384AA000, 0x384AC000, 0x384AE000, 0x384B0000, 0x384B2000, 0x384B4000, 0x384B6000, 0x384B8000, 0x384BA000, 0x384BC000, 0x384BE000,
  0x384C0000, 0x384C2000, 0x384C4000, 0x384C6000, 0x384C8000, 0x384CA000, 0x384CC000, 0x384CE000, 0x384D0000, 0x384D2000, 0x384D4000, 0x384D6000, 0x384D8000, 0x384DA000, 0x384DC000, 0x384DE000,
  0x384E0000, 0x384E2000, 0x384E4000, 0x384E6000, 0x384E8000, 0x384EA000, 0x384EC000, 0x384EE000, 0x384F0000, 0x384F2000, 0x384F4000, 0x384F6000, 0x384F8000, 0x384FA000, 0x384FC000, 0x384FE000,
  0x38500000, 0x38502000, 0x38504000, 0x38506000, 0x38508000, 0x3850A000, 0x3850C000, 0x3850E000, 0x38510000, 0x38512000, 0x38514000, 0x38516000, 0x38518000, 0x3851A000, 0x3851C000, 0x3851E000,
  0x38520000, 0x38522000, 0x38524000, 0x38526000, 0x38528000, 0x3852A000, 0x3852C000, 0x3852E000, 0x38530000, 0x38532000, 0x38534000, 0x38536000, 0x38538000, 0x3853A000, 0x3853C000, 0x3853E000,
  0x38540000, 0x38542000, 0x38544000, 0x38546000, 0x38548000, 0x3854A000, 0x3854C000, 0x3854E000, 0x38550000, 0x38552000, 0x38554000, 0x38556000, 0x38558000, 0x3855A000, 0x3855C000, 0x3855E000,
  0x38560000, 0x38562000, 0x38564000, 0x38566000, 0x38568000, 0x3856A000, 0x3856C000, 0x3856E000, 0x38570000, 0x38572000, 0x38574000, 0x38576000, 0x38578000, 0x3857A000, 0x3857C000, 0x3857E000,
  0x38580000, 0x38582000, 0x38584000, 0x38586000, 0x38588000, 0x3858A000, 0x3858C000, 0x3858E000, 0x38590000, 0x38592000, 0x38594000, 0x38596000, 0x38598000, 0x3859A000, 0x3859C000, 0x3859E000,
  0x385A0000, 0x385A2000, 0x385A4000, 0x385A6000, 0x385A8000, 0x385AA000, 0x385AC000, 0x385AE000, 0x385B0000, 0x385B2000, 0x385B4000, 0x385B6000, 0x385B8000, 0x385BA000, 0x385BC000, 0x385BE000,
  0x385C0000, 0x385C2000, 0x385C4000, 0x385C6000, 0x385C8000, 0x385CA000, 0x385CC000, 0x385CE000, 0x385D0000, 0x385D2000, 0x385D4000, 0x385D6000, 0x385D8000, 0x385DA000, 0x385DC000, 0x385DE000,
  0x385E0000, 0x385E2000, 0x385E4000, 0x385E6000, 0x385E8000, 0x385EA000, 0x385EC000, 0x385EE000, 0x385F0000, 0x385F2000, 0x385F4000, 0x385F6000, 0x385F8000, 0x385FA000, 0x385FC000, 0x385FE000,
  0x38600000, 0x38602000, 0x38604000, 0x38606000, 0x38608000, 0x3860A000, 0x3860C000, 0x3860E000, 0x38610000, 0x38612000, 0x38614000, 0x38616000, 0x38618000, 0x3861A000, 0x3861C000, 0x3861E000,
  0x38620000, 0x38622000, 0x38624000, 0x38626000, 0x38628000, 0x3862A000, 0x3862C000, 0x3862E000, 0x38630000, 0x38632000, 0x38634000, 0x38636000, 0x38638000, 0x3863A000, 0x3863C000, 0x3863E000,
  0x38640000, 0x38642000, 0x38644000, 0x38646000, 0x38648000, 0x3864A000, 0x3864C000, 0x3864E000, 0x38650000, 0x38652000, 0x38654000, 0x38656000, 0x38658000, 0x3865A000, 0x3865C000, 0x3865E000,
  0x38660000, 0x38662000, 0x38664000, 0x38666000, 0x38668000, 0x3866A000, 0x3866C000, 0x3866E000, 0x38670000, 0x38672000, 0x38674000, 0x38676000, 0x38678000, 0x3867A000, 0x3867C000, 0x3867E000,
  0x38680000, 0x38682000, 0x38684000, 0x38686000, 0x38688000, 0x3868A000, 0x3868C000, 0x3868E000, 0x38690000, 0x38692000, 0x38694000, 0x38696000, 0x38698000, 0x3869A000, 0x3869C000, 0x3869E000,
  0x386A0000, 0x386A2000, 0x386A4000, 0x386A6000, 0x386A8000, 0x386AA000, 0x386AC000, 0x386AE000, 0x386B0000, 0x386B2000, 0x386B4000, 0x386B6000, 0x386B8000, 0x386BA000, 0x386BC000, 0x386BE000,
  0x386C0000, 0x386C2000, 0x386C4000, 0x386C6000, 0x386C8000, 0x386CA000, 0x386CC000, 0x386CE000, 0x386D0000, 0x386D2000, 0x386D4000, 0x386D6000, 0x386D8000, 0x386DA000, 0x386DC000, 0x386DE000,
  0x386E0000, 0x386E2000, 0x386E4000, 0x386E6000, 0x386E8000, 0x386EA000, 0x386EC000, 0x386EE000, 0x386F0000, 0x386F2000, 0x386F4000, 0x386F6000, 0x386F8000, 0x386FA000, 0x386FC000, 0x386FE000,
  0x38700000, 0x38702000, 0x38704000, 0x38706000, 0x38708000, 0x3870A000, 0x3870C000, 0x3870E000, 0x38710000, 0x38712000, 0x38714000, 0x38716000, 0x38718000, 0x3871A000, 0x3871C000, 0x3871E000,
  0x38720000, 0x38722000, 0x38724000, 0x38726000, 0x38728000, 0x3872A000, 0x3872C000, 0x3872E000, 0x38730000, 0x38732000, 0x38734000, 0x38736000, 0x38738000, 0x3873A000, 0x3873C000, 0x3873E000,
  0x38740000, 0x38742000, 0x38744000, 0x38746000, 0x38748000, 0x3874A000, 0x3874C000, 0x3874E000, 0x38750000, 0x38752000, 0x38754000, 0x38756000, 0x38758000, 0x3875A000, 0x3875C000, 0x3875E000,
  0x38760000, 0x38762000, 0x38764000, 0x38766000, 0x38768000, 0x3876A000, 0x3876C000, 0x3876E000, 0x38770000, 0x38772000, 0x38774000, 0x38776000, 0x38778000, 0x3877A000, 0x3877C000, 0x3877E000,
  0x38780000, 0x38782000, 0x38784000, 0x38786000, 0x38788000, 0x3878A000, 0x3878C000, 0x3878E000, 0x38790000, 0x38792000, 0x38794000, 0x38796000, 0x38798000, 0x3879A000, 0x3879C000, 0x3879E000,
  0x387A0000, 0x387A2000, 0x387A4000, 0x387A6000, 0x387A8000, 0x387AA000, 0x387AC000, 0x387AE000, 0x387B0000, 0x387B2000, 0x387B4000, 0x387B6000, 0x387B8000, 0x387BA000, 0x387BC000, 0x387BE000,
  0x387C0000, 0x387C2000, 0x387C4000, 0x387C6000, 0x387C8000, 0x387CA000, 0x387CC000, 0x387CE000, 0x387D0000, 0x387D2000, 0x387D4000, 0x387D6000, 0x387D8000, 0x387DA000, 0x387DC000, 0x387DE000,
  0x387E0000, 0x387E2000, 0x387E4000, 0x387E6000, 0x387E8000, 0x387EA000, 0x387EC000, 0x387EE000, 0x387F0000, 0x387F2000, 0x387F4000, 0x387F6000, 0x387F8000, 0x387FA000, 0x387FC000, 0x387FE000 };
__constant static const uint32_t exponent_table[64] = {
  0x00000000, 0x00800000, 0x01000000, 0x01800000, 0x02000000, 0x02800000, 0x03000000, 0x03800000, 0x04000000, 0x04800000, 0x05000000, 0x05800000, 0x06000000, 0x06800000, 0x07000000, 0x07800000,
  0x08000000, 0x08800000, 0x09000000, 0x09800000, 0x0A000000, 0x0A800000, 0x0B000000, 0x0B800000, 0x0C000000, 0x0C800000, 0x0D000000, 0x0D800000, 0x0E000000, 0x0E800000, 0x0F000000, 0x47800000,
  0x80000000, 0x80800000, 0x81000000, 0x81800000, 0x82000000, 0x82800000, 0x83000000, 0x83800000, 0x84000000, 0x84800000, 0x85000000, 0x85800000, 0x86000000, 0x86800000, 0x87000000, 0x87800000,
  0x88000000, 0x88800000, 0x89000000, 0x89800000, 0x8A000000, 0x8A800000, 0x8B000000, 0x8B800000, 0x8C000000, 0x8C800000, 0x8D000000, 0x8D800000, 0x8E000000, 0x8E800000, 0x8F000000, 0xC7800000 };
__constant static const unsigned short offset_table[64] = {
  0, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
  0, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 };

static uint16_t float2halfbits(float value) {
  union { float x; uint32_t y; } u;
  u.x = value;
  uint32_t bits = u.y;

  uint16_t hbits = base_table[bits>>23] + (uint16_t)((bits&0x7FFFFF)>>shift_table[bits>>23]);;

  return hbits;
}

static float halfbits2float(uint16_t value) {
  uint32_t bits = mantissa_table[offset_table[value>>10]+(value&0x3FF)] + exponent_table[value>>10];

  union { uint32_t x; float y; } u;
  u.x = bits;
  return u.y;
}

// End of half.h.
// Start of timing.h.

// The function get_wall_time() returns the wall time in microseconds
// (with an unspecified offset).

#ifdef _WIN32

#include <windows.h>

static int64_t get_wall_time(void) {
  LARGE_INTEGER time,freq;
  assert(QueryPerformanceFrequency(&freq));
  assert(QueryPerformanceCounter(&time));
  return ((double)time.QuadPart / freq.QuadPart) * 1000000;
}

#else
// Assuming POSIX

#include <time.h>
#include <sys/time.h>

static int64_t get_wall_time(void) {
  struct timeval time;
  assert(gettimeofday(&time,NULL) == 0);
  return time.tv_sec * 1000000 + time.tv_usec;
}

static int64_t get_wall_time_ns(void) {
  struct timespec time;
  assert(clock_gettime(CLOCK_REALTIME, &time) == 0);
  return time.tv_sec * 1000000000 + time.tv_nsec;
}

#endif

// End of timing.h.

#ifdef _MSC_VER
#define inline __inline
#endif
#include <string.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>



// Start of lock.h.

// A very simple cross-platform implementation of locks.  Uses
// pthreads on Unix and some Windows thing there.  Futhark's
// host-level code is not multithreaded, but user code may be, so we
// need some mechanism for ensuring atomic access to API functions.
// This is that mechanism.  It is not exposed to user code at all, so
// we do not have to worry about name collisions.

#ifdef _WIN32

typedef HANDLE lock_t;

static void create_lock(lock_t *lock) {
  *lock = CreateMutex(NULL,  // Default security attributes.
                      FALSE, // Initially unlocked.
                      NULL); // Unnamed.
}

static void lock_lock(lock_t *lock) {
  assert(WaitForSingleObject(*lock, INFINITE) == WAIT_OBJECT_0);
}

static void lock_unlock(lock_t *lock) {
  assert(ReleaseMutex(*lock));
}

static void free_lock(lock_t *lock) {
  CloseHandle(*lock);
}

#else
// Assuming POSIX

#include <pthread.h>

typedef pthread_mutex_t lock_t;

static void create_lock(lock_t *lock) {
  int r = pthread_mutex_init(lock, NULL);
  assert(r == 0);
}

static void lock_lock(lock_t *lock) {
  int r = pthread_mutex_lock(lock);
  assert(r == 0);
}

static void lock_unlock(lock_t *lock) {
  int r = pthread_mutex_unlock(lock);
  assert(r == 0);
}

static void free_lock(lock_t *lock) {
  // Nothing to do for pthreads.
  (void)lock;
}

#endif

// End of lock.h.

#define FUTHARK_F64_ENABLED

// Start of scalar.h.

// Implementation of the primitive scalar operations.  Very
// repetitive.  This code is inserted directly into both CUDA and
// OpenCL programs, as well as the CPU code, so it has some #ifdefs to
// work everywhere.  Some operations are defined as macros because
// this allows us to use them as constant expressions in things like
// array sizes and static initialisers.

// Some of the #ifdefs are because OpenCL uses type-generic functions
// for some operations (e.g. sqrt), while C and CUDA sensibly use
// distinct functions for different precisions (e.g. sqrtf() and
// sqrt()).  This is quite annoying.  Due to C's unfortunate casting
// rules, it is also really easy to accidentally implement
// floating-point functions in the wrong precision, so be careful.

// Double-precision definitions are only included if the preprocessor
// macro FUTHARK_F64_ENABLED is set.

static inline uint8_t add8(uint8_t x, uint8_t y) {
  return x + y;
}

static inline uint16_t add16(uint16_t x, uint16_t y) {
  return x + y;
}

static inline uint32_t add32(uint32_t x, uint32_t y) {
  return x + y;
}

static inline uint64_t add64(uint64_t x, uint64_t y) {
  return x + y;
}

static inline uint8_t sub8(uint8_t x, uint8_t y) {
  return x - y;
}

static inline uint16_t sub16(uint16_t x, uint16_t y) {
  return x - y;
}

static inline uint32_t sub32(uint32_t x, uint32_t y) {
  return x - y;
}

static inline uint64_t sub64(uint64_t x, uint64_t y) {
  return x - y;
}

static inline uint8_t mul8(uint8_t x, uint8_t y) {
  return x * y;
}

static inline uint16_t mul16(uint16_t x, uint16_t y) {
  return x * y;
}

static inline uint32_t mul32(uint32_t x, uint32_t y) {
  return x * y;
}

static inline uint64_t mul64(uint64_t x, uint64_t y) {
  return x * y;
}

static inline uint8_t udiv8(uint8_t x, uint8_t y) {
  return x / y;
}

static inline uint16_t udiv16(uint16_t x, uint16_t y) {
  return x / y;
}

static inline uint32_t udiv32(uint32_t x, uint32_t y) {
  return x / y;
}

static inline uint64_t udiv64(uint64_t x, uint64_t y) {
  return x / y;
}

static inline uint8_t udiv_up8(uint8_t x, uint8_t y) {
  return (x + y - 1) / y;
}

static inline uint16_t udiv_up16(uint16_t x, uint16_t y) {
  return (x + y - 1) / y;
}

static inline uint32_t udiv_up32(uint32_t x, uint32_t y) {
  return (x + y - 1) / y;
}

static inline uint64_t udiv_up64(uint64_t x, uint64_t y) {
  return (x + y - 1) / y;
}

static inline uint8_t umod8(uint8_t x, uint8_t y) {
  return x % y;
}

static inline uint16_t umod16(uint16_t x, uint16_t y) {
  return x % y;
}

static inline uint32_t umod32(uint32_t x, uint32_t y) {
  return x % y;
}

static inline uint64_t umod64(uint64_t x, uint64_t y) {
  return x % y;
}

static inline uint8_t udiv_safe8(uint8_t x, uint8_t y) {
  return y == 0 ? 0 : x / y;
}

static inline uint16_t udiv_safe16(uint16_t x, uint16_t y) {
  return y == 0 ? 0 : x / y;
}

static inline uint32_t udiv_safe32(uint32_t x, uint32_t y) {
  return y == 0 ? 0 : x / y;
}

static inline uint64_t udiv_safe64(uint64_t x, uint64_t y) {
  return y == 0 ? 0 : x / y;
}

static inline uint8_t udiv_up_safe8(uint8_t x, uint8_t y) {
  return y == 0 ? 0 : (x + y - 1) / y;
}

static inline uint16_t udiv_up_safe16(uint16_t x, uint16_t y) {
  return y == 0 ? 0 : (x + y - 1) / y;
}

static inline uint32_t udiv_up_safe32(uint32_t x, uint32_t y) {
  return y == 0 ? 0 : (x + y - 1) / y;
}

static inline uint64_t udiv_up_safe64(uint64_t x, uint64_t y) {
  return y == 0 ? 0 : (x + y - 1) / y;
}

static inline uint8_t umod_safe8(uint8_t x, uint8_t y) {
  return y == 0 ? 0 : x % y;
}

static inline uint16_t umod_safe16(uint16_t x, uint16_t y) {
  return y == 0 ? 0 : x % y;
}

static inline uint32_t umod_safe32(uint32_t x, uint32_t y) {
  return y == 0 ? 0 : x % y;
}

static inline uint64_t umod_safe64(uint64_t x, uint64_t y) {
  return y == 0 ? 0 : x % y;
}

static inline int8_t sdiv8(int8_t x, int8_t y) {
  int8_t q = x / y;
  int8_t r = x % y;

  return q - ((r != 0 && r < 0 != y < 0) ? 1 : 0);
}

static inline int16_t sdiv16(int16_t x, int16_t y) {
  int16_t q = x / y;
  int16_t r = x % y;

  return q - ((r != 0 && r < 0 != y < 0) ? 1 : 0);
}

static inline int32_t sdiv32(int32_t x, int32_t y) {
  int32_t q = x / y;
  int32_t r = x % y;

  return q - ((r != 0 && r < 0 != y < 0) ? 1 : 0);
}

static inline int64_t sdiv64(int64_t x, int64_t y) {
  int64_t q = x / y;
  int64_t r = x % y;

  return q - ((r != 0 && r < 0 != y < 0) ? 1 : 0);
}

static inline int8_t sdiv_up8(int8_t x, int8_t y) {
  return sdiv8(x + y - 1, y);
}

static inline int16_t sdiv_up16(int16_t x, int16_t y) {
  return sdiv16(x + y - 1, y);
}

static inline int32_t sdiv_up32(int32_t x, int32_t y) {
  return sdiv32(x + y - 1, y);
}

static inline int64_t sdiv_up64(int64_t x, int64_t y) {
  return sdiv64(x + y - 1, y);
}

static inline int8_t smod8(int8_t x, int8_t y) {
  int8_t r = x % y;

  return r + (r == 0 || (x > 0 && y > 0) || (x < 0 && y < 0) ? 0 : y);
}

static inline int16_t smod16(int16_t x, int16_t y) {
  int16_t r = x % y;

  return r + (r == 0 || (x > 0 && y > 0) || (x < 0 && y < 0) ? 0 : y);
}

static inline int32_t smod32(int32_t x, int32_t y) {
  int32_t r = x % y;

  return r + (r == 0 || (x > 0 && y > 0) || (x < 0 && y < 0) ? 0 : y);
}

static inline int64_t smod64(int64_t x, int64_t y) {
  int64_t r = x % y;

  return r + (r == 0 || (x > 0 && y > 0) || (x < 0 && y < 0) ? 0 : y);
}

static inline int8_t sdiv_safe8(int8_t x, int8_t y) {
  return y == 0 ? 0 : sdiv8(x, y);
}

static inline int16_t sdiv_safe16(int16_t x, int16_t y) {
  return y == 0 ? 0 : sdiv16(x, y);
}

static inline int32_t sdiv_safe32(int32_t x, int32_t y) {
  return y == 0 ? 0 : sdiv32(x, y);
}

static inline int64_t sdiv_safe64(int64_t x, int64_t y) {
  return y == 0 ? 0 : sdiv64(x, y);
}

static inline int8_t sdiv_up_safe8(int8_t x, int8_t y) {
  return sdiv_safe8(x + y - 1, y);
}

static inline int16_t sdiv_up_safe16(int16_t x, int16_t y) {
  return sdiv_safe16(x + y - 1, y);
}

static inline int32_t sdiv_up_safe32(int32_t x, int32_t y) {
  return sdiv_safe32(x + y - 1, y);
}

static inline int64_t sdiv_up_safe64(int64_t x, int64_t y) {
  return sdiv_safe64(x + y - 1, y);
}

static inline int8_t smod_safe8(int8_t x, int8_t y) {
  return y == 0 ? 0 : smod8(x, y);
}

static inline int16_t smod_safe16(int16_t x, int16_t y) {
  return y == 0 ? 0 : smod16(x, y);
}

static inline int32_t smod_safe32(int32_t x, int32_t y) {
  return y == 0 ? 0 : smod32(x, y);
}

static inline int64_t smod_safe64(int64_t x, int64_t y) {
  return y == 0 ? 0 : smod64(x, y);
}

static inline int8_t squot8(int8_t x, int8_t y) {
  return x / y;
}

static inline int16_t squot16(int16_t x, int16_t y) {
  return x / y;
}

static inline int32_t squot32(int32_t x, int32_t y) {
  return x / y;
}

static inline int64_t squot64(int64_t x, int64_t y) {
  return x / y;
}

static inline int8_t srem8(int8_t x, int8_t y) {
  return x % y;
}

static inline int16_t srem16(int16_t x, int16_t y) {
  return x % y;
}

static inline int32_t srem32(int32_t x, int32_t y) {
  return x % y;
}

static inline int64_t srem64(int64_t x, int64_t y) {
  return x % y;
}

static inline int8_t squot_safe8(int8_t x, int8_t y) {
  return y == 0 ? 0 : x / y;
}

static inline int16_t squot_safe16(int16_t x, int16_t y) {
  return y == 0 ? 0 : x / y;
}

static inline int32_t squot_safe32(int32_t x, int32_t y) {
  return y == 0 ? 0 : x / y;
}

static inline int64_t squot_safe64(int64_t x, int64_t y) {
  return y == 0 ? 0 : x / y;
}

static inline int8_t srem_safe8(int8_t x, int8_t y) {
  return y == 0 ? 0 : x % y;
}

static inline int16_t srem_safe16(int16_t x, int16_t y) {
  return y == 0 ? 0 : x % y;
}

static inline int32_t srem_safe32(int32_t x, int32_t y) {
  return y == 0 ? 0 : x % y;
}

static inline int64_t srem_safe64(int64_t x, int64_t y) {
  return y == 0 ? 0 : x % y;
}

static inline int8_t smin8(int8_t x, int8_t y) {
  return x < y ? x : y;
}

static inline int16_t smin16(int16_t x, int16_t y) {
  return x < y ? x : y;
}

static inline int32_t smin32(int32_t x, int32_t y) {
  return x < y ? x : y;
}

static inline int64_t smin64(int64_t x, int64_t y) {
  return x < y ? x : y;
}

static inline uint8_t umin8(uint8_t x, uint8_t y) {
  return x < y ? x : y;
}

static inline uint16_t umin16(uint16_t x, uint16_t y) {
  return x < y ? x : y;
}

static inline uint32_t umin32(uint32_t x, uint32_t y) {
  return x < y ? x : y;
}

static inline uint64_t umin64(uint64_t x, uint64_t y) {
  return x < y ? x : y;
}

static inline int8_t smax8(int8_t x, int8_t y) {
  return x < y ? y : x;
}

static inline int16_t smax16(int16_t x, int16_t y) {
  return x < y ? y : x;
}

static inline int32_t smax32(int32_t x, int32_t y) {
  return x < y ? y : x;
}

static inline int64_t smax64(int64_t x, int64_t y) {
  return x < y ? y : x;
}

static inline uint8_t umax8(uint8_t x, uint8_t y) {
  return x < y ? y : x;
}

static inline uint16_t umax16(uint16_t x, uint16_t y) {
  return x < y ? y : x;
}

static inline uint32_t umax32(uint32_t x, uint32_t y) {
  return x < y ? y : x;
}

static inline uint64_t umax64(uint64_t x, uint64_t y) {
  return x < y ? y : x;
}

static inline uint8_t shl8(uint8_t x, uint8_t y) {
  return (uint8_t)(x << y);
}

static inline uint16_t shl16(uint16_t x, uint16_t y) {
  return (uint16_t)(x << y);
}

static inline uint32_t shl32(uint32_t x, uint32_t y) {
  return x << y;
}

static inline uint64_t shl64(uint64_t x, uint64_t y) {
  return x << y;
}

static inline uint8_t lshr8(uint8_t x, uint8_t y) {
  return x >> y;
}

static inline uint16_t lshr16(uint16_t x, uint16_t y) {
  return x >> y;
}

static inline uint32_t lshr32(uint32_t x, uint32_t y) {
  return x >> y;
}

static inline uint64_t lshr64(uint64_t x, uint64_t y) {
  return x >> y;
}

static inline int8_t ashr8(int8_t x, int8_t y) {
  return x >> y;
}

static inline int16_t ashr16(int16_t x, int16_t y) {
  return x >> y;
}

static inline int32_t ashr32(int32_t x, int32_t y) {
  return x >> y;
}

static inline int64_t ashr64(int64_t x, int64_t y) {
  return x >> y;
}

static inline uint8_t and8(uint8_t x, uint8_t y) {
  return x & y;
}

static inline uint16_t and16(uint16_t x, uint16_t y) {
  return x & y;
}

static inline uint32_t and32(uint32_t x, uint32_t y) {
  return x & y;
}

static inline uint64_t and64(uint64_t x, uint64_t y) {
  return x & y;
}

static inline uint8_t or8(uint8_t x, uint8_t y) {
  return x | y;
}

static inline uint16_t or16(uint16_t x, uint16_t y) {
  return x | y;
}

static inline uint32_t or32(uint32_t x, uint32_t y) {
  return x | y;
}

static inline uint64_t or64(uint64_t x, uint64_t y) {
  return x | y;
}

static inline uint8_t xor8(uint8_t x, uint8_t y) {
  return x ^ y;
}

static inline uint16_t xor16(uint16_t x, uint16_t y) {
  return x ^ y;
}

static inline uint32_t xor32(uint32_t x, uint32_t y) {
  return x ^ y;
}

static inline uint64_t xor64(uint64_t x, uint64_t y) {
  return x ^ y;
}

static inline bool ult8(uint8_t x, uint8_t y) {
  return x < y;
}

static inline bool ult16(uint16_t x, uint16_t y) {
  return x < y;
}

static inline bool ult32(uint32_t x, uint32_t y) {
  return x < y;
}

static inline bool ult64(uint64_t x, uint64_t y) {
  return x < y;
}

static inline bool ule8(uint8_t x, uint8_t y) {
  return x <= y;
}

static inline bool ule16(uint16_t x, uint16_t y) {
  return x <= y;
}

static inline bool ule32(uint32_t x, uint32_t y) {
  return x <= y;
}

static inline bool ule64(uint64_t x, uint64_t y) {
  return x <= y;
}

static inline bool slt8(int8_t x, int8_t y) {
  return x < y;
}

static inline bool slt16(int16_t x, int16_t y) {
  return x < y;
}

static inline bool slt32(int32_t x, int32_t y) {
  return x < y;
}

static inline bool slt64(int64_t x, int64_t y) {
  return x < y;
}

static inline bool sle8(int8_t x, int8_t y) {
  return x <= y;
}

static inline bool sle16(int16_t x, int16_t y) {
  return x <= y;
}

static inline bool sle32(int32_t x, int32_t y) {
  return x <= y;
}

static inline bool sle64(int64_t x, int64_t y) {
  return x <= y;
}

static inline uint8_t pow8(uint8_t x, uint8_t y) {
  uint8_t res = 1, rem = y;

  while (rem != 0) {
    if (rem & 1)
      res *= x;
    rem >>= 1;
    x *= x;
  }
  return res;
}

static inline uint16_t pow16(uint16_t x, uint16_t y) {
  uint16_t res = 1, rem = y;

  while (rem != 0) {
    if (rem & 1)
      res *= x;
    rem >>= 1;
    x *= x;
  }
  return res;
}

static inline uint32_t pow32(uint32_t x, uint32_t y) {
  uint32_t res = 1, rem = y;

  while (rem != 0) {
    if (rem & 1)
      res *= x;
    rem >>= 1;
    x *= x;
  }
  return res;
}

static inline uint64_t pow64(uint64_t x, uint64_t y) {
  uint64_t res = 1, rem = y;

  while (rem != 0) {
    if (rem & 1)
      res *= x;
    rem >>= 1;
    x *= x;
  }
  return res;
}

static inline bool itob_i8_bool(int8_t x) {
  return x;
}

static inline bool itob_i16_bool(int16_t x) {
  return x;
}

static inline bool itob_i32_bool(int32_t x) {
  return x;
}

static inline bool itob_i64_bool(int64_t x) {
  return x;
}

static inline int8_t btoi_bool_i8(bool x) {
  return x;
}

static inline int16_t btoi_bool_i16(bool x) {
  return x;
}

static inline int32_t btoi_bool_i32(bool x) {
  return x;
}

static inline int64_t btoi_bool_i64(bool x) {
  return x;
}

#define sext_i8_i8(x) ((int8_t) (int8_t) (x))
#define sext_i8_i16(x) ((int16_t) (int8_t) (x))
#define sext_i8_i32(x) ((int32_t) (int8_t) (x))
#define sext_i8_i64(x) ((int64_t) (int8_t) (x))
#define sext_i16_i8(x) ((int8_t) (int16_t) (x))
#define sext_i16_i16(x) ((int16_t) (int16_t) (x))
#define sext_i16_i32(x) ((int32_t) (int16_t) (x))
#define sext_i16_i64(x) ((int64_t) (int16_t) (x))
#define sext_i32_i8(x) ((int8_t) (int32_t) (x))
#define sext_i32_i16(x) ((int16_t) (int32_t) (x))
#define sext_i32_i32(x) ((int32_t) (int32_t) (x))
#define sext_i32_i64(x) ((int64_t) (int32_t) (x))
#define sext_i64_i8(x) ((int8_t) (int64_t) (x))
#define sext_i64_i16(x) ((int16_t) (int64_t) (x))
#define sext_i64_i32(x) ((int32_t) (int64_t) (x))
#define sext_i64_i64(x) ((int64_t) (int64_t) (x))
#define zext_i8_i8(x) ((int8_t) (uint8_t) (x))
#define zext_i8_i16(x) ((int16_t) (uint8_t) (x))
#define zext_i8_i32(x) ((int32_t) (uint8_t) (x))
#define zext_i8_i64(x) ((int64_t) (uint8_t) (x))
#define zext_i16_i8(x) ((int8_t) (uint16_t) (x))
#define zext_i16_i16(x) ((int16_t) (uint16_t) (x))
#define zext_i16_i32(x) ((int32_t) (uint16_t) (x))
#define zext_i16_i64(x) ((int64_t) (uint16_t) (x))
#define zext_i32_i8(x) ((int8_t) (uint32_t) (x))
#define zext_i32_i16(x) ((int16_t) (uint32_t) (x))
#define zext_i32_i32(x) ((int32_t) (uint32_t) (x))
#define zext_i32_i64(x) ((int64_t) (uint32_t) (x))
#define zext_i64_i8(x) ((int8_t) (uint64_t) (x))
#define zext_i64_i16(x) ((int16_t) (uint64_t) (x))
#define zext_i64_i32(x) ((int32_t) (uint64_t) (x))
#define zext_i64_i64(x) ((int64_t) (uint64_t) (x))

static int8_t abs8(int8_t x) {
  return (int8_t)abs(x);
}

static int16_t abs16(int16_t x) {
  return (int16_t)abs(x);
}

static int32_t abs32(int32_t x) {
  return abs(x);
}

static int64_t abs64(int64_t x) {
#if defined(__OPENCL_VERSION__)
  return abs(x);
#else
  return llabs(x);
#endif
}

#if defined(__OPENCL_VERSION__)
static int32_t futrts_popc8(int8_t x) {
  return popcount(x);
}

static int32_t futrts_popc16(int16_t x) {
  return popcount(x);
}

static int32_t futrts_popc32(int32_t x) {
  return popcount(x);
}

static int32_t futrts_popc64(int64_t x) {
  return popcount(x);
}
#elif defined(__CUDA_ARCH__)

static int32_t futrts_popc8(int8_t x) {
  return __popc(zext_i8_i32(x));
}

static int32_t futrts_popc16(int16_t x) {
  return __popc(zext_i16_i32(x));
}

static int32_t futrts_popc32(int32_t x) {
  return __popc(x);
}

static int32_t futrts_popc64(int64_t x) {
  return __popcll(x);
}

#else // Not OpenCL or CUDA, but plain C.

static int32_t futrts_popc8(uint8_t x) {
  int c = 0;
  for (; x; ++c) { x &= x - 1; }
  return c;
}

static int32_t futrts_popc16(uint16_t x) {
  int c = 0;
  for (; x; ++c) { x &= x - 1; }
  return c;
}

static int32_t futrts_popc32(uint32_t x) {
  int c = 0;
  for (; x; ++c) { x &= x - 1; }
  return c;
}

static int32_t futrts_popc64(uint64_t x) {
  int c = 0;
  for (; x; ++c) { x &= x - 1; }
  return c;
}
#endif

#if defined(__OPENCL_VERSION__)
static uint8_t futrts_mul_hi8(uint8_t a, uint8_t b) {
  return mul_hi(a, b);
}

static uint16_t futrts_mul_hi16(uint16_t a, uint16_t b) {
  return mul_hi(a, b);
}

static uint32_t futrts_mul_hi32(uint32_t a, uint32_t b) {
  return mul_hi(a, b);
}

static uint64_t futrts_mul_hi64(uint64_t a, uint64_t b) {
  return mul_hi(a, b);
}

#elif defined(__CUDA_ARCH__)

static uint8_t futrts_mul_hi8(uint8_t a, uint8_t b) {
  uint16_t aa = a;
  uint16_t bb = b;

  return aa * bb >> 8;
}

static uint16_t futrts_mul_hi16(uint16_t a, uint16_t b) {
  uint32_t aa = a;
  uint32_t bb = b;

  return aa * bb >> 16;
}

static uint32_t futrts_mul_hi32(uint32_t a, uint32_t b) {
  return mulhi(a, b);
}

static uint64_t futrts_mul_hi64(uint64_t a, uint64_t b) {
  return mul64hi(a, b);
}

#else // Not OpenCL or CUDA, but plain C.

static uint8_t futrts_mul_hi8(uint8_t a, uint8_t b) {
  uint16_t aa = a;
  uint16_t bb = b;

  return aa * bb >> 8;
}

static uint16_t futrts_mul_hi16(uint16_t a, uint16_t b) {
  uint32_t aa = a;
  uint32_t bb = b;

  return aa * bb >> 16;
}

static uint32_t futrts_mul_hi32(uint32_t a, uint32_t b) {
  uint64_t aa = a;
  uint64_t bb = b;

  return aa * bb >> 32;
}

static uint64_t futrts_mul_hi64(uint64_t a, uint64_t b) {
  __uint128_t aa = a;
  __uint128_t bb = b;

  return aa * bb >> 64;
}
#endif

#if defined(__OPENCL_VERSION__)
static uint8_t futrts_mad_hi8(uint8_t a, uint8_t b, uint8_t c) {
  return mad_hi(a, b, c);
}

static uint16_t futrts_mad_hi16(uint16_t a, uint16_t b, uint16_t c) {
  return mad_hi(a, b, c);
}

static uint32_t futrts_mad_hi32(uint32_t a, uint32_t b, uint32_t c) {
  return mad_hi(a, b, c);
}

static uint64_t futrts_mad_hi64(uint64_t a, uint64_t b, uint64_t c) {
  return mad_hi(a, b, c);
}

#else // Not OpenCL

static uint8_t futrts_mad_hi8(uint8_t a, uint8_t b, uint8_t c) {
  return futrts_mul_hi8(a, b) + c;
}

static uint16_t futrts_mad_hi16(uint16_t a, uint16_t b, uint16_t c) {
  return futrts_mul_hi16(a, b) + c;
}

static uint32_t futrts_mad_hi32(uint32_t a, uint32_t b, uint32_t c) {
  return futrts_mul_hi32(a, b) + c;
}

static uint64_t futrts_mad_hi64(uint64_t a, uint64_t b, uint64_t c) {
  return futrts_mul_hi64(a, b) + c;
}
#endif

#if defined(__OPENCL_VERSION__)
static int32_t futrts_clzz8(int8_t x) {
  return clz(x);
}

static int32_t futrts_clzz16(int16_t x) {
  return clz(x);
}

static int32_t futrts_clzz32(int32_t x) {
  return clz(x);
}

static int32_t futrts_clzz64(int64_t x) {
  return clz(x);
}

#elif defined(__CUDA_ARCH__)

static int32_t futrts_clzz8(int8_t x) {
  return __clz(zext_i8_i32(x)) - 24;
}

static int32_t futrts_clzz16(int16_t x) {
  return __clz(zext_i16_i32(x)) - 16;
}

static int32_t futrts_clzz32(int32_t x) {
  return __clz(x);
}

static int32_t futrts_clzz64(int64_t x) {
  return __clzll(x);
}

#else // Not OpenCL or CUDA, but plain C.

static int32_t futrts_clzz8(int8_t x) {
  return x == 0 ? 8 : __builtin_clz((uint32_t)zext_i8_i32(x)) - 24;
}

static int32_t futrts_clzz16(int16_t x) {
  return x == 0 ? 16 : __builtin_clz((uint32_t)zext_i16_i32(x)) - 16;
}

static int32_t futrts_clzz32(int32_t x) {
  return x == 0 ? 32 : __builtin_clz((uint32_t)x);
}

static int32_t futrts_clzz64(int64_t x) {
  return x == 0 ? 64 : __builtin_clzll((uint64_t)x);
}
#endif

#if defined(__OPENCL_VERSION__)
static int32_t futrts_ctzz8(int8_t x) {
  int i = 0;
  for (; i < 8 && (x & 1) == 0; i++, x >>= 1)
    ;
  return i;
}

static int32_t futrts_ctzz16(int16_t x) {
  int i = 0;
  for (; i < 16 && (x & 1) == 0; i++, x >>= 1)
    ;
  return i;
}

static int32_t futrts_ctzz32(int32_t x) {
  int i = 0;
  for (; i < 32 && (x & 1) == 0; i++, x >>= 1)
    ;
  return i;
}

static int32_t futrts_ctzz64(int64_t x) {
  int i = 0;
  for (; i < 64 && (x & 1) == 0; i++, x >>= 1)
    ;
  return i;
}

#elif defined(__CUDA_ARCH__)

static int32_t futrts_ctzz8(int8_t x) {
  int y = __ffs(x);
  return y == 0 ? 8 : y - 1;
}

static int32_t futrts_ctzz16(int16_t x) {
  int y = __ffs(x);
  return y == 0 ? 16 : y - 1;
}

static int32_t futrts_ctzz32(int32_t x) {
  int y = __ffs(x);
  return y == 0 ? 32 : y - 1;
}

static int32_t futrts_ctzz64(int64_t x) {
  int y = __ffsll(x);
  return y == 0 ? 64 : y - 1;
}

#else // Not OpenCL or CUDA, but plain C.

static int32_t futrts_ctzz8(int8_t x) {
  return x == 0 ? 8 : __builtin_ctz((uint32_t)x);
}

static int32_t futrts_ctzz16(int16_t x) {
  return x == 0 ? 16 : __builtin_ctz((uint32_t)x);
}

static int32_t futrts_ctzz32(int32_t x) {
  return x == 0 ? 32 : __builtin_ctz((uint32_t)x);
}

static int32_t futrts_ctzz64(int64_t x) {
  return x == 0 ? 64 : __builtin_ctzll((uint64_t)x);
}
#endif

static inline float fdiv32(float x, float y) {
  return x / y;
}

static inline float fadd32(float x, float y) {
  return x + y;
}

static inline float fsub32(float x, float y) {
  return x - y;
}

static inline float fmul32(float x, float y) {
  return x * y;
}

static inline bool cmplt32(float x, float y) {
  return x < y;
}

static inline bool cmple32(float x, float y) {
  return x <= y;
}

static inline float sitofp_i8_f32(int8_t x) {
  return (float) x;
}

static inline float sitofp_i16_f32(int16_t x) {
  return (float) x;
}

static inline float sitofp_i32_f32(int32_t x) {
  return (float) x;
}

static inline float sitofp_i64_f32(int64_t x) {
  return (float) x;
}

static inline float uitofp_i8_f32(uint8_t x) {
  return (float) x;
}

static inline float uitofp_i16_f32(uint16_t x) {
  return (float) x;
}

static inline float uitofp_i32_f32(uint32_t x) {
  return (float) x;
}

static inline float uitofp_i64_f32(uint64_t x) {
  return (float) x;
}

static inline int8_t fptosi_f32_i8(float x) {
  return (int8_t) x;
}

static inline int16_t fptosi_f32_i16(float x) {
  return (int16_t) x;
}

static inline int32_t fptosi_f32_i32(float x) {
  return (int32_t) x;
}

static inline int64_t fptosi_f32_i64(float x) {
  return (int64_t) x;
}

static inline uint8_t fptoui_f32_i8(float x) {
  return (uint8_t) x;
}

static inline uint16_t fptoui_f32_i16(float x) {
  return (uint16_t) x;
}

static inline uint32_t fptoui_f32_i32(float x) {
  return (uint32_t) x;
}

static inline uint64_t fptoui_f32_i64(float x) {
  return (uint64_t) x;
}

#ifdef __OPENCL_VERSION__
static inline float fabs32(float x) {
  return fabs(x);
}

static inline float fmax32(float x, float y) {
  return fmax(x, y);
}

static inline float fmin32(float x, float y) {
  return fmin(x, y);
}

static inline float fpow32(float x, float y) {
  return pow(x, y);
}

#else // Not OpenCL, but CUDA or plain C.

static inline float fabs32(float x) {
  return fabsf(x);
}

static inline float fmax32(float x, float y) {
  return fmaxf(x, y);
}

static inline float fmin32(float x, float y) {
  return fminf(x, y);
}

static inline float fpow32(float x, float y) {
  return powf(x, y);
}
#endif

static inline bool futrts_isnan32(float x) {
  return isnan(x);
}

static inline bool futrts_isinf32(float x) {
  return isinf(x);
}

#ifdef __OPENCL_VERSION__
static inline float futrts_log32(float x) {
  return log(x);
}

static inline float futrts_log2_32(float x) {
  return log2(x);
}

static inline float futrts_log10_32(float x) {
  return log10(x);
}

static inline float futrts_sqrt32(float x) {
  return sqrt(x);
}

static inline float futrts_exp32(float x) {
  return exp(x);
}

static inline float futrts_cos32(float x) {
  return cos(x);
}

static inline float futrts_sin32(float x) {
  return sin(x);
}

static inline float futrts_tan32(float x) {
  return tan(x);
}

static inline float futrts_acos32(float x) {
  return acos(x);
}

static inline float futrts_asin32(float x) {
  return asin(x);
}

static inline float futrts_atan32(float x) {
  return atan(x);
}

static inline float futrts_cosh32(float x) {
  return cosh(x);
}

static inline float futrts_sinh32(float x) {
  return sinh(x);
}

static inline float futrts_tanh32(float x) {
  return tanh(x);
}

static inline float futrts_acosh32(float x) {
  return acosh(x);
}

static inline float futrts_asinh32(float x) {
  return asinh(x);
}

static inline float futrts_atanh32(float x) {
  return atanh(x);
}

static inline float futrts_atan2_32(float x, float y) {
  return atan2(x, y);
}

static inline float futrts_hypot32(float x, float y) {
  return hypot(x, y);
}

static inline float futrts_gamma32(float x) {
  return tgamma(x);
}

static inline float futrts_lgamma32(float x) {
  return lgamma(x);
}

static inline float fmod32(float x, float y) {
  return fmod(x, y);
}

static inline float futrts_round32(float x) {
  return rint(x);
}

static inline float futrts_floor32(float x) {
  return floor(x);
}

static inline float futrts_ceil32(float x) {
  return ceil(x);
}

static inline float futrts_lerp32(float v0, float v1, float t) {
  return mix(v0, v1, t);
}

static inline float futrts_mad32(float a, float b, float c) {
  return mad(a, b, c);
}

static inline float futrts_fma32(float a, float b, float c) {
  return fma(a, b, c);
}

#else // Not OpenCL, but CUDA or plain C.

static inline float futrts_log32(float x) {
  return logf(x);
}

static inline float futrts_log2_32(float x) {
  return log2f(x);
}

static inline float futrts_log10_32(float x) {
  return log10f(x);
}

static inline float futrts_sqrt32(float x) {
  return sqrtf(x);
}

static inline float futrts_exp32(float x) {
  return expf(x);
}

static inline float futrts_cos32(float x) {
  return cosf(x);
}

static inline float futrts_sin32(float x) {
  return sinf(x);
}

static inline float futrts_tan32(float x) {
  return tanf(x);
}

static inline float futrts_acos32(float x) {
  return acosf(x);
}

static inline float futrts_asin32(float x) {
  return asinf(x);
}

static inline float futrts_atan32(float x) {
  return atanf(x);
}

static inline float futrts_cosh32(float x) {
  return coshf(x);
}

static inline float futrts_sinh32(float x) {
  return sinhf(x);
}

static inline float futrts_tanh32(float x) {
  return tanhf(x);
}

static inline float futrts_acosh32(float x) {
  return acoshf(x);
}

static inline float futrts_asinh32(float x) {
  return asinhf(x);
}

static inline float futrts_atanh32(float x) {
  return atanhf(x);
}

static inline float futrts_atan2_32(float x, float y) {
  return atan2f(x, y);
}

static inline float futrts_hypot32(float x, float y) {
  return hypotf(x, y);
}

static inline float futrts_gamma32(float x) {
  return tgammaf(x);
}

static inline float futrts_lgamma32(float x) {
  return lgammaf(x);
}

static inline float fmod32(float x, float y) {
  return fmodf(x, y);
}

static inline float futrts_round32(float x) {
  return rintf(x);
}

static inline float futrts_floor32(float x) {
  return floorf(x);
}

static inline float futrts_ceil32(float x) {
  return ceilf(x);
}

static inline float futrts_lerp32(float v0, float v1, float t) {
  return v0 + (v1 - v0) * t;
}

static inline float futrts_mad32(float a, float b, float c) {
  return a * b + c;
}

static inline float futrts_fma32(float a, float b, float c) {
  return fmaf(a, b, c);
}
#endif

static inline int32_t futrts_to_bits32(float x) {
  union {
    float f;
    int32_t t;
  } p;

  p.f = x;
  return p.t;
}

static inline float futrts_from_bits32(int32_t x) {
  union {
    int32_t f;
    float t;
  } p;

  p.f = x;
  return p.t;
}

static inline float fsignum32(float x) {
  return futrts_isnan32(x) ? x : (x > 0) - (x < 0);
}

#ifdef FUTHARK_F64_ENABLED

static inline double fdiv64(double x, double y) {
  return x / y;
}

static inline double fadd64(double x, double y) {
  return x + y;
}

static inline double fsub64(double x, double y) {
  return x - y;
}

static inline double fmul64(double x, double y) {
  return x * y;
}

static inline bool cmplt64(double x, double y) {
  return x < y;
}

static inline bool cmple64(double x, double y) {
  return x <= y;
}

static inline double sitofp_i8_f64(int8_t x) {
  return (double) x;
}

static inline double sitofp_i16_f64(int16_t x) {
  return (double) x;
}

static inline double sitofp_i32_f64(int32_t x) {
  return (double) x;
}

static inline double sitofp_i64_f64(int64_t x) {
  return (double) x;
}

static inline double uitofp_i8_f64(uint8_t x) {
  return (double) x;
}

static inline double uitofp_i16_f64(uint16_t x) {
  return (double) x;
}

static inline double uitofp_i32_f64(uint32_t x) {
  return (double) x;
}

static inline double uitofp_i64_f64(uint64_t x) {
  return (double) x;
}

static inline int8_t fptosi_f64_i8(double x) {
  return (int8_t) x;
}

static inline int16_t fptosi_f64_i16(double x) {
  return (int16_t) x;
}

static inline int32_t fptosi_f64_i32(double x) {
  return (int32_t) x;
}

static inline int64_t fptosi_f64_i64(double x) {
  return (int64_t) x;
}

static inline uint8_t fptoui_f64_i8(double x) {
  return (uint8_t) x;
}

static inline uint16_t fptoui_f64_i16(double x) {
  return (uint16_t) x;
}

static inline uint32_t fptoui_f64_i32(double x) {
  return (uint32_t) x;
}

static inline uint64_t fptoui_f64_i64(double x) {
  return (uint64_t) x;
}

static inline double fabs64(double x) {
  return fabs(x);
}

static inline double fmax64(double x, double y) {
  return fmax(x, y);
}

static inline double fmin64(double x, double y) {
  return fmin(x, y);
}

static inline double fpow64(double x, double y) {
  return pow(x, y);
}

static inline double futrts_log64(double x) {
  return log(x);
}

static inline double futrts_log2_64(double x) {
  return log2(x);
}

static inline double futrts_log10_64(double x) {
  return log10(x);
}

static inline double futrts_sqrt64(double x) {
  return sqrt(x);
}

static inline double futrts_exp64(double x) {
  return exp(x);
}

static inline double futrts_cos64(double x) {
  return cos(x);
}

static inline double futrts_sin64(double x) {
  return sin(x);
}

static inline double futrts_tan64(double x) {
  return tan(x);
}

static inline double futrts_acos64(double x) {
  return acos(x);
}

static inline double futrts_asin64(double x) {
  return asin(x);
}

static inline double futrts_atan64(double x) {
  return atan(x);
}

static inline double futrts_cosh64(double x) {
  return cosh(x);
}

static inline double futrts_sinh64(double x) {
  return sinh(x);
}

static inline double futrts_tanh64(double x) {
  return tanh(x);
}

static inline double futrts_acosh64(double x) {
  return acosh(x);
}

static inline double futrts_asinh64(double x) {
  return asinh(x);
}

static inline double futrts_atanh64(double x) {
  return atanh(x);
}

static inline double futrts_atan2_64(double x, double y) {
  return atan2(x, y);
}

static inline double futrts_hypot64(double x, double y) {
  return hypot(x, y);
}

static inline double futrts_gamma64(double x) {
  return tgamma(x);
}

static inline double futrts_lgamma64(double x) {
  return lgamma(x);
}

static inline double futrts_fma64(double a, double b, double c) {
  return fma(a, b, c);
}

static inline double futrts_round64(double x) {
  return rint(x);
}

static inline double futrts_ceil64(double x) {
  return ceil(x);
}

static inline double futrts_floor64(double x) {
  return floor(x);
}

static inline bool futrts_isnan64(double x) {
  return isnan(x);
}

static inline bool futrts_isinf64(double x) {
  return isinf(x);
}

static inline int64_t futrts_to_bits64(double x) {
  union {
    double f;
    int64_t t;
  } p;

  p.f = x;
  return p.t;
}

static inline double futrts_from_bits64(int64_t x) {
  union {
    int64_t f;
    double t;
  } p;

  p.f = x;
  return p.t;
}

static inline double fmod64(double x, double y) {
  return fmod(x, y);
}

static inline double fsignum64(double x) {
  return futrts_isnan64(x) ? x : (x > 0) - (x < 0);
}

static inline double futrts_lerp64(double v0, double v1, double t) {
#ifdef __OPENCL_VERSION__
  return mix(v0, v1, t);
#else
  return v0 + (v1 - v0) * t;
#endif
}

static inline double futrts_mad64(double a, double b, double c) {
#ifdef __OPENCL_VERSION__
  return mad(a, b, c);
#else
  return a * b + c;
#endif
}

static inline float fpconv_f32_f32(float x) {
  return (float) x;
}

static inline double fpconv_f32_f64(float x) {
  return (double) x;
}

static inline float fpconv_f64_f32(double x) {
  return (float) x;
}

static inline double fpconv_f64_f64(double x) {
  return (double) x;
}

#endif

// End of scalar.h.
// Start of scalar_f16.h.

// Half-precision is emulated if needed (e.g. in straight C) with the
// native type used if possible.  The emulation works by typedef'ing
// 'float' to 'f16', and then implementing all operations on single
// precision.  To cut down on duplication, we use the same code for
// those Futhark functions that require just operators or casts.  The
// in-memory representation for arrays will still be 16 bits even
// under emulation, so the compiler will have to be careful when
// generating reads or writes.

#if !defined(cl_khr_fp16) && !(defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 600)
#define EMULATE_F16
#endif

#if !defined(EMULATE_F16) && defined(__OPENCL_VERSION__)
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
#endif

#ifdef EMULATE_F16

// Note that the half-precision storage format is still 16 bits - the
// compiler will have to be real careful!
typedef float f16;

#else

#ifdef __CUDA_ARCH__
#include <cuda_fp16.h>
#endif

typedef half f16;

#endif

// Some of these functions convert to single precision because half
// precision versions are not available.

static inline f16 fadd16(f16 x, f16 y) {
  return x + y;
}

static inline f16 fsub16(f16 x, f16 y) {
  return x - y;
}

static inline f16 fmul16(f16 x, f16 y) {
  return x * y;
}

static inline bool cmplt16(f16 x, f16 y) {
  return x < y;
}

static inline bool cmple16(f16 x, f16 y) {
  return x <= y;
}

static inline f16 sitofp_i8_f16(int8_t x) {
  return (f16) x;
}

static inline f16 sitofp_i16_f16(int16_t x) {
  return (f16) x;
}

static inline f16 sitofp_i32_f16(int32_t x) {
  return (f16) x;
}

static inline f16 sitofp_i64_f16(int64_t x) {
  return (f16) x;
}

static inline f16 uitofp_i8_f16(uint8_t x) {
  return (f16) x;
}

static inline f16 uitofp_i16_f16(uint16_t x) {
  return (f16) x;
}

static inline f16 uitofp_i32_f16(uint32_t x) {
  return (f16) x;
}

static inline f16 uitofp_i64_f16(uint64_t x) {
  return (f16) x;
}

static inline int8_t fptosi_f16_i8(f16 x) {
  return (int8_t) (float) x;
}

static inline int16_t fptosi_f16_i16(f16 x) {
  return (int16_t) x;
}

static inline int32_t fptosi_f16_i32(f16 x) {
  return (int32_t) x;
}

static inline int64_t fptosi_f16_i64(f16 x) {
  return (int64_t) x;
}

static inline uint8_t fptoui_f16_i8(f16 x) {
  return (uint8_t) (float) x;
}

static inline uint16_t fptoui_f16_i16(f16 x) {
  return (uint16_t) x;
}

static inline uint32_t fptoui_f16_i32(f16 x) {
  return (uint32_t) x;
}

static inline uint64_t fptoui_f16_i64(f16 x) {
  return (uint64_t) x;
}

#ifndef EMULATE_F16

#ifdef __OPENCL_VERSION__
static inline f16 fabs16(f16 x) {
  return fabs(x);
}

static inline f16 fmax16(f16 x, f16 y) {
  return fmax(x, y);
}

static inline f16 fmin16(f16 x, f16 y) {
  return fmin(x, y);
}

static inline f16 fpow16(f16 x, f16 y) {
  return pow(x, y);
}

#else // Assuming CUDA.

static inline f16 fabs16(f16 x) {
  return fabsf(x);
}

static inline f16 fmax16(f16 x, f16 y) {
  return fmaxf(x, y);
}

static inline f16 fmin16(f16 x, f16 y) {
  return fminf(x, y);
}

static inline f16 fpow16(f16 x, f16 y) {
  return powf(x, y);
}
#endif

static inline bool futrts_isnan16(f16 x) {
  return isnan((float)x);
}

static inline bool futrts_isinf16(f16 x) {
  return isinf((float)x);
}

#ifdef __OPENCL_VERSION__
static inline f16 futrts_log16(f16 x) {
  return log(x);
}

static inline f16 futrts_log2_16(f16 x) {
  return log2(x);
}

static inline f16 futrts_log10_16(f16 x) {
  return log10(x);
}

static inline f16 futrts_sqrt16(f16 x) {
  return sqrt(x);
}

static inline f16 futrts_exp16(f16 x) {
  return exp(x);
}

static inline f16 futrts_cos16(f16 x) {
  return cos(x);
}

static inline f16 futrts_sin16(f16 x) {
  return sin(x);
}

static inline f16 futrts_tan16(f16 x) {
  return tan(x);
}

static inline f16 futrts_acos16(f16 x) {
  return acos(x);
}

static inline f16 futrts_asin16(f16 x) {
  return asin(x);
}

static inline f16 futrts_atan16(f16 x) {
  return atan(x);
}

static inline f16 futrts_cosh16(f16 x) {
  return cosh(x);
}

static inline f16 futrts_sinh16(f16 x) {
  return sinh(x);
}

static inline f16 futrts_tanh16(f16 x) {
  return tanh(x);
}

static inline f16 futrts_acosh16(f16 x) {
  return acosh(x);
}

static inline f16 futrts_asinh16(f16 x) {
  return asinh(x);
}

static inline f16 futrts_atanh16(f16 x) {
  return atanh(x);
}

static inline f16 futrts_atan2_16(f16 x, f16 y) {
  return atan2(x, y);
}

static inline f16 futrts_hypot16(f16 x, f16 y) {
  return hypot(x, y);
}

static inline f16 futrts_gamma16(f16 x) {
  return tgamma(x);
}

static inline f16 futrts_lgamma16(f16 x) {
  return lgamma(x);
}

static inline f16 fmod16(f16 x, f16 y) {
  return fmod(x, y);
}

static inline f16 futrts_round16(f16 x) {
  return rint(x);
}

static inline f16 futrts_floor16(f16 x) {
  return floor(x);
}

static inline f16 futrts_ceil16(f16 x) {
  return ceil(x);
}

static inline f16 futrts_lerp16(f16 v0, f16 v1, f16 t) {
  return mix(v0, v1, t);
}

static inline f16 futrts_mad16(f16 a, f16 b, f16 c) {
  return mad(a, b, c);
}

static inline f16 futrts_fma16(f16 a, f16 b, f16 c) {
  return fma(a, b, c);
}

#else // Assume CUDA.

static inline f16 futrts_log16(f16 x) {
  return hlog(x);
}

static inline f16 futrts_log2_16(f16 x) {
  return hlog2(x);
}

static inline f16 futrts_log10_16(f16 x) {
  return hlog10(x);
}

static inline f16 futrts_sqrt16(f16 x) {
  return hsqrt(x);
}

static inline f16 futrts_exp16(f16 x) {
  return hexp(x);
}

static inline f16 futrts_cos16(f16 x) {
  return hcos(x);
}

static inline f16 futrts_sin16(f16 x) {
  return hsin(x);
}

static inline f16 futrts_tan16(f16 x) {
  return tanf(x);
}

static inline f16 futrts_acos16(f16 x) {
  return acosf(x);
}

static inline f16 futrts_asin16(f16 x) {
  return asinf(x);
}

static inline f16 futrts_atan16(f16 x) {
  return atanf(x);
}

static inline f16 futrts_cosh16(f16 x) {
  return coshf(x);
}

static inline f16 futrts_sinh16(f16 x) {
  return sinhf(x);
}

static inline f16 futrts_tanh16(f16 x) {
  return tanhf(x);
}

static inline f16 futrts_acosh16(f16 x) {
  return acoshf(x);
}

static inline f16 futrts_asinh16(f16 x) {
  return asinhf(x);
}

static inline f16 futrts_atanh16(f16 x) {
  return atanhf(x);
}

static inline f16 futrts_atan2_16(f16 x, f16 y) {
  return atan2f(x, y);
}

static inline f16 futrts_hypot16(f16 x, f16 y) {
  return hypotf(x, y);
}

static inline f16 futrts_gamma16(f16 x) {
  return tgammaf(x);
}

static inline f16 futrts_lgamma16(f16 x) {
  return lgammaf(x);
}

static inline f16 fmod16(f16 x, f16 y) {
  return fmodf(x, y);
}

static inline f16 futrts_round16(f16 x) {
  return rintf(x);
}

static inline f16 futrts_floor16(f16 x) {
  return hfloor(x);
}

static inline f16 futrts_ceil16(f16 x) {
  return hceil(x);
}

static inline f16 futrts_lerp16(f16 v0, f16 v1, f16 t) {
  return v0 + (v1 - v0) * t;
}

static inline f16 futrts_mad16(f16 a, f16 b, f16 c) {
  return a * b + c;
}

static inline f16 futrts_fma16(f16 a, f16 b, f16 c) {
  return fmaf(a, b, c);
}

#endif

// The CUDA __half type cannot be put in unions for some reason, so we
// use bespoke conversion functions instead.
#ifdef __CUDA_ARCH__
static inline int16_t futrts_to_bits16(f16 x) {
  return __half_as_ushort(x);
}
static inline f16 futrts_from_bits16(int16_t x) {
  return __ushort_as_half(x);
}
#else
static inline int16_t futrts_to_bits16(f16 x) {
  union {
    f16 f;
    int16_t t;
  } p;

  p.f = x;
  return p.t;
}

static inline f16 futrts_from_bits16(int16_t x) {
  union {
    int16_t f;
    f16 t;
  } p;

  p.f = x;
  return p.t;
}
#endif

#else // No native f16 - emulate.

static inline f16 fabs16(f16 x) {
  return fabs32(x);
}

static inline f16 fmax16(f16 x, f16 y) {
  return fmax32(x, y);
}

static inline f16 fmin16(f16 x, f16 y) {
  return fmin32(x, y);
}

static inline f16 fpow16(f16 x, f16 y) {
  return fpow32(x, y);
}

static inline bool futrts_isnan16(f16 x) {
  return futrts_isnan32(x);
}

static inline bool futrts_isinf16(f16 x) {
  return futrts_isinf32(x);
}

static inline f16 futrts_log16(f16 x) {
  return futrts_log32(x);
}

static inline f16 futrts_log2_16(f16 x) {
  return futrts_log2_32(x);
}

static inline f16 futrts_log10_16(f16 x) {
  return futrts_log10_32(x);
}

static inline f16 futrts_sqrt16(f16 x) {
  return futrts_sqrt32(x);
}

static inline f16 futrts_exp16(f16 x) {
  return futrts_exp32(x);
}

static inline f16 futrts_cos16(f16 x) {
  return futrts_cos32(x);
}

static inline f16 futrts_sin16(f16 x) {
  return futrts_sin32(x);
}

static inline f16 futrts_tan16(f16 x) {
  return futrts_tan32(x);
}

static inline f16 futrts_acos16(f16 x) {
  return futrts_acos32(x);
}

static inline f16 futrts_asin16(f16 x) {
  return futrts_asin32(x);
}

static inline f16 futrts_atan16(f16 x) {
  return futrts_atan32(x);
}

static inline f16 futrts_cosh16(f16 x) {
  return futrts_cosh32(x);
}

static inline f16 futrts_sinh16(f16 x) {
  return futrts_sinh32(x);
}

static inline f16 futrts_tanh16(f16 x) {
  return futrts_tanh32(x);
}

static inline f16 futrts_acosh16(f16 x) {
  return futrts_acosh32(x);
}

static inline f16 futrts_asinh16(f16 x) {
  return futrts_asinh32(x);
}

static inline f16 futrts_atanh16(f16 x) {
  return futrts_atanh32(x);
}

static inline f16 futrts_atan2_16(f16 x, f16 y) {
  return futrts_atan2_32(x, y);
}

static inline f16 futrts_hypot16(f16 x, f16 y) {
  return futrts_hypot32(x, y);
}

static inline f16 futrts_gamma16(f16 x) {
  return futrts_gamma32(x);
}

static inline f16 futrts_lgamma16(f16 x) {
  return futrts_lgamma32(x);
}

static inline f16 fmod16(f16 x, f16 y) {
  return fmod32(x, y);
}

static inline f16 futrts_round16(f16 x) {
  return futrts_round32(x);
}

static inline f16 futrts_floor16(f16 x) {
  return futrts_floor32(x);
}

static inline f16 futrts_ceil16(f16 x) {
  return futrts_ceil32(x);
}

static inline f16 futrts_lerp16(f16 v0, f16 v1, f16 t) {
  return futrts_lerp32(v0, v1, t);
}

static inline f16 futrts_mad16(f16 a, f16 b, f16 c) {
  return futrts_mad32(a, b, c);
}

static inline f16 futrts_fma16(f16 a, f16 b, f16 c) {
  return futrts_fma32(a, b, c);
}

// Even when we are using an OpenCL that does not support cl_khr_fp16,
// it must still support vload_half for actually creating a
// half-precision number, which can then be efficiently converted to a
// float.  Similarly for vstore_half.
#ifdef __OPENCL_VERSION__

static inline int16_t futrts_to_bits16(f16 x) {
  int16_t y;
  // Violating strict aliasing here.
  vstore_half((float)x, 0, (half*)&y);
  return y;
}

static inline f16 futrts_from_bits16(int16_t x) {
  return (f16)vload_half(0, (half*)&x);
}

#else

static inline int16_t futrts_to_bits16(f16 x) {
  return (int16_t)float2halfbits(x);
}

static inline f16 futrts_from_bits16(int16_t x) {
  return halfbits2float((uint16_t)x);
}

static inline f16 fsignum16(f16 x) {
  return futrts_isnan16(x) ? x : (x > 0) - (x < 0);
}

#endif

#endif

static inline float fpconv_f16_f16(f16 x) {
  return x;
}

static inline float fpconv_f16_f32(f16 x) {
  return x;
}

static inline f16 fpconv_f32_f16(float x) {
  return x;
}

#ifdef FUTHARK_F64_ENABLED

static inline double fpconv_f16_f64(f16 x) {
  return (double) x;
}

static inline f16 fpconv_f64_f16(double x) {
  return (f16) x;
}

#endif


// End of scalar_f16.h.

static int init_constants(struct futhark_context *);
static int free_constants(struct futhark_context *);
struct memblock {
    int *references;
    unsigned char *mem;
    int64_t size;
    const char *desc;
};
// start of scheduler.h

// First, the API that the generated code will access.  In principle,
// we could then compile the scheduler separately and link an object
// file with the generated code.  In practice, we will embed all of
// this in the generated code.

// Scheduler handle.
struct scheduler;

// Initialise a scheduler (and start worker threads).
static int scheduler_init(struct scheduler *scheduler,
                          int num_workers,
                          double kappa);

// Shut down a scheduler (and destroy worker threads).
static int scheduler_destroy(struct scheduler *scheduler);

// Figure out the smallest amount of work that amortises task
// creation.
static int determine_kappa(double *kappa);

// How a segop should be scheduled.
enum scheduling {
  DYNAMIC,
  STATIC
};

// How a given task should be executed.  Filled out by the scheduler
// and passed to the segop function
struct scheduler_info {
  int64_t iter_pr_subtask;
  int64_t remainder;
  int nsubtasks;
  enum scheduling sched;
  int wake_up_threads;

  int64_t *task_time;
  int64_t *task_iter;
};

// A segop function.  This is what you hand the scheduler for
// execution.
typedef int (*segop_fn)(void* args,
                        int64_t iterations,
                        int tid,
                        struct scheduler_info info);

// A task for the scheduler to execute.
struct scheduler_segop {
  void *args;
  segop_fn top_level_fn;
  segop_fn nested_fn;
  int64_t iterations;
  enum scheduling sched;

  // Pointers to timer and iter associated with the task
  int64_t *task_time;
  int64_t *task_iter;

  // For debugging
  const char* name;
};

static inline int scheduler_prepare_task(struct scheduler *scheduler,
                                         struct scheduler_segop *task);

typedef int (*parloop_fn)(void* args,
                          int64_t start,
                          int64_t end,
                          int subtask_id,
                          int tid);

// A parallel parloop task.
struct scheduler_parloop {
  void* args;
  parloop_fn fn;
  int64_t iterations;
  struct scheduler_info info;

  // For debugging
  const char* name;
};

static inline int scheduler_execute_task(struct scheduler *scheduler,
                                         struct scheduler_parloop *task);

// Then the API implementation.

#include <signal.h>

#if defined(_WIN32)
#include <windows.h>
#elif defined(__APPLE__)
#include <sys/sysctl.h>
// For getting cpu usage of threads
#include <mach/mach.h>
#include <sys/resource.h>
#elif defined(__linux__)
#include <sys/sysinfo.h>
#include <sys/resource.h>
#include <signal.h>
#elif defined(__EMSCRIPTEN__)
#include <emscripten/threading.h>
#include <sys/sysinfo.h>
#include <sys/resource.h>
#include <signal.h>
#endif

/* Multicore Utility functions */

/* A wrapper for getting rusage on Linux and MacOS */
/* TODO maybe figure out this for windows */
static inline int getrusage_thread(struct rusage *rusage)
{
  int err = -1;
#if  defined(__APPLE__)
    thread_basic_info_data_t info = { 0 };
    mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
    kern_return_t kern_err;

    kern_err = thread_info(mach_thread_self(),
                           THREAD_BASIC_INFO,
                           (thread_info_t)&info,
                           &info_count);
    if (kern_err == KERN_SUCCESS) {
        memset(rusage, 0, sizeof(struct rusage));
        rusage->ru_utime.tv_sec = info.user_time.seconds;
        rusage->ru_utime.tv_usec = info.user_time.microseconds;
        rusage->ru_stime.tv_sec = info.system_time.seconds;
        rusage->ru_stime.tv_usec = info.system_time.microseconds;
        err = 0;
    } else {
        errno = EINVAL;
    }
#elif defined(__linux__) || __EMSCRIPTEN__
    err = getrusage(RUSAGE_THREAD, rusage);
#endif
    return err;
}

/* returns the number of logical cores */
static int num_processors()
{
#if  defined(_WIN32)
/* https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info */
    SYSTEM_INFO sysinfo;
    GetSystemInfo(&sysinfo);
    int ncores = sysinfo.dwNumberOfProcessors;
    fprintf(stderr, "Found %d cores on your Windows machine\n Is that correct?\n", ncores);
    return ncores;
#elif defined(__APPLE__)
    int ncores;
    size_t ncores_size = sizeof(ncores);
    CHECK_ERRNO(sysctlbyname("hw.logicalcpu", &ncores, &ncores_size, NULL, 0),
                "sysctlbyname (hw.logicalcpu)");
    return ncores;
#elif defined(__linux__)
  return get_nprocs();
#elif __EMSCRIPTEN__
  return emscripten_num_logical_cores();
#else
  fprintf(stderr, "operating system not recognised\n");
  return -1;
#endif
}

static unsigned int g_seed;

// Used to seed the generator.
static inline void fast_srand(unsigned int seed) {
    g_seed = seed;
}

// Compute a pseudorandom integer.
// Output value in range [0, 32767]
static inline unsigned int fast_rand(void) {
    g_seed = (214013*g_seed+2531011);
    return (g_seed>>16)&0x7FFF;
}

struct subtask_queue {
  int capacity;             // Size of the buffer.
  int first;                // Index of the start of the ring buffer.
  int num_used;             // Number of used elements in the buffer.
  struct subtask **buffer;

  pthread_mutex_t mutex;    // Mutex used for synchronisation.
  pthread_cond_t cond;      // Condition variable used for synchronisation.
  int dead;

#if defined(MCPROFILE)
  /* Profiling fields */
  uint64_t time_enqueue;
  uint64_t time_dequeue;
  uint64_t n_dequeues;
  uint64_t n_enqueues;
#endif
};

/* A subtask that can be executed by a worker */
struct subtask {
  /* The parloop function */
  parloop_fn fn;
  /* Execution parameters */
  void* args;
  int64_t start, end;
  int id;

  /* Dynamic scheduling parameters */
  int chunkable;
  int64_t chunk_size;

  /* Shared variables across subtasks */
  volatile int *counter; // Counter for ongoing subtasks
  // Shared task timers and iterators
  int64_t *task_time;
  int64_t *task_iter;

  /* For debugging */
  const char *name;
};


struct worker {
  pthread_t thread;
  struct scheduler *scheduler;  /* Reference to the scheduler struct the worker belongs to*/
  struct subtask_queue q;
  int dead;
  int tid;                      /* Just a thread id */

  /* "thread local" time fields used for online algorithm */
  uint64_t timer;
  uint64_t total;
  int nested; /* How nested the current computation is */

  // Profiling fields
  int output_usage;            /* Whether to dump thread usage */
  uint64_t time_spent_working; /* Time spent in parloop functions */
};

static inline void output_worker_usage(struct worker *worker)
{
  struct rusage usage;
  CHECK_ERRNO(getrusage_thread(&usage), "getrusage_thread");
  struct timeval user_cpu_time = usage.ru_utime;
  struct timeval sys_cpu_time = usage.ru_stime;
  fprintf(stderr, "tid: %2d - work time %10llu us - user time: %10llu us - sys: %10llu us\n",
          worker->tid,
          (long long unsigned)worker->time_spent_working / 1000,
          (long long unsigned)(user_cpu_time.tv_sec * 1000000 + user_cpu_time.tv_usec),
          (long long unsigned)(sys_cpu_time.tv_sec * 1000000 + sys_cpu_time.tv_usec));
}

/* Doubles the size of the queue */
static inline int subtask_queue_grow_queue(struct subtask_queue *subtask_queue) {

  int new_capacity = 2 * subtask_queue->capacity;
#ifdef MCDEBUG
  fprintf(stderr, "Growing queue to %d\n", subtask_queue->capacity * 2);
#endif

  struct subtask **new_buffer = calloc(new_capacity, sizeof(struct subtask*));
  for (int i = 0; i < subtask_queue->num_used; i++) {
    new_buffer[i] = subtask_queue->buffer[(subtask_queue->first + i) % subtask_queue->capacity];
  }

  free(subtask_queue->buffer);
  subtask_queue->buffer = new_buffer;
  subtask_queue->capacity = new_capacity;
  subtask_queue->first = 0;

  return 0;
}

// Initialise a job queue with the given capacity.  The queue starts out
// empty.  Returns non-zero on error.
static inline int subtask_queue_init(struct subtask_queue *subtask_queue, int capacity)
{
  assert(subtask_queue != NULL);
  memset(subtask_queue, 0, sizeof(struct subtask_queue));

  subtask_queue->capacity = capacity;
  subtask_queue->buffer = calloc(capacity, sizeof(struct subtask*));
  if (subtask_queue->buffer == NULL) {
    return -1;
  }

  CHECK_ERRNO(pthread_mutex_init(&subtask_queue->mutex, NULL), "pthread_mutex_init");
  CHECK_ERRNO(pthread_cond_init(&subtask_queue->cond, NULL), "pthread_cond_init");

  return 0;
}

// Destroy the job queue.  Blocks until the queue is empty before it
// is destroyed.
static inline int subtask_queue_destroy(struct subtask_queue *subtask_queue)
{
  assert(subtask_queue != NULL);

  CHECK_ERR(pthread_mutex_lock(&subtask_queue->mutex), "pthread_mutex_lock");

  while (subtask_queue->num_used != 0) {
    CHECK_ERR(pthread_cond_wait(&subtask_queue->cond, &subtask_queue->mutex), "pthread_cond_wait");
  }

  // Queue is now empty.  Let's kill it!
  subtask_queue->dead = 1;
  free(subtask_queue->buffer);
  CHECK_ERR(pthread_cond_broadcast(&subtask_queue->cond), "pthread_cond_broadcast");
  CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");

  return 0;
}

static inline void dump_queue(struct worker *worker)
{
  struct subtask_queue *subtask_queue = &worker->q;
  CHECK_ERR(pthread_mutex_lock(&subtask_queue->mutex), "pthread_mutex_lock");
  for (int i = 0; i < subtask_queue->num_used; i++) {
    struct subtask * subtask = subtask_queue->buffer[(subtask_queue->first + i) % subtask_queue->capacity];
    printf("queue tid %d with %d task %s\n", worker->tid, i, subtask->name);
  }
  CHECK_ERR(pthread_cond_broadcast(&subtask_queue->cond), "pthread_cond_broadcast");
  CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");
}

// Push an element onto the end of the job queue.  Blocks if the
// subtask_queue is full (its size is equal to its capacity).  Returns
// non-zero on error.  It is an error to push a job onto a queue that
// has been destroyed.
static inline int subtask_queue_enqueue(struct worker *worker, struct subtask *subtask )
{
  assert(worker != NULL);
  struct subtask_queue *subtask_queue = &worker->q;

#ifdef MCPROFILE
  uint64_t start = get_wall_time();
#endif

  CHECK_ERR(pthread_mutex_lock(&subtask_queue->mutex), "pthread_mutex_lock");
  // Wait until there is room in the subtask_queue.
  while (subtask_queue->num_used == subtask_queue->capacity && !subtask_queue->dead) {
    if (subtask_queue->num_used == subtask_queue->capacity) {
      CHECK_ERR(subtask_queue_grow_queue(subtask_queue), "subtask_queue_grow_queue");
      continue;
    }
    CHECK_ERR(pthread_cond_wait(&subtask_queue->cond, &subtask_queue->mutex), "pthread_cond_wait");
  }

  if (subtask_queue->dead) {
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");
    return -1;
  }

  // If we made it past the loop, there is room in the subtask_queue.
  subtask_queue->buffer[(subtask_queue->first + subtask_queue->num_used) % subtask_queue->capacity] = subtask;
  subtask_queue->num_used++;

#ifdef MCPROFILE
  uint64_t end = get_wall_time();
  subtask_queue->time_enqueue += (end - start);
  subtask_queue->n_enqueues++;
#endif
  // Broadcast a reader (if any) that there is now an element.
  CHECK_ERR(pthread_cond_broadcast(&subtask_queue->cond), "pthread_cond_broadcast");
  CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");

  return 0;
}


/* Like subtask_queue_dequeue, but with two differences:
   1) the subtask is stolen from the __front__ of the queue
   2) returns immediately if there is no subtasks queued,
      as we dont' want to block on another workers queue and
*/
static inline int subtask_queue_steal(struct worker *worker,
                                      struct subtask **subtask)
{
  struct subtask_queue *subtask_queue = &worker->q;
  assert(subtask_queue != NULL);

#ifdef MCPROFILE
  uint64_t start = get_wall_time();
#endif
  CHECK_ERR(pthread_mutex_lock(&subtask_queue->mutex), "pthread_mutex_lock");

  if (subtask_queue->num_used == 0) {
    CHECK_ERR(pthread_cond_broadcast(&subtask_queue->cond), "pthread_cond_broadcast");
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");
    return 1;
  }

  if (subtask_queue->dead) {
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");
    return -1;
  }

  // Tasks gets stolen from the "front"
  struct subtask *cur_back = subtask_queue->buffer[subtask_queue->first];
  struct subtask *new_subtask = NULL;
  int remaining_iter = cur_back->end - cur_back->start;
  // If subtask is chunkable, we steal half of the iterations
  if (cur_back->chunkable && remaining_iter > 1) {
      int64_t half = remaining_iter / 2;
      new_subtask = malloc(sizeof(struct subtask));
      *new_subtask = *cur_back;
      new_subtask->start = cur_back->end - half;
      cur_back->end = new_subtask->start;
      __atomic_fetch_add(cur_back->counter, 1, __ATOMIC_RELAXED);
  } else {
    new_subtask = cur_back;
    subtask_queue->num_used--;
    subtask_queue->first = (subtask_queue->first + 1) % subtask_queue->capacity;
  }
  *subtask = new_subtask;

  if (*subtask == NULL) {
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthred_mutex_unlock");
    return 1;
  }

#ifdef MCPROFILE
  uint64_t end = get_wall_time();
  subtask_queue->time_dequeue += (end - start);
  subtask_queue->n_dequeues++;
#endif

  // Broadcast a writer (if any) that there is now room for more.
  CHECK_ERR(pthread_cond_broadcast(&subtask_queue->cond), "pthread_cond_broadcast");
  CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");

  return 0;
}


// Pop an element from the back of the job queue.
// Optional argument can be provided to block or not
static inline int subtask_queue_dequeue(struct worker *worker,
                                        struct subtask **subtask, int blocking)
{
  assert(worker != NULL);
  struct subtask_queue *subtask_queue = &worker->q;

#ifdef MCPROFILE
  uint64_t start = get_wall_time();
#endif

  CHECK_ERR(pthread_mutex_lock(&subtask_queue->mutex), "pthread_mutex_lock");
  if (subtask_queue->num_used == 0 && !blocking) {
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");
    return 1;
  }
  // Try to steal some work while the subtask_queue is empty
  while (subtask_queue->num_used == 0 && !subtask_queue->dead) {
    pthread_cond_wait(&subtask_queue->cond, &subtask_queue->mutex);
  }

  if (subtask_queue->dead) {
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");
    return -1;
  }

  // dequeue pops from the back
  *subtask = subtask_queue->buffer[(subtask_queue->first + subtask_queue->num_used - 1) % subtask_queue->capacity];
  subtask_queue->num_used--;

  if (*subtask == NULL) {
    assert(!"got NULL ptr");
    CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthred_mutex_unlock");
    return -1;
  }

#ifdef MCPROFILE
  uint64_t end = get_wall_time();
  subtask_queue->time_dequeue += (end - start);
  subtask_queue->n_dequeues++;
#endif

  // Broadcast a writer (if any) that there is now room for more.
  CHECK_ERR(pthread_cond_broadcast(&subtask_queue->cond), "pthread_cond_broadcast");
  CHECK_ERR(pthread_mutex_unlock(&subtask_queue->mutex), "pthread_mutex_unlock");

  return 0;
}

static inline int subtask_queue_is_empty(struct subtask_queue *subtask_queue)
{
  return subtask_queue->num_used == 0;
}

/* Scheduler definitions */

struct scheduler {
  struct worker *workers;
  int num_threads;

  // If there is work to steal => active_work > 0
  volatile int active_work;

  // Only one error can be returned at the time now.  Maybe we can
  // provide a stack like structure for pushing errors onto if we wish
  // to backpropagte multiple errors
  volatile int error;

  // kappa time unit in nanoseconds
  double kappa;
};


// Thread local variable worker struct
// Note that, accesses to tls variables are expensive
// Minimize direct references to this variable
__thread struct worker* worker_local = NULL;

static int64_t total_now(int64_t total, int64_t time) {
  return total + (get_wall_time_ns() - time);
}

static int random_other_worker(struct scheduler *scheduler, int my_id) {
  int my_num_workers = scheduler->num_threads;
  assert(my_num_workers != 1);
  int i = fast_rand() % (my_num_workers - 1);
  if (i >= my_id) {
    i++;
  }
#ifdef MCDEBUG
  assert(i >= 0);
  assert(i < my_num_workers);
  assert(i != my_id);
#endif

  return i;
}


static inline int64_t compute_chunk_size(double kappa, struct subtask* subtask)
{
  double C = (double)*subtask->task_time / (double)*subtask->task_iter;
  if (C == 0.0F) C += DBL_EPSILON;
  return smax64((int64_t)(kappa / C), 1);
}

/* Takes a chunk from subtask and enqueues the remaining iterations onto the worker's queue */
/* A no-op if the subtask is not chunkable */
static inline struct subtask* chunk_subtask(struct worker* worker, struct subtask *subtask)
{
  if (subtask->chunkable) {
    // Do we have information from previous runs avaliable
    if (*subtask->task_iter > 0) {
      subtask->chunk_size = compute_chunk_size(worker->scheduler->kappa, subtask);
      assert(subtask->chunk_size > 0);
    }
    int64_t remaining_iter = subtask->end - subtask->start;
    assert(remaining_iter > 0);
    if (remaining_iter > subtask->chunk_size) {
      struct subtask *new_subtask = malloc(sizeof(struct subtask));
      *new_subtask = *subtask;
      // increment the subtask join counter to account for new subtask
      __atomic_fetch_add(subtask->counter, 1, __ATOMIC_RELAXED);
      // Update range parameters
      subtask->end = subtask->start + subtask->chunk_size;
      new_subtask->start = subtask->end;
      subtask_queue_enqueue(worker, new_subtask);
    }
  }
  return subtask;
}

static inline int run_subtask(struct worker* worker, struct subtask* subtask)
{
  assert(subtask != NULL);
  assert(worker != NULL);

  subtask = chunk_subtask(worker, subtask);
  worker->total = 0;
  worker->timer = get_wall_time_ns();
#if defined(MCPROFILE)
  int64_t start = worker->timer;
#endif
  worker->nested++;
  int err = subtask->fn(subtask->args, subtask->start, subtask->end,
                        subtask->id,
                        worker->tid);
  worker->nested--;
  // Some error occured during some other subtask
  // so we just clean-up and return
  if (worker->scheduler->error != 0) {
    // Even a failed task counts as finished.
    __atomic_fetch_sub(subtask->counter, 1, __ATOMIC_RELAXED);
    free(subtask);
    return 0;
  }
  if (err != 0) {
    __atomic_store_n(&worker->scheduler->error, err, __ATOMIC_RELAXED);
  }
  // Total sequential time spent
  int64_t time_elapsed = total_now(worker->total, worker->timer);
#if defined(MCPROFILE)
  worker->time_spent_working += get_wall_time_ns() - start;
#endif
  int64_t iter = subtask->end - subtask->start;
  // report measurements
  // These updates should really be done using a single atomic CAS operation
  __atomic_fetch_add(subtask->task_time, time_elapsed, __ATOMIC_RELAXED);
  __atomic_fetch_add(subtask->task_iter, iter, __ATOMIC_RELAXED);
  // We need a fence here, since if the counter is decremented before either
  // of the two above are updated bad things can happen, e.g. if they are stack-allocated
  __atomic_thread_fence(__ATOMIC_SEQ_CST);
  __atomic_fetch_sub(subtask->counter, 1, __ATOMIC_RELAXED);
  free(subtask);
  return 0;
}


static inline int is_small(struct scheduler_segop *task, struct scheduler *scheduler, int *nsubtasks)
{
  int64_t time = *task->task_time;
  int64_t iter = *task->task_iter;

  if (task->sched == DYNAMIC || iter == 0) {
    *nsubtasks = scheduler->num_threads;
    return 0;
  }

  // Estimate the constant C
  double C = (double)time / (double)iter;
  double cur_task_iter = (double) task->iterations;

  // Returns true if the task is small i.e.
  // if the number of iterations times C is smaller
  // than the overhead of subtask creation
  if (C == 0.0F || C * cur_task_iter < scheduler->kappa) {
    *nsubtasks = 1;
    return 1;
  }

  // Else compute how many subtasks this tasks should create
  int64_t min_iter_pr_subtask = smax64(scheduler->kappa / C, 1);
  *nsubtasks = smin64(smax64(task->iterations / min_iter_pr_subtask, 1), scheduler->num_threads);

  return 0;
}

// TODO make this prettier
static inline struct subtask* create_subtask(parloop_fn fn,
                                             void* args,
                                             const char* name,
                                             volatile int* counter,
                                             int64_t *timer,
                                             int64_t *iter,
                                             int64_t start, int64_t end,
                                             int chunkable,
                                             int64_t chunk_size,
                                             int id)
{
  struct subtask* subtask = malloc(sizeof(struct subtask));
  if (subtask == NULL) {
    assert(!"malloc failed in create_subtask");
    return NULL;
  }
  subtask->fn         = fn;
  subtask->args       = args;

  subtask->counter    = counter;
  subtask->task_time  = timer;
  subtask->task_iter  = iter;

  subtask->start      = start;
  subtask->end        = end;
  subtask->id         = id;
  subtask->chunkable  = chunkable;
  subtask->chunk_size = chunk_size;

  subtask->name       = name;
  return subtask;
}

static int dummy_counter = 0;
static int64_t dummy_timer = 0;
static int64_t dummy_iter = 0;

static int dummy_fn(void *args, int64_t start, int64_t end, int subtask_id, int tid) {
  (void)args;
  (void)start;
  (void)end;
  (void)subtask_id;
  (void)tid;
  return 0;
}

// Wake up threads, who are blocking by pushing a dummy task
// onto their queue
static inline void wake_up_threads(struct scheduler *scheduler, int start_tid, int end_tid) {

#if defined(MCDEBUG)
  assert(start_tid >= 1);
  assert(end_tid <= scheduler->num_threads);
#endif
  for (int i = start_tid; i < end_tid; i++) {
    struct subtask *subtask = create_subtask(dummy_fn, NULL, "dummy_fn",
                                            &dummy_counter,
                                            &dummy_timer, &dummy_iter,
                                            0, 0,
                                            0, 0,
                                            0);
    CHECK_ERR(subtask_queue_enqueue(&scheduler->workers[i], subtask), "subtask_queue_enqueue");
  }
}

static inline int is_finished(struct worker *worker) {
  return worker->dead && subtask_queue_is_empty(&worker->q);
}

// Try to steal from a random queue
static inline int steal_from_random_worker(struct worker* worker)
{
  int my_id = worker->tid;
  struct scheduler* scheduler = worker->scheduler;
  int k = random_other_worker(scheduler, my_id);
  struct worker *worker_k = &scheduler->workers[k];
  struct subtask* subtask =  NULL;
  int retval = subtask_queue_steal(worker_k, &subtask);
  if (retval == 0) {
    subtask_queue_enqueue(worker, subtask);
    return 1;
  }
  return 0;
}


static inline void *scheduler_worker(void* args)
{
  struct worker *worker = (struct worker*) args;
  struct scheduler *scheduler = worker->scheduler;
  worker_local = worker;
  struct subtask *subtask = NULL;

  while(!is_finished(worker)) {
    if (!subtask_queue_is_empty(&worker->q)) {
      int retval = subtask_queue_dequeue(worker, &subtask, 0);
      if (retval == 0) {
        assert(subtask != NULL);
        CHECK_ERR(run_subtask(worker, subtask), "run_subtask");
      } // else someone stole our work

    } else if (scheduler->active_work) { /* steal */
      while (!is_finished(worker) && scheduler->active_work) {
        if (steal_from_random_worker(worker)) {
          break;
        }
      }
    } else { /* go back to sleep and wait for work */
      int retval = subtask_queue_dequeue(worker, &subtask, 1);
      if (retval == 0) {
        assert(subtask != NULL);
        CHECK_ERR(run_subtask(worker, subtask), "run_subtask");
      }
    }
  }

  assert(subtask_queue_is_empty(&worker->q));
#if defined(MCPROFILE)
  if (worker->output_usage)
    output_worker_usage(worker);
#endif
  return NULL;
}


static inline int scheduler_execute_parloop(struct scheduler *scheduler,
                                            struct scheduler_parloop *task,
                                            int64_t *timer)
{

  struct worker *worker = worker_local;

  struct scheduler_info info = task->info;
  int64_t iter_pr_subtask = info.iter_pr_subtask;
  int64_t remainder = info.remainder;
  int nsubtasks = info.nsubtasks;
  volatile int join_counter = nsubtasks;

  // Shared timer used to sum up all
  // sequential work from each subtask
  int64_t task_timer = 0;
  int64_t task_iter = 0;

  enum scheduling sched = info.sched;
  /* If each subtasks should be processed in chunks */
  int chunkable = sched == STATIC ? 0 : 1;
  int64_t chunk_size = 1; // The initial chunk size when no info is avaliable


  if (info.wake_up_threads || sched == DYNAMIC)
    __atomic_add_fetch(&scheduler->active_work, nsubtasks, __ATOMIC_RELAXED);

  int64_t start = 0;
  int64_t end = iter_pr_subtask + (int64_t)(remainder != 0);
  for (int subtask_id = 0; subtask_id < nsubtasks; subtask_id++) {
    struct subtask *subtask = create_subtask(task->fn, task->args, task->name,
                                              &join_counter,
                                              &task_timer, &task_iter,
                                              start, end,
                                              chunkable, chunk_size,
                                              subtask_id);
    assert(subtask != NULL);
    // In most cases we will never have more subtasks than workers,
    // but there can be exceptions (e.g. the kappa tuning function).
    struct worker *subtask_worker =
      worker->nested
      ? &scheduler->workers[worker->tid]
      : &scheduler->workers[subtask_id % scheduler->num_threads];
    CHECK_ERR(subtask_queue_enqueue(subtask_worker, subtask),
              "subtask_queue_enqueue");
    // Update range params
    start = end;
    end += iter_pr_subtask + ((subtask_id + 1) < remainder);
  }

  if (info.wake_up_threads) {
    wake_up_threads(scheduler, nsubtasks, scheduler->num_threads);
  }

  // Join (wait for subtasks to finish)
  while(join_counter != 0) {
    if (!subtask_queue_is_empty(&worker->q)) {
      struct subtask *subtask = NULL;
      int err = subtask_queue_dequeue(worker, &subtask, 0);
      if (err == 0 ) {
        CHECK_ERR(run_subtask(worker, subtask), "run_subtask");
      }
    } else {
      if (steal_from_random_worker(worker)) {
        struct subtask *subtask = NULL;
        int err = subtask_queue_dequeue(worker, &subtask, 0);
        if (err == 0) {
          CHECK_ERR(run_subtask(worker, subtask), "run_subtask");
        }
      }
    }
  }


  if (info.wake_up_threads || sched == DYNAMIC) {
    __atomic_sub_fetch(&scheduler->active_work, nsubtasks, __ATOMIC_RELAXED);
  }

  // Write back timing results of all sequential work
  (*timer) += task_timer;
  return scheduler->error;
}


static inline int scheduler_execute_task(struct scheduler *scheduler,
                                         struct scheduler_parloop *task)
{

  struct worker *worker = worker_local;

  int err = 0;

  // How much sequential work was performed by the task
  int64_t task_timer = 0;

  /* Execute task sequential or parallel based on decision made earlier */
  if (task->info.nsubtasks == 1) {
    int64_t start = get_wall_time_ns();
    err = task->fn(task->args, 0, task->iterations, 0, worker->tid);
    int64_t end = get_wall_time_ns();
    task_timer = end - start;
    worker->time_spent_working += task_timer;
    // Report time measurements
    // TODO the update of both of these should really be a single atomic!!
    __atomic_fetch_add(task->info.task_time, task_timer, __ATOMIC_RELAXED);
    __atomic_fetch_add(task->info.task_iter, task->iterations, __ATOMIC_RELAXED);
  } else {
    // Add "before" time if we already are inside a task
    int64_t time_before = 0;
    if (worker->nested > 0) {
      time_before = total_now(worker->total, worker->timer);
    }

    err = scheduler_execute_parloop(scheduler, task, &task_timer);

    // Report time measurements
    // TODO the update of both of these should really be a single atomic!!
    __atomic_fetch_add(task->info.task_time, task_timer, __ATOMIC_RELAXED);
    __atomic_fetch_add(task->info.task_iter, task->iterations, __ATOMIC_RELAXED);

    // Update timers to account for new timings
    worker->total = time_before + task_timer;
    worker->timer = get_wall_time_ns();
  }


  return err;
}

/* Decide on how schedule the incoming task i.e. how many subtasks and
   to run sequential or (potentially nested) parallel code body */
static inline int scheduler_prepare_task(struct scheduler* scheduler,
                                         struct scheduler_segop *task)
{
  assert(task != NULL);

  struct worker *worker = worker_local;
  struct scheduler_info info;
  info.task_time = task->task_time;
  info.task_iter = task->task_iter;

  int nsubtasks;
  // Decide if task should be scheduled sequentially
  if (is_small(task, scheduler, &nsubtasks)) {
    info.iter_pr_subtask = task->iterations;
    info.remainder = 0;
    info.nsubtasks = nsubtasks;
    return task->top_level_fn(task->args, task->iterations, worker->tid, info);
  } else {
    info.iter_pr_subtask = task->iterations / nsubtasks;
    info.remainder = task->iterations % nsubtasks;
    info.sched = task->sched;
    switch (task->sched) {
    case STATIC:
      info.nsubtasks = info.iter_pr_subtask == 0 ? info.remainder : ((task->iterations - info.remainder) / info.iter_pr_subtask);
      break;
    case DYNAMIC:
      // As any thread can take any subtasks, we are being safe with using
      // an upper bound on the number of tasks such that the task allocate enough memory
      info.nsubtasks = info.iter_pr_subtask == 0 ? info.remainder : nsubtasks;
      break;
    default:
      assert(!"Got unknown scheduling");
    }
  }

  info.wake_up_threads = 0;
  // We only use the nested parallel segop function if we can't exchaust all cores
  // using the outer most level
  if (task->nested_fn != NULL && info.nsubtasks < scheduler->num_threads && info.nsubtasks == task->iterations) {
    if (worker->nested == 0)
      info.wake_up_threads = 1;
    return task->nested_fn(task->args, task->iterations, worker->tid, info);
  }

  return task->top_level_fn(task->args, task->iterations, worker->tid, info);
}

// Now some code for finding the proper value of kappa on a given
// machine (the smallest amount of work that amortises the cost of
// task creation).

struct tuning_struct {
  int32_t *free_tuning_res;
  int32_t *array;
};

// Reduction function over an integer array
static int tuning_loop(void *args, int64_t start, int64_t end,
                                     int flat_tid, int tid) {
  (void)flat_tid;
  (void)tid;

  int err = 0;
  struct tuning_struct *tuning_struct = (struct tuning_struct *) args;
  int32_t *array = tuning_struct->array;
  int32_t *tuning_res = tuning_struct->free_tuning_res;

  int32_t sum = 0;
  for (int i = start; i < end; i++) {
    int32_t y = array[i];
    sum = add32(sum, y);
  }
  *tuning_res = sum;
  return err;
}

// The main entry point for the tuning process.  Sets the provided
// variable ``kappa``.
static int determine_kappa(double *kappa) {
  int err = 0;

  int64_t iterations = 100000000;
  int64_t tuning_time = 0;
  int64_t tuning_iter = 0;

  int32_t *array = malloc(sizeof(int32_t) * iterations);
  for (int64_t i = 0; i < iterations; i++) {
    array[i] = fast_rand();
  }

  int64_t start_tuning = get_wall_time_ns();
  /* **************************** */
  /* Run sequential reduce first' */
  /* **************************** */
  int64_t tuning_sequentiual_start = get_wall_time_ns();
  struct tuning_struct tuning_struct;
  int32_t tuning_res;
  tuning_struct.free_tuning_res = &tuning_res;
  tuning_struct.array = array;

  err = tuning_loop(&tuning_struct, 0, iterations, 0, 0);
  int64_t tuning_sequentiual_end = get_wall_time_ns();
  int64_t sequential_elapsed = tuning_sequentiual_end - tuning_sequentiual_start;

  double C = (double)sequential_elapsed / (double)iterations;
  fprintf(stderr, " Time for sequential run is %lld - Found C %f\n", (long long)sequential_elapsed, C);

  /* ********************** */
  /* Now run tuning process */
  /* ********************** */
  // Setup a scheduler with a single worker
  struct scheduler scheduler;
  scheduler.num_threads = 1;
  scheduler.workers = malloc(sizeof(struct worker));
  worker_local = &scheduler.workers[0];
  worker_local->tid = 0;
  CHECK_ERR(subtask_queue_init(&scheduler.workers[0].q, 1024),
            "failed to init queue for worker %d\n", 0);

  // Start tuning for kappa
  double kappa_tune = 1000; // Initial kappa is 1 us
  double ratio;
  int64_t time_elapsed;
  while(1) {
    int64_t min_iter_pr_subtask = (int64_t) (kappa_tune / C) == 0 ? 1 : (kappa_tune / C);
    int nsubtasks = iterations / min_iter_pr_subtask;
    struct scheduler_info info;
    info.iter_pr_subtask = min_iter_pr_subtask;

    info.nsubtasks = iterations / min_iter_pr_subtask;
    info.remainder = iterations % min_iter_pr_subtask;
    info.task_time = &tuning_time;
    info.task_iter = &tuning_iter;
    info.sched = STATIC;

    struct scheduler_parloop parloop;
    parloop.name = "tuning_loop";
    parloop.fn = tuning_loop;
    parloop.args = &tuning_struct;
    parloop.iterations = iterations;
    parloop.info = info;

    int64_t tuning_chunked_start = get_wall_time_ns();
    int determine_kappa_err =
      scheduler_execute_task(&scheduler,
                             &parloop);
    assert(determine_kappa_err == 0);
    int64_t tuning_chunked_end = get_wall_time_ns();
    time_elapsed =  tuning_chunked_end - tuning_chunked_start;

    ratio = (double)time_elapsed / (double)sequential_elapsed;
    if (ratio < 1.055) {
      break;
    }
    kappa_tune += 100; // Increase by 100 ns at the time
    fprintf(stderr, "nsubtask %d - kappa %f - ratio %f\n", nsubtasks, kappa_tune, ratio);
  }

  int64_t end_tuning = get_wall_time_ns();
  fprintf(stderr, "tuning took %lld ns and found kappa %f - time %lld - ratio %f\n",
          (long long)end_tuning - start_tuning,
          kappa_tune,
          (long long)time_elapsed,
          ratio);
  *kappa = kappa_tune;

  // Clean-up
  CHECK_ERR(subtask_queue_destroy(&scheduler.workers[0].q), "failed to destroy queue");
  free(array);
  free(scheduler.workers);
  return err;
}

static int scheduler_init(struct scheduler *scheduler,
                          int num_workers,
                          double kappa) {
  assert(num_workers > 0);

  scheduler->kappa = kappa;
  scheduler->num_threads = num_workers;
  scheduler->active_work = 0;
  scheduler->error = 0;

  scheduler->workers = calloc(num_workers, sizeof(struct worker));

  const int queue_capacity = 1024;

  worker_local = &scheduler->workers[0];
  worker_local->tid = 0;
  worker_local->scheduler = scheduler;
  CHECK_ERR(subtask_queue_init(&worker_local->q, queue_capacity),
            "failed to init queue for worker %d\n", 0);

  for (int i = 1; i < num_workers; i++) {
    struct worker *cur_worker = &scheduler->workers[i];
    memset(cur_worker, 0, sizeof(struct worker));
    cur_worker->tid = i;
    cur_worker->output_usage = 0;
    cur_worker->scheduler = scheduler;
    CHECK_ERR(subtask_queue_init(&cur_worker->q, queue_capacity),
              "failed to init queue for worker %d\n", i);

    CHECK_ERR(pthread_create(&cur_worker->thread,
                             NULL,
                             &scheduler_worker,
                             cur_worker),
              "Failed to create worker %d\n", i);
  }

  return 0;
}

static int scheduler_destroy(struct scheduler *scheduler) {
  // We assume that this function is called by the thread controlling
  // the first worker, which is why we treat scheduler->workers[0]
  // specially here.

  // First mark them all as dead.
  for (int i = 1; i < scheduler->num_threads; i++) {
    struct worker *cur_worker = &scheduler->workers[i];
    cur_worker->dead = 1;
  }

  // Then destroy their task queues (this will wake up the threads and
  // make them do their shutdown).
  for (int i = 1; i < scheduler->num_threads; i++) {
    struct worker *cur_worker = &scheduler->workers[i];
    subtask_queue_destroy(&cur_worker->q);
  }

  // Then actually wait for them to stop.
  for (int i = 1; i < scheduler->num_threads; i++) {
    struct worker *cur_worker = &scheduler->workers[i];
    CHECK_ERR(pthread_join(scheduler->workers[i].thread, NULL), "pthread_join");
  }

  // And then destroy our own queue.
  subtask_queue_destroy(&scheduler->workers[0].q);

  free(scheduler->workers);

  return 0;
}

// End of scheduler.h

struct futhark_context_config {
    int in_use;
    int debugging;
    int profiling;
    int num_threads;
};
struct futhark_context_config *futhark_context_config_new(void)
{
    struct futhark_context_config *cfg =
                                  (struct futhark_context_config *) malloc(sizeof(struct futhark_context_config));
    
    if (cfg == NULL)
        return NULL;
    cfg->in_use = 0;
    cfg->debugging = 0;
    cfg->profiling = 0;
    cfg->num_threads = 0;
    return cfg;
}
void futhark_context_config_free(struct futhark_context_config *cfg)
{
    assert(!cfg->in_use);
    free(cfg);
}
void futhark_context_config_set_debugging(struct futhark_context_config *cfg,
                                          int detail)
{
    cfg->debugging = detail;
}
void futhark_context_config_set_profiling(struct futhark_context_config *cfg,
                                          int flag)
{
    cfg->profiling = flag;
}
void futhark_context_config_set_logging(struct futhark_context_config *cfg,
                                        int detail)
{
    // Does nothing for this backend.
    (void) cfg;
    (void) detail;
}
void futhark_context_config_set_num_threads(struct futhark_context_config *cfg,
                                            int n)
{
    cfg->num_threads = n;
}
struct futhark_context {
    struct futhark_context_config *cfg;
    struct scheduler scheduler;
    int detail_memory;
    int debugging;
    int profiling;
    int profiling_paused;
    int logging;
    lock_t lock;
    char *error;
    FILE *log;
    int total_runs;
    long total_runtime;
    int64_t peak_mem_usage_default;
    int64_t cur_mem_usage_default;
    struct {
        int dummy;
    } constants;
    int64_t *futhark_mc_segmap_parloop_77060_total_runtime;
    int *futhark_mc_segmap_parloop_77060_runs;
    int64_t *futhark_mc_segmap_parloop_77060_iter;
    int64_t futhark_mc_segmap_parloop_77060_total_total_runtime;
    int futhark_mc_segmap_parloop_77060_total_runs;
    int64_t futhark_mc_segmap_parloop_77060_total_iter;
    int64_t *futhark_mc_segmap_task_77058_total_runtime;
    int *futhark_mc_segmap_task_77058_runs;
    int64_t *futhark_mc_segmap_task_77058_iter;
    int64_t futhark_mc_segmap_task_77058_total_time;
    int64_t futhark_mc_segmap_task_77058_total_iter;
    int64_t *futhark_mc_scan_stage_1_parloop_77080_total_runtime;
    int *futhark_mc_scan_stage_1_parloop_77080_runs;
    int64_t *futhark_mc_scan_stage_1_parloop_77080_iter;
    int64_t futhark_mc_scan_stage_1_parloop_77080_total_total_runtime;
    int futhark_mc_scan_stage_1_parloop_77080_total_runs;
    int64_t futhark_mc_scan_stage_1_parloop_77080_total_iter;
    int64_t *futhark_mc_scan_stage_3_parloop_77082_total_runtime;
    int *futhark_mc_scan_stage_3_parloop_77082_runs;
    int64_t *futhark_mc_scan_stage_3_parloop_77082_iter;
    int64_t futhark_mc_scan_stage_3_parloop_77082_total_total_runtime;
    int futhark_mc_scan_stage_3_parloop_77082_total_runs;
    int64_t futhark_mc_scan_stage_3_parloop_77082_total_iter;
    int64_t *futhark_mc_segscan_task_77077_total_runtime;
    int *futhark_mc_segscan_task_77077_runs;
    int64_t *futhark_mc_segscan_task_77077_iter;
    int64_t futhark_mc_segscan_task_77077_total_time;
    int64_t futhark_mc_segscan_task_77077_total_iter;
    int64_t *futhark_mc_segmap_parloop_77086_total_runtime;
    int *futhark_mc_segmap_parloop_77086_runs;
    int64_t *futhark_mc_segmap_parloop_77086_iter;
    int64_t futhark_mc_segmap_parloop_77086_total_total_runtime;
    int futhark_mc_segmap_parloop_77086_total_runs;
    int64_t futhark_mc_segmap_parloop_77086_total_iter;
    int64_t *futhark_mc_segmap_task_77084_total_runtime;
    int *futhark_mc_segmap_task_77084_runs;
    int64_t *futhark_mc_segmap_task_77084_iter;
    int64_t futhark_mc_segmap_task_77084_total_time;
    int64_t futhark_mc_segmap_task_77084_total_iter;
    int64_t *futhark_mc_segmap_parloop_77090_total_runtime;
    int *futhark_mc_segmap_parloop_77090_runs;
    int64_t *futhark_mc_segmap_parloop_77090_iter;
    int64_t futhark_mc_segmap_parloop_77090_total_total_runtime;
    int futhark_mc_segmap_parloop_77090_total_runs;
    int64_t futhark_mc_segmap_parloop_77090_total_iter;
    int64_t *futhark_mc_segmap_task_77088_total_runtime;
    int *futhark_mc_segmap_task_77088_runs;
    int64_t *futhark_mc_segmap_task_77088_iter;
    int64_t futhark_mc_segmap_task_77088_total_time;
    int64_t futhark_mc_segmap_task_77088_total_iter;
    int64_t *futhark_mc_segmap_parloop_77094_total_runtime;
    int *futhark_mc_segmap_parloop_77094_runs;
    int64_t *futhark_mc_segmap_parloop_77094_iter;
    int64_t futhark_mc_segmap_parloop_77094_total_total_runtime;
    int futhark_mc_segmap_parloop_77094_total_runs;
    int64_t futhark_mc_segmap_parloop_77094_total_iter;
    int64_t *futhark_mc_segmap_task_77092_total_runtime;
    int *futhark_mc_segmap_task_77092_runs;
    int64_t *futhark_mc_segmap_task_77092_iter;
    int64_t futhark_mc_segmap_task_77092_total_time;
    int64_t futhark_mc_segmap_task_77092_total_iter;
    int64_t *futhark_mc_segmap_parloop_77098_total_runtime;
    int *futhark_mc_segmap_parloop_77098_runs;
    int64_t *futhark_mc_segmap_parloop_77098_iter;
    int64_t futhark_mc_segmap_parloop_77098_total_total_runtime;
    int futhark_mc_segmap_parloop_77098_total_runs;
    int64_t futhark_mc_segmap_parloop_77098_total_iter;
    int64_t *futhark_mc_segmap_task_77096_total_runtime;
    int *futhark_mc_segmap_task_77096_runs;
    int64_t *futhark_mc_segmap_task_77096_iter;
    int64_t futhark_mc_segmap_task_77096_total_time;
    int64_t futhark_mc_segmap_task_77096_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77106_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77106_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77106_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77106_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77106_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77106_total_iter;
    int64_t *futhark_mc_segred_task_77103_total_runtime;
    int *futhark_mc_segred_task_77103_runs;
    int64_t *futhark_mc_segred_task_77103_iter;
    int64_t futhark_mc_segred_task_77103_total_time;
    int64_t futhark_mc_segred_task_77103_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77111_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77111_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77111_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77111_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77111_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77111_total_iter;
    int64_t *futhark_mc_segred_task_77108_total_runtime;
    int *futhark_mc_segred_task_77108_runs;
    int64_t *futhark_mc_segred_task_77108_iter;
    int64_t futhark_mc_segred_task_77108_total_time;
    int64_t futhark_mc_segred_task_77108_total_iter;
    int64_t *futhark_mc_segmap_parloop_77101_total_runtime;
    int *futhark_mc_segmap_parloop_77101_runs;
    int64_t *futhark_mc_segmap_parloop_77101_iter;
    int64_t futhark_mc_segmap_parloop_77101_total_total_runtime;
    int futhark_mc_segmap_parloop_77101_total_runs;
    int64_t futhark_mc_segmap_parloop_77101_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77099_total_runtime;
    int *futhark_mc_segmap_nested_task_77099_runs;
    int64_t *futhark_mc_segmap_nested_task_77099_iter;
    int64_t *futhark_mc_segmap_parloop_77069_total_runtime;
    int *futhark_mc_segmap_parloop_77069_runs;
    int64_t *futhark_mc_segmap_parloop_77069_iter;
    int64_t futhark_mc_segmap_parloop_77069_total_total_runtime;
    int futhark_mc_segmap_parloop_77069_total_runs;
    int64_t futhark_mc_segmap_parloop_77069_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77067_total_runtime;
    int *futhark_mc_segmap_nested_task_77067_runs;
    int64_t *futhark_mc_segmap_nested_task_77067_iter;
    int64_t *futhark_mc_segmap_parloop_77115_total_runtime;
    int *futhark_mc_segmap_parloop_77115_runs;
    int64_t *futhark_mc_segmap_parloop_77115_iter;
    int64_t futhark_mc_segmap_parloop_77115_total_total_runtime;
    int futhark_mc_segmap_parloop_77115_total_runs;
    int64_t futhark_mc_segmap_parloop_77115_total_iter;
    int64_t *futhark_mc_segmap_task_77113_total_runtime;
    int *futhark_mc_segmap_task_77113_runs;
    int64_t *futhark_mc_segmap_task_77113_iter;
    int64_t futhark_mc_segmap_task_77113_total_time;
    int64_t futhark_mc_segmap_task_77113_total_iter;
    int64_t *futhark_mc_scan_stage_1_parloop_77137_total_runtime;
    int *futhark_mc_scan_stage_1_parloop_77137_runs;
    int64_t *futhark_mc_scan_stage_1_parloop_77137_iter;
    int64_t futhark_mc_scan_stage_1_parloop_77137_total_total_runtime;
    int futhark_mc_scan_stage_1_parloop_77137_total_runs;
    int64_t futhark_mc_scan_stage_1_parloop_77137_total_iter;
    int64_t *futhark_mc_scan_stage_3_parloop_77139_total_runtime;
    int *futhark_mc_scan_stage_3_parloop_77139_runs;
    int64_t *futhark_mc_scan_stage_3_parloop_77139_iter;
    int64_t futhark_mc_scan_stage_3_parloop_77139_total_total_runtime;
    int futhark_mc_scan_stage_3_parloop_77139_total_runs;
    int64_t futhark_mc_scan_stage_3_parloop_77139_total_iter;
    int64_t *futhark_mc_segscan_task_77134_total_runtime;
    int *futhark_mc_segscan_task_77134_runs;
    int64_t *futhark_mc_segscan_task_77134_iter;
    int64_t futhark_mc_segscan_task_77134_total_time;
    int64_t futhark_mc_segscan_task_77134_total_iter;
    int64_t *futhark_mc_segmap_parloop_77143_total_runtime;
    int *futhark_mc_segmap_parloop_77143_runs;
    int64_t *futhark_mc_segmap_parloop_77143_iter;
    int64_t futhark_mc_segmap_parloop_77143_total_total_runtime;
    int futhark_mc_segmap_parloop_77143_total_runs;
    int64_t futhark_mc_segmap_parloop_77143_total_iter;
    int64_t *futhark_mc_segmap_task_77141_total_runtime;
    int *futhark_mc_segmap_task_77141_runs;
    int64_t *futhark_mc_segmap_task_77141_iter;
    int64_t futhark_mc_segmap_task_77141_total_time;
    int64_t futhark_mc_segmap_task_77141_total_iter;
    int64_t *futhark_mc_segmap_parloop_77147_total_runtime;
    int *futhark_mc_segmap_parloop_77147_runs;
    int64_t *futhark_mc_segmap_parloop_77147_iter;
    int64_t futhark_mc_segmap_parloop_77147_total_total_runtime;
    int futhark_mc_segmap_parloop_77147_total_runs;
    int64_t futhark_mc_segmap_parloop_77147_total_iter;
    int64_t *futhark_mc_segmap_task_77145_total_runtime;
    int *futhark_mc_segmap_task_77145_runs;
    int64_t *futhark_mc_segmap_task_77145_iter;
    int64_t futhark_mc_segmap_task_77145_total_time;
    int64_t futhark_mc_segmap_task_77145_total_iter;
    int64_t *futhark_mc_segmap_parloop_77151_total_runtime;
    int *futhark_mc_segmap_parloop_77151_runs;
    int64_t *futhark_mc_segmap_parloop_77151_iter;
    int64_t futhark_mc_segmap_parloop_77151_total_total_runtime;
    int futhark_mc_segmap_parloop_77151_total_runs;
    int64_t futhark_mc_segmap_parloop_77151_total_iter;
    int64_t *futhark_mc_segmap_task_77149_total_runtime;
    int *futhark_mc_segmap_task_77149_runs;
    int64_t *futhark_mc_segmap_task_77149_iter;
    int64_t futhark_mc_segmap_task_77149_total_time;
    int64_t futhark_mc_segmap_task_77149_total_iter;
    int64_t *futhark_mc_segmap_parloop_77155_total_runtime;
    int *futhark_mc_segmap_parloop_77155_runs;
    int64_t *futhark_mc_segmap_parloop_77155_iter;
    int64_t futhark_mc_segmap_parloop_77155_total_total_runtime;
    int futhark_mc_segmap_parloop_77155_total_runs;
    int64_t futhark_mc_segmap_parloop_77155_total_iter;
    int64_t *futhark_mc_segmap_task_77153_total_runtime;
    int *futhark_mc_segmap_task_77153_runs;
    int64_t *futhark_mc_segmap_task_77153_iter;
    int64_t futhark_mc_segmap_task_77153_total_time;
    int64_t futhark_mc_segmap_task_77153_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77165_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77165_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77165_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77165_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77165_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77165_total_iter;
    int64_t *futhark_mc_segred_task_77160_total_runtime;
    int *futhark_mc_segred_task_77160_runs;
    int64_t *futhark_mc_segred_task_77160_iter;
    int64_t futhark_mc_segred_task_77160_total_time;
    int64_t futhark_mc_segred_task_77160_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77171_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77171_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77171_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77171_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77171_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77171_total_iter;
    int64_t *futhark_mc_segred_task_77167_total_runtime;
    int *futhark_mc_segred_task_77167_runs;
    int64_t *futhark_mc_segred_task_77167_iter;
    int64_t futhark_mc_segred_task_77167_total_time;
    int64_t futhark_mc_segred_task_77167_total_iter;
    int64_t *futhark_mc_segmap_parloop_77158_total_runtime;
    int *futhark_mc_segmap_parloop_77158_runs;
    int64_t *futhark_mc_segmap_parloop_77158_iter;
    int64_t futhark_mc_segmap_parloop_77158_total_total_runtime;
    int futhark_mc_segmap_parloop_77158_total_runs;
    int64_t futhark_mc_segmap_parloop_77158_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77156_total_runtime;
    int *futhark_mc_segmap_nested_task_77156_runs;
    int64_t *futhark_mc_segmap_nested_task_77156_iter;
    int64_t *futhark_mc_segmap_parloop_77125_total_runtime;
    int *futhark_mc_segmap_parloop_77125_runs;
    int64_t *futhark_mc_segmap_parloop_77125_iter;
    int64_t futhark_mc_segmap_parloop_77125_total_total_runtime;
    int futhark_mc_segmap_parloop_77125_total_runs;
    int64_t futhark_mc_segmap_parloop_77125_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77123_total_runtime;
    int *futhark_mc_segmap_nested_task_77123_runs;
    int64_t *futhark_mc_segmap_nested_task_77123_iter;
    int64_t *futhark_mc_segmap_parloop_77175_total_runtime;
    int *futhark_mc_segmap_parloop_77175_runs;
    int64_t *futhark_mc_segmap_parloop_77175_iter;
    int64_t futhark_mc_segmap_parloop_77175_total_total_runtime;
    int futhark_mc_segmap_parloop_77175_total_runs;
    int64_t futhark_mc_segmap_parloop_77175_total_iter;
    int64_t *futhark_mc_segmap_task_77173_total_runtime;
    int *futhark_mc_segmap_task_77173_runs;
    int64_t *futhark_mc_segmap_task_77173_iter;
    int64_t futhark_mc_segmap_task_77173_total_time;
    int64_t futhark_mc_segmap_task_77173_total_iter;
    int64_t *futhark_mc_scan_stage_1_parloop_77197_total_runtime;
    int *futhark_mc_scan_stage_1_parloop_77197_runs;
    int64_t *futhark_mc_scan_stage_1_parloop_77197_iter;
    int64_t futhark_mc_scan_stage_1_parloop_77197_total_total_runtime;
    int futhark_mc_scan_stage_1_parloop_77197_total_runs;
    int64_t futhark_mc_scan_stage_1_parloop_77197_total_iter;
    int64_t *futhark_mc_scan_stage_3_parloop_77199_total_runtime;
    int *futhark_mc_scan_stage_3_parloop_77199_runs;
    int64_t *futhark_mc_scan_stage_3_parloop_77199_iter;
    int64_t futhark_mc_scan_stage_3_parloop_77199_total_total_runtime;
    int futhark_mc_scan_stage_3_parloop_77199_total_runs;
    int64_t futhark_mc_scan_stage_3_parloop_77199_total_iter;
    int64_t *futhark_mc_segscan_task_77194_total_runtime;
    int *futhark_mc_segscan_task_77194_runs;
    int64_t *futhark_mc_segscan_task_77194_iter;
    int64_t futhark_mc_segscan_task_77194_total_time;
    int64_t futhark_mc_segscan_task_77194_total_iter;
    int64_t *futhark_mc_segmap_parloop_77203_total_runtime;
    int *futhark_mc_segmap_parloop_77203_runs;
    int64_t *futhark_mc_segmap_parloop_77203_iter;
    int64_t futhark_mc_segmap_parloop_77203_total_total_runtime;
    int futhark_mc_segmap_parloop_77203_total_runs;
    int64_t futhark_mc_segmap_parloop_77203_total_iter;
    int64_t *futhark_mc_segmap_task_77201_total_runtime;
    int *futhark_mc_segmap_task_77201_runs;
    int64_t *futhark_mc_segmap_task_77201_iter;
    int64_t futhark_mc_segmap_task_77201_total_time;
    int64_t futhark_mc_segmap_task_77201_total_iter;
    int64_t *futhark_mc_segmap_parloop_77207_total_runtime;
    int *futhark_mc_segmap_parloop_77207_runs;
    int64_t *futhark_mc_segmap_parloop_77207_iter;
    int64_t futhark_mc_segmap_parloop_77207_total_total_runtime;
    int futhark_mc_segmap_parloop_77207_total_runs;
    int64_t futhark_mc_segmap_parloop_77207_total_iter;
    int64_t *futhark_mc_segmap_task_77205_total_runtime;
    int *futhark_mc_segmap_task_77205_runs;
    int64_t *futhark_mc_segmap_task_77205_iter;
    int64_t futhark_mc_segmap_task_77205_total_time;
    int64_t futhark_mc_segmap_task_77205_total_iter;
    int64_t *futhark_mc_segmap_parloop_77211_total_runtime;
    int *futhark_mc_segmap_parloop_77211_runs;
    int64_t *futhark_mc_segmap_parloop_77211_iter;
    int64_t futhark_mc_segmap_parloop_77211_total_total_runtime;
    int futhark_mc_segmap_parloop_77211_total_runs;
    int64_t futhark_mc_segmap_parloop_77211_total_iter;
    int64_t *futhark_mc_segmap_task_77209_total_runtime;
    int *futhark_mc_segmap_task_77209_runs;
    int64_t *futhark_mc_segmap_task_77209_iter;
    int64_t futhark_mc_segmap_task_77209_total_time;
    int64_t futhark_mc_segmap_task_77209_total_iter;
    int64_t *futhark_mc_segmap_parloop_77215_total_runtime;
    int *futhark_mc_segmap_parloop_77215_runs;
    int64_t *futhark_mc_segmap_parloop_77215_iter;
    int64_t futhark_mc_segmap_parloop_77215_total_total_runtime;
    int futhark_mc_segmap_parloop_77215_total_runs;
    int64_t futhark_mc_segmap_parloop_77215_total_iter;
    int64_t *futhark_mc_segmap_task_77213_total_runtime;
    int *futhark_mc_segmap_task_77213_runs;
    int64_t *futhark_mc_segmap_task_77213_iter;
    int64_t futhark_mc_segmap_task_77213_total_time;
    int64_t futhark_mc_segmap_task_77213_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77227_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77227_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77227_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77227_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77227_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77227_total_iter;
    int64_t *futhark_mc_segred_task_77220_total_runtime;
    int *futhark_mc_segred_task_77220_runs;
    int64_t *futhark_mc_segred_task_77220_iter;
    int64_t futhark_mc_segred_task_77220_total_time;
    int64_t futhark_mc_segred_task_77220_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77233_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77233_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77233_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77233_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77233_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77233_total_iter;
    int64_t *futhark_mc_segred_task_77229_total_runtime;
    int *futhark_mc_segred_task_77229_runs;
    int64_t *futhark_mc_segred_task_77229_iter;
    int64_t futhark_mc_segred_task_77229_total_time;
    int64_t futhark_mc_segred_task_77229_total_iter;
    int64_t *futhark_mc_segmap_parloop_77218_total_runtime;
    int *futhark_mc_segmap_parloop_77218_runs;
    int64_t *futhark_mc_segmap_parloop_77218_iter;
    int64_t futhark_mc_segmap_parloop_77218_total_total_runtime;
    int futhark_mc_segmap_parloop_77218_total_runs;
    int64_t futhark_mc_segmap_parloop_77218_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77216_total_runtime;
    int *futhark_mc_segmap_nested_task_77216_runs;
    int64_t *futhark_mc_segmap_nested_task_77216_iter;
    int64_t *futhark_mc_segmap_parloop_77185_total_runtime;
    int *futhark_mc_segmap_parloop_77185_runs;
    int64_t *futhark_mc_segmap_parloop_77185_iter;
    int64_t futhark_mc_segmap_parloop_77185_total_total_runtime;
    int futhark_mc_segmap_parloop_77185_total_runs;
    int64_t futhark_mc_segmap_parloop_77185_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77183_total_runtime;
    int *futhark_mc_segmap_nested_task_77183_runs;
    int64_t *futhark_mc_segmap_nested_task_77183_iter;
    int64_t *futhark_mc_segmap_parloop_77237_total_runtime;
    int *futhark_mc_segmap_parloop_77237_runs;
    int64_t *futhark_mc_segmap_parloop_77237_iter;
    int64_t futhark_mc_segmap_parloop_77237_total_total_runtime;
    int futhark_mc_segmap_parloop_77237_total_runs;
    int64_t futhark_mc_segmap_parloop_77237_total_iter;
    int64_t *futhark_mc_segmap_task_77235_total_runtime;
    int *futhark_mc_segmap_task_77235_runs;
    int64_t *futhark_mc_segmap_task_77235_iter;
    int64_t futhark_mc_segmap_task_77235_total_time;
    int64_t futhark_mc_segmap_task_77235_total_iter;
    int64_t *futhark_mc_scan_stage_1_parloop_77258_total_runtime;
    int *futhark_mc_scan_stage_1_parloop_77258_runs;
    int64_t *futhark_mc_scan_stage_1_parloop_77258_iter;
    int64_t futhark_mc_scan_stage_1_parloop_77258_total_total_runtime;
    int futhark_mc_scan_stage_1_parloop_77258_total_runs;
    int64_t futhark_mc_scan_stage_1_parloop_77258_total_iter;
    int64_t *futhark_mc_scan_stage_3_parloop_77260_total_runtime;
    int *futhark_mc_scan_stage_3_parloop_77260_runs;
    int64_t *futhark_mc_scan_stage_3_parloop_77260_iter;
    int64_t futhark_mc_scan_stage_3_parloop_77260_total_total_runtime;
    int futhark_mc_scan_stage_3_parloop_77260_total_runs;
    int64_t futhark_mc_scan_stage_3_parloop_77260_total_iter;
    int64_t *futhark_mc_segscan_task_77255_total_runtime;
    int *futhark_mc_segscan_task_77255_runs;
    int64_t *futhark_mc_segscan_task_77255_iter;
    int64_t futhark_mc_segscan_task_77255_total_time;
    int64_t futhark_mc_segscan_task_77255_total_iter;
    int64_t *futhark_mc_segmap_parloop_77264_total_runtime;
    int *futhark_mc_segmap_parloop_77264_runs;
    int64_t *futhark_mc_segmap_parloop_77264_iter;
    int64_t futhark_mc_segmap_parloop_77264_total_total_runtime;
    int futhark_mc_segmap_parloop_77264_total_runs;
    int64_t futhark_mc_segmap_parloop_77264_total_iter;
    int64_t *futhark_mc_segmap_task_77262_total_runtime;
    int *futhark_mc_segmap_task_77262_runs;
    int64_t *futhark_mc_segmap_task_77262_iter;
    int64_t futhark_mc_segmap_task_77262_total_time;
    int64_t futhark_mc_segmap_task_77262_total_iter;
    int64_t *futhark_mc_segmap_parloop_77268_total_runtime;
    int *futhark_mc_segmap_parloop_77268_runs;
    int64_t *futhark_mc_segmap_parloop_77268_iter;
    int64_t futhark_mc_segmap_parloop_77268_total_total_runtime;
    int futhark_mc_segmap_parloop_77268_total_runs;
    int64_t futhark_mc_segmap_parloop_77268_total_iter;
    int64_t *futhark_mc_segmap_task_77266_total_runtime;
    int *futhark_mc_segmap_task_77266_runs;
    int64_t *futhark_mc_segmap_task_77266_iter;
    int64_t futhark_mc_segmap_task_77266_total_time;
    int64_t futhark_mc_segmap_task_77266_total_iter;
    int64_t *futhark_mc_segmap_parloop_77272_total_runtime;
    int *futhark_mc_segmap_parloop_77272_runs;
    int64_t *futhark_mc_segmap_parloop_77272_iter;
    int64_t futhark_mc_segmap_parloop_77272_total_total_runtime;
    int futhark_mc_segmap_parloop_77272_total_runs;
    int64_t futhark_mc_segmap_parloop_77272_total_iter;
    int64_t *futhark_mc_segmap_task_77270_total_runtime;
    int *futhark_mc_segmap_task_77270_runs;
    int64_t *futhark_mc_segmap_task_77270_iter;
    int64_t futhark_mc_segmap_task_77270_total_time;
    int64_t futhark_mc_segmap_task_77270_total_iter;
    int64_t *futhark_mc_segmap_parloop_77276_total_runtime;
    int *futhark_mc_segmap_parloop_77276_runs;
    int64_t *futhark_mc_segmap_parloop_77276_iter;
    int64_t futhark_mc_segmap_parloop_77276_total_total_runtime;
    int futhark_mc_segmap_parloop_77276_total_runs;
    int64_t futhark_mc_segmap_parloop_77276_total_iter;
    int64_t *futhark_mc_segmap_task_77274_total_runtime;
    int *futhark_mc_segmap_task_77274_runs;
    int64_t *futhark_mc_segmap_task_77274_iter;
    int64_t futhark_mc_segmap_task_77274_total_time;
    int64_t futhark_mc_segmap_task_77274_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77286_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77286_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77286_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77286_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77286_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77286_total_iter;
    int64_t *futhark_mc_segred_task_77283_total_runtime;
    int *futhark_mc_segred_task_77283_runs;
    int64_t *futhark_mc_segred_task_77283_iter;
    int64_t futhark_mc_segred_task_77283_total_time;
    int64_t futhark_mc_segred_task_77283_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77291_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77291_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77291_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77291_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77291_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77291_total_iter;
    int64_t *futhark_mc_segred_task_77288_total_runtime;
    int *futhark_mc_segred_task_77288_runs;
    int64_t *futhark_mc_segred_task_77288_iter;
    int64_t futhark_mc_segred_task_77288_total_time;
    int64_t futhark_mc_segred_task_77288_total_iter;
    int64_t *futhark_mc_segmap_parloop_77280_total_runtime;
    int *futhark_mc_segmap_parloop_77280_runs;
    int64_t *futhark_mc_segmap_parloop_77280_iter;
    int64_t futhark_mc_segmap_parloop_77280_total_total_runtime;
    int futhark_mc_segmap_parloop_77280_total_runs;
    int64_t futhark_mc_segmap_parloop_77280_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77278_total_runtime;
    int *futhark_mc_segmap_nested_task_77278_runs;
    int64_t *futhark_mc_segmap_nested_task_77278_iter;
    int64_t *futhark_mc_segmap_parloop_77247_total_runtime;
    int *futhark_mc_segmap_parloop_77247_runs;
    int64_t *futhark_mc_segmap_parloop_77247_iter;
    int64_t futhark_mc_segmap_parloop_77247_total_total_runtime;
    int futhark_mc_segmap_parloop_77247_total_runs;
    int64_t futhark_mc_segmap_parloop_77247_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77245_total_runtime;
    int *futhark_mc_segmap_nested_task_77245_runs;
    int64_t *futhark_mc_segmap_nested_task_77245_iter;
    int64_t *futhark_mc_segmap_parloop_77295_total_runtime;
    int *futhark_mc_segmap_parloop_77295_runs;
    int64_t *futhark_mc_segmap_parloop_77295_iter;
    int64_t futhark_mc_segmap_parloop_77295_total_total_runtime;
    int futhark_mc_segmap_parloop_77295_total_runs;
    int64_t futhark_mc_segmap_parloop_77295_total_iter;
    int64_t *futhark_mc_segmap_task_77293_total_runtime;
    int *futhark_mc_segmap_task_77293_runs;
    int64_t *futhark_mc_segmap_task_77293_iter;
    int64_t futhark_mc_segmap_task_77293_total_time;
    int64_t futhark_mc_segmap_task_77293_total_iter;
    int64_t *futhark_mc_scan_stage_1_parloop_77319_total_runtime;
    int *futhark_mc_scan_stage_1_parloop_77319_runs;
    int64_t *futhark_mc_scan_stage_1_parloop_77319_iter;
    int64_t futhark_mc_scan_stage_1_parloop_77319_total_total_runtime;
    int futhark_mc_scan_stage_1_parloop_77319_total_runs;
    int64_t futhark_mc_scan_stage_1_parloop_77319_total_iter;
    int64_t *futhark_mc_scan_stage_3_parloop_77321_total_runtime;
    int *futhark_mc_scan_stage_3_parloop_77321_runs;
    int64_t *futhark_mc_scan_stage_3_parloop_77321_iter;
    int64_t futhark_mc_scan_stage_3_parloop_77321_total_total_runtime;
    int futhark_mc_scan_stage_3_parloop_77321_total_runs;
    int64_t futhark_mc_scan_stage_3_parloop_77321_total_iter;
    int64_t *futhark_mc_segscan_task_77316_total_runtime;
    int *futhark_mc_segscan_task_77316_runs;
    int64_t *futhark_mc_segscan_task_77316_iter;
    int64_t futhark_mc_segscan_task_77316_total_time;
    int64_t futhark_mc_segscan_task_77316_total_iter;
    int64_t *futhark_mc_segmap_parloop_77325_total_runtime;
    int *futhark_mc_segmap_parloop_77325_runs;
    int64_t *futhark_mc_segmap_parloop_77325_iter;
    int64_t futhark_mc_segmap_parloop_77325_total_total_runtime;
    int futhark_mc_segmap_parloop_77325_total_runs;
    int64_t futhark_mc_segmap_parloop_77325_total_iter;
    int64_t *futhark_mc_segmap_task_77323_total_runtime;
    int *futhark_mc_segmap_task_77323_runs;
    int64_t *futhark_mc_segmap_task_77323_iter;
    int64_t futhark_mc_segmap_task_77323_total_time;
    int64_t futhark_mc_segmap_task_77323_total_iter;
    int64_t *futhark_mc_segmap_parloop_77329_total_runtime;
    int *futhark_mc_segmap_parloop_77329_runs;
    int64_t *futhark_mc_segmap_parloop_77329_iter;
    int64_t futhark_mc_segmap_parloop_77329_total_total_runtime;
    int futhark_mc_segmap_parloop_77329_total_runs;
    int64_t futhark_mc_segmap_parloop_77329_total_iter;
    int64_t *futhark_mc_segmap_task_77327_total_runtime;
    int *futhark_mc_segmap_task_77327_runs;
    int64_t *futhark_mc_segmap_task_77327_iter;
    int64_t futhark_mc_segmap_task_77327_total_time;
    int64_t futhark_mc_segmap_task_77327_total_iter;
    int64_t *futhark_mc_segmap_parloop_77333_total_runtime;
    int *futhark_mc_segmap_parloop_77333_runs;
    int64_t *futhark_mc_segmap_parloop_77333_iter;
    int64_t futhark_mc_segmap_parloop_77333_total_total_runtime;
    int futhark_mc_segmap_parloop_77333_total_runs;
    int64_t futhark_mc_segmap_parloop_77333_total_iter;
    int64_t *futhark_mc_segmap_task_77331_total_runtime;
    int *futhark_mc_segmap_task_77331_runs;
    int64_t *futhark_mc_segmap_task_77331_iter;
    int64_t futhark_mc_segmap_task_77331_total_time;
    int64_t futhark_mc_segmap_task_77331_total_iter;
    int64_t *futhark_mc_segmap_parloop_77337_total_runtime;
    int *futhark_mc_segmap_parloop_77337_runs;
    int64_t *futhark_mc_segmap_parloop_77337_iter;
    int64_t futhark_mc_segmap_parloop_77337_total_total_runtime;
    int futhark_mc_segmap_parloop_77337_total_runs;
    int64_t futhark_mc_segmap_parloop_77337_total_iter;
    int64_t *futhark_mc_segmap_task_77335_total_runtime;
    int *futhark_mc_segmap_task_77335_runs;
    int64_t *futhark_mc_segmap_task_77335_iter;
    int64_t futhark_mc_segmap_task_77335_total_time;
    int64_t futhark_mc_segmap_task_77335_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77351_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77351_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77351_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77351_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77351_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77351_total_iter;
    int64_t *futhark_mc_segred_task_77346_total_runtime;
    int *futhark_mc_segred_task_77346_runs;
    int64_t *futhark_mc_segred_task_77346_iter;
    int64_t futhark_mc_segred_task_77346_total_time;
    int64_t futhark_mc_segred_task_77346_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77357_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77357_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77357_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77357_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77357_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77357_total_iter;
    int64_t *futhark_mc_segred_task_77353_total_runtime;
    int *futhark_mc_segred_task_77353_runs;
    int64_t *futhark_mc_segred_task_77353_iter;
    int64_t futhark_mc_segred_task_77353_total_time;
    int64_t futhark_mc_segred_task_77353_total_iter;
    int64_t *futhark_mc_segmap_parloop_77342_total_runtime;
    int *futhark_mc_segmap_parloop_77342_runs;
    int64_t *futhark_mc_segmap_parloop_77342_iter;
    int64_t futhark_mc_segmap_parloop_77342_total_total_runtime;
    int futhark_mc_segmap_parloop_77342_total_runs;
    int64_t futhark_mc_segmap_parloop_77342_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77340_total_runtime;
    int *futhark_mc_segmap_nested_task_77340_runs;
    int64_t *futhark_mc_segmap_nested_task_77340_iter;
    int64_t *futhark_mc_segmap_parloop_77307_total_runtime;
    int *futhark_mc_segmap_parloop_77307_runs;
    int64_t *futhark_mc_segmap_parloop_77307_iter;
    int64_t futhark_mc_segmap_parloop_77307_total_total_runtime;
    int futhark_mc_segmap_parloop_77307_total_runs;
    int64_t futhark_mc_segmap_parloop_77307_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77305_total_runtime;
    int *futhark_mc_segmap_nested_task_77305_runs;
    int64_t *futhark_mc_segmap_nested_task_77305_iter;
    int64_t *futhark_mc_segmap_parloop_77361_total_runtime;
    int *futhark_mc_segmap_parloop_77361_runs;
    int64_t *futhark_mc_segmap_parloop_77361_iter;
    int64_t futhark_mc_segmap_parloop_77361_total_total_runtime;
    int futhark_mc_segmap_parloop_77361_total_runs;
    int64_t futhark_mc_segmap_parloop_77361_total_iter;
    int64_t *futhark_mc_segmap_task_77359_total_runtime;
    int *futhark_mc_segmap_task_77359_runs;
    int64_t *futhark_mc_segmap_task_77359_iter;
    int64_t futhark_mc_segmap_task_77359_total_time;
    int64_t futhark_mc_segmap_task_77359_total_iter;
    int64_t *futhark_mc_scan_stage_1_parloop_77387_total_runtime;
    int *futhark_mc_scan_stage_1_parloop_77387_runs;
    int64_t *futhark_mc_scan_stage_1_parloop_77387_iter;
    int64_t futhark_mc_scan_stage_1_parloop_77387_total_total_runtime;
    int futhark_mc_scan_stage_1_parloop_77387_total_runs;
    int64_t futhark_mc_scan_stage_1_parloop_77387_total_iter;
    int64_t *futhark_mc_scan_stage_3_parloop_77389_total_runtime;
    int *futhark_mc_scan_stage_3_parloop_77389_runs;
    int64_t *futhark_mc_scan_stage_3_parloop_77389_iter;
    int64_t futhark_mc_scan_stage_3_parloop_77389_total_total_runtime;
    int futhark_mc_scan_stage_3_parloop_77389_total_runs;
    int64_t futhark_mc_scan_stage_3_parloop_77389_total_iter;
    int64_t *futhark_mc_segscan_task_77384_total_runtime;
    int *futhark_mc_segscan_task_77384_runs;
    int64_t *futhark_mc_segscan_task_77384_iter;
    int64_t futhark_mc_segscan_task_77384_total_time;
    int64_t futhark_mc_segscan_task_77384_total_iter;
    int64_t *futhark_mc_segmap_parloop_77393_total_runtime;
    int *futhark_mc_segmap_parloop_77393_runs;
    int64_t *futhark_mc_segmap_parloop_77393_iter;
    int64_t futhark_mc_segmap_parloop_77393_total_total_runtime;
    int futhark_mc_segmap_parloop_77393_total_runs;
    int64_t futhark_mc_segmap_parloop_77393_total_iter;
    int64_t *futhark_mc_segmap_task_77391_total_runtime;
    int *futhark_mc_segmap_task_77391_runs;
    int64_t *futhark_mc_segmap_task_77391_iter;
    int64_t futhark_mc_segmap_task_77391_total_time;
    int64_t futhark_mc_segmap_task_77391_total_iter;
    int64_t *futhark_mc_segmap_parloop_77397_total_runtime;
    int *futhark_mc_segmap_parloop_77397_runs;
    int64_t *futhark_mc_segmap_parloop_77397_iter;
    int64_t futhark_mc_segmap_parloop_77397_total_total_runtime;
    int futhark_mc_segmap_parloop_77397_total_runs;
    int64_t futhark_mc_segmap_parloop_77397_total_iter;
    int64_t *futhark_mc_segmap_task_77395_total_runtime;
    int *futhark_mc_segmap_task_77395_runs;
    int64_t *futhark_mc_segmap_task_77395_iter;
    int64_t futhark_mc_segmap_task_77395_total_time;
    int64_t futhark_mc_segmap_task_77395_total_iter;
    int64_t *futhark_mc_segmap_parloop_77401_total_runtime;
    int *futhark_mc_segmap_parloop_77401_runs;
    int64_t *futhark_mc_segmap_parloop_77401_iter;
    int64_t futhark_mc_segmap_parloop_77401_total_total_runtime;
    int futhark_mc_segmap_parloop_77401_total_runs;
    int64_t futhark_mc_segmap_parloop_77401_total_iter;
    int64_t *futhark_mc_segmap_task_77399_total_runtime;
    int *futhark_mc_segmap_task_77399_runs;
    int64_t *futhark_mc_segmap_task_77399_iter;
    int64_t futhark_mc_segmap_task_77399_total_time;
    int64_t futhark_mc_segmap_task_77399_total_iter;
    int64_t *futhark_mc_segmap_parloop_77405_total_runtime;
    int *futhark_mc_segmap_parloop_77405_runs;
    int64_t *futhark_mc_segmap_parloop_77405_iter;
    int64_t futhark_mc_segmap_parloop_77405_total_total_runtime;
    int futhark_mc_segmap_parloop_77405_total_runs;
    int64_t futhark_mc_segmap_parloop_77405_total_iter;
    int64_t *futhark_mc_segmap_task_77403_total_runtime;
    int *futhark_mc_segmap_task_77403_runs;
    int64_t *futhark_mc_segmap_task_77403_iter;
    int64_t futhark_mc_segmap_task_77403_total_time;
    int64_t futhark_mc_segmap_task_77403_total_iter;
    int64_t *futhark_mc_segmap_parloop_77420_total_runtime;
    int *futhark_mc_segmap_parloop_77420_runs;
    int64_t *futhark_mc_segmap_parloop_77420_iter;
    int64_t futhark_mc_segmap_parloop_77420_total_total_runtime;
    int futhark_mc_segmap_parloop_77420_total_runs;
    int64_t futhark_mc_segmap_parloop_77420_total_iter;
    int64_t *futhark_mc_segmap_task_77418_total_runtime;
    int *futhark_mc_segmap_task_77418_runs;
    int64_t *futhark_mc_segmap_task_77418_iter;
    int64_t futhark_mc_segmap_task_77418_total_time;
    int64_t futhark_mc_segmap_task_77418_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77429_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77429_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77429_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77429_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77429_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77429_total_iter;
    int64_t *futhark_mc_segred_task_77422_total_runtime;
    int *futhark_mc_segred_task_77422_runs;
    int64_t *futhark_mc_segred_task_77422_iter;
    int64_t futhark_mc_segred_task_77422_total_time;
    int64_t futhark_mc_segred_task_77422_total_iter;
    int64_t *futhark_mc_segred_stage_1_parloop_77435_total_runtime;
    int *futhark_mc_segred_stage_1_parloop_77435_runs;
    int64_t *futhark_mc_segred_stage_1_parloop_77435_iter;
    int64_t futhark_mc_segred_stage_1_parloop_77435_total_total_runtime;
    int futhark_mc_segred_stage_1_parloop_77435_total_runs;
    int64_t futhark_mc_segred_stage_1_parloop_77435_total_iter;
    int64_t *futhark_mc_segred_task_77431_total_runtime;
    int *futhark_mc_segred_task_77431_runs;
    int64_t *futhark_mc_segred_task_77431_iter;
    int64_t futhark_mc_segred_task_77431_total_time;
    int64_t futhark_mc_segred_task_77431_total_iter;
    int64_t *futhark_mc_segmap_parloop_77412_total_runtime;
    int *futhark_mc_segmap_parloop_77412_runs;
    int64_t *futhark_mc_segmap_parloop_77412_iter;
    int64_t futhark_mc_segmap_parloop_77412_total_total_runtime;
    int futhark_mc_segmap_parloop_77412_total_runs;
    int64_t futhark_mc_segmap_parloop_77412_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77410_total_runtime;
    int *futhark_mc_segmap_nested_task_77410_runs;
    int64_t *futhark_mc_segmap_nested_task_77410_iter;
    int64_t *futhark_mc_segmap_parloop_77375_total_runtime;
    int *futhark_mc_segmap_parloop_77375_runs;
    int64_t *futhark_mc_segmap_parloop_77375_iter;
    int64_t futhark_mc_segmap_parloop_77375_total_total_runtime;
    int futhark_mc_segmap_parloop_77375_total_runs;
    int64_t futhark_mc_segmap_parloop_77375_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77373_total_runtime;
    int *futhark_mc_segmap_nested_task_77373_runs;
    int64_t *futhark_mc_segmap_nested_task_77373_iter;
    int64_t *futhark_mc_segmap_parloop_77439_total_runtime;
    int *futhark_mc_segmap_parloop_77439_runs;
    int64_t *futhark_mc_segmap_parloop_77439_iter;
    int64_t futhark_mc_segmap_parloop_77439_total_total_runtime;
    int futhark_mc_segmap_parloop_77439_total_runs;
    int64_t futhark_mc_segmap_parloop_77439_total_iter;
    int64_t *futhark_mc_segmap_task_77437_total_runtime;
    int *futhark_mc_segmap_task_77437_runs;
    int64_t *futhark_mc_segmap_task_77437_iter;
    int64_t futhark_mc_segmap_task_77437_total_time;
    int64_t futhark_mc_segmap_task_77437_total_iter;
    int64_t *futhark_mc_segmap_parloop_77448_total_runtime;
    int *futhark_mc_segmap_parloop_77448_runs;
    int64_t *futhark_mc_segmap_parloop_77448_iter;
    int64_t futhark_mc_segmap_parloop_77448_total_total_runtime;
    int futhark_mc_segmap_parloop_77448_total_runs;
    int64_t futhark_mc_segmap_parloop_77448_total_iter;
    int64_t *futhark_mc_segmap_task_77446_total_runtime;
    int *futhark_mc_segmap_task_77446_runs;
    int64_t *futhark_mc_segmap_task_77446_iter;
    int64_t futhark_mc_segmap_task_77446_total_time;
    int64_t futhark_mc_segmap_task_77446_total_iter;
    int64_t *futhark_mc_segmap_parloop_77443_total_runtime;
    int *futhark_mc_segmap_parloop_77443_runs;
    int64_t *futhark_mc_segmap_parloop_77443_iter;
    int64_t futhark_mc_segmap_parloop_77443_total_total_runtime;
    int futhark_mc_segmap_parloop_77443_total_runs;
    int64_t futhark_mc_segmap_parloop_77443_total_iter;
    int64_t *futhark_mc_segmap_nested_task_77441_total_runtime;
    int *futhark_mc_segmap_nested_task_77441_runs;
    int64_t *futhark_mc_segmap_nested_task_77441_iter;
    int64_t tuning_timing;
    int64_t tuning_iter;
};
struct futhark_context *futhark_context_new(struct futhark_context_config *cfg)
{
    assert(!cfg->in_use);
    
    struct futhark_context *ctx =
                           (struct futhark_context *) malloc(sizeof(struct futhark_context));
    
    if (ctx == NULL)
        return NULL;
    ctx->cfg = cfg;
    ctx->cfg->in_use = 1;
    // Initialize rand()
    fast_srand(time(0));
    ctx->detail_memory = cfg->debugging;
    ctx->debugging = cfg->debugging;
    ctx->profiling = cfg->profiling;
    ctx->profiling_paused = 0;
    ctx->logging = 0;
    ctx->error = NULL;
    ctx->log = stderr;
    create_lock(&ctx->lock);
    
    int tune_kappa = 0;
    double kappa = 5.1f * 1000;
    
    if (tune_kappa) {
        if (determine_kappa(&kappa) != 0)
            return NULL;
    }
    if (scheduler_init(&ctx->scheduler, cfg->num_threads >
                       0 ? cfg->num_threads : num_processors(), kappa) != 0)
        return NULL;
    ctx->peak_mem_usage_default = 0;
    ctx->cur_mem_usage_default = 0;
    ctx->futhark_mc_segmap_parloop_77060_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77060_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77060_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77060_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77060_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77060_total_iter = 0;
    ctx->futhark_mc_segmap_task_77058_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77058_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77058_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77058_total_time = 0;
    ctx->futhark_mc_segmap_task_77058_total_iter = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77080_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77080_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77080_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77080_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77080_total_iter = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77082_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77082_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77082_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77082_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77082_total_iter = 0;
    ctx->futhark_mc_segscan_task_77077_total_runtime = calloc(sizeof(int64_t),
                                                              ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77077_runs = calloc(sizeof(int),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77077_iter = calloc(sizeof(sizeof(int64_t)),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77077_total_time = 0;
    ctx->futhark_mc_segscan_task_77077_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77086_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77086_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77086_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77086_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77086_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77086_total_iter = 0;
    ctx->futhark_mc_segmap_task_77084_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77084_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77084_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77084_total_time = 0;
    ctx->futhark_mc_segmap_task_77084_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77090_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77090_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77090_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77090_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77090_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77090_total_iter = 0;
    ctx->futhark_mc_segmap_task_77088_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77088_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77088_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77088_total_time = 0;
    ctx->futhark_mc_segmap_task_77088_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77094_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77094_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77094_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77094_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77094_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77094_total_iter = 0;
    ctx->futhark_mc_segmap_task_77092_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77092_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77092_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77092_total_time = 0;
    ctx->futhark_mc_segmap_task_77092_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77098_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77098_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77098_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77098_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77098_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77098_total_iter = 0;
    ctx->futhark_mc_segmap_task_77096_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77096_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77096_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77096_total_time = 0;
    ctx->futhark_mc_segmap_task_77096_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77106_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77106_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77106_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77106_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77106_total_iter = 0;
    ctx->futhark_mc_segred_task_77103_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77103_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77103_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77103_total_time = 0;
    ctx->futhark_mc_segred_task_77103_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77111_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77111_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77111_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77111_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77111_total_iter = 0;
    ctx->futhark_mc_segred_task_77108_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77108_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77108_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77108_total_time = 0;
    ctx->futhark_mc_segred_task_77108_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77101_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77101_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77101_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77101_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77101_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77101_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77099_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77099_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77099_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77069_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77069_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77069_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77069_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77069_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77069_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77067_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77067_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77067_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77115_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77115_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77115_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77115_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77115_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77115_total_iter = 0;
    ctx->futhark_mc_segmap_task_77113_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77113_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77113_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77113_total_time = 0;
    ctx->futhark_mc_segmap_task_77113_total_iter = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77137_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77137_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77137_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77137_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77137_total_iter = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77139_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77139_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77139_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77139_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77139_total_iter = 0;
    ctx->futhark_mc_segscan_task_77134_total_runtime = calloc(sizeof(int64_t),
                                                              ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77134_runs = calloc(sizeof(int),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77134_iter = calloc(sizeof(sizeof(int64_t)),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77134_total_time = 0;
    ctx->futhark_mc_segscan_task_77134_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77143_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77143_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77143_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77143_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77143_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77143_total_iter = 0;
    ctx->futhark_mc_segmap_task_77141_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77141_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77141_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77141_total_time = 0;
    ctx->futhark_mc_segmap_task_77141_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77147_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77147_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77147_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77147_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77147_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77147_total_iter = 0;
    ctx->futhark_mc_segmap_task_77145_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77145_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77145_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77145_total_time = 0;
    ctx->futhark_mc_segmap_task_77145_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77151_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77151_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77151_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77151_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77151_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77151_total_iter = 0;
    ctx->futhark_mc_segmap_task_77149_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77149_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77149_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77149_total_time = 0;
    ctx->futhark_mc_segmap_task_77149_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77155_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77155_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77155_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77155_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77155_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77155_total_iter = 0;
    ctx->futhark_mc_segmap_task_77153_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77153_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77153_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77153_total_time = 0;
    ctx->futhark_mc_segmap_task_77153_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77165_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77165_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77165_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77165_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77165_total_iter = 0;
    ctx->futhark_mc_segred_task_77160_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77160_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77160_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77160_total_time = 0;
    ctx->futhark_mc_segred_task_77160_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77171_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77171_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77171_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77171_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77171_total_iter = 0;
    ctx->futhark_mc_segred_task_77167_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77167_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77167_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77167_total_time = 0;
    ctx->futhark_mc_segred_task_77167_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77158_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77158_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77158_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77158_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77158_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77158_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77156_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77156_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77156_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77125_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77125_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77125_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77125_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77125_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77125_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77123_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77123_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77123_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77175_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77175_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77175_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77175_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77175_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77175_total_iter = 0;
    ctx->futhark_mc_segmap_task_77173_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77173_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77173_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77173_total_time = 0;
    ctx->futhark_mc_segmap_task_77173_total_iter = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77197_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77197_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77197_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77197_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77197_total_iter = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77199_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77199_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77199_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77199_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77199_total_iter = 0;
    ctx->futhark_mc_segscan_task_77194_total_runtime = calloc(sizeof(int64_t),
                                                              ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77194_runs = calloc(sizeof(int),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77194_iter = calloc(sizeof(sizeof(int64_t)),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77194_total_time = 0;
    ctx->futhark_mc_segscan_task_77194_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77203_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77203_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77203_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77203_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77203_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77203_total_iter = 0;
    ctx->futhark_mc_segmap_task_77201_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77201_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77201_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77201_total_time = 0;
    ctx->futhark_mc_segmap_task_77201_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77207_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77207_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77207_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77207_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77207_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77207_total_iter = 0;
    ctx->futhark_mc_segmap_task_77205_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77205_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77205_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77205_total_time = 0;
    ctx->futhark_mc_segmap_task_77205_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77211_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77211_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77211_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77211_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77211_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77211_total_iter = 0;
    ctx->futhark_mc_segmap_task_77209_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77209_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77209_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77209_total_time = 0;
    ctx->futhark_mc_segmap_task_77209_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77215_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77215_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77215_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77215_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77215_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77215_total_iter = 0;
    ctx->futhark_mc_segmap_task_77213_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77213_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77213_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77213_total_time = 0;
    ctx->futhark_mc_segmap_task_77213_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77227_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77227_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77227_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77227_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77227_total_iter = 0;
    ctx->futhark_mc_segred_task_77220_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77220_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77220_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77220_total_time = 0;
    ctx->futhark_mc_segred_task_77220_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77233_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77233_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77233_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77233_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77233_total_iter = 0;
    ctx->futhark_mc_segred_task_77229_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77229_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77229_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77229_total_time = 0;
    ctx->futhark_mc_segred_task_77229_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77218_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77218_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77218_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77218_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77218_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77218_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77216_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77216_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77216_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77185_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77185_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77185_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77185_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77185_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77185_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77183_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77183_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77183_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77237_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77237_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77237_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77237_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77237_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77237_total_iter = 0;
    ctx->futhark_mc_segmap_task_77235_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77235_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77235_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77235_total_time = 0;
    ctx->futhark_mc_segmap_task_77235_total_iter = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77258_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77258_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77258_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77258_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77258_total_iter = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77260_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77260_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77260_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77260_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77260_total_iter = 0;
    ctx->futhark_mc_segscan_task_77255_total_runtime = calloc(sizeof(int64_t),
                                                              ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77255_runs = calloc(sizeof(int),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77255_iter = calloc(sizeof(sizeof(int64_t)),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77255_total_time = 0;
    ctx->futhark_mc_segscan_task_77255_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77264_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77264_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77264_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77264_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77264_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77264_total_iter = 0;
    ctx->futhark_mc_segmap_task_77262_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77262_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77262_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77262_total_time = 0;
    ctx->futhark_mc_segmap_task_77262_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77268_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77268_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77268_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77268_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77268_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77268_total_iter = 0;
    ctx->futhark_mc_segmap_task_77266_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77266_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77266_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77266_total_time = 0;
    ctx->futhark_mc_segmap_task_77266_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77272_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77272_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77272_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77272_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77272_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77272_total_iter = 0;
    ctx->futhark_mc_segmap_task_77270_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77270_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77270_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77270_total_time = 0;
    ctx->futhark_mc_segmap_task_77270_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77276_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77276_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77276_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77276_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77276_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77276_total_iter = 0;
    ctx->futhark_mc_segmap_task_77274_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77274_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77274_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77274_total_time = 0;
    ctx->futhark_mc_segmap_task_77274_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77286_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77286_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77286_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77286_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77286_total_iter = 0;
    ctx->futhark_mc_segred_task_77283_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77283_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77283_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77283_total_time = 0;
    ctx->futhark_mc_segred_task_77283_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77291_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77291_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77291_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77291_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77291_total_iter = 0;
    ctx->futhark_mc_segred_task_77288_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77288_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77288_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77288_total_time = 0;
    ctx->futhark_mc_segred_task_77288_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77280_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77280_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77280_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77280_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77280_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77280_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77278_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77278_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77278_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77247_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77247_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77247_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77247_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77247_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77247_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77245_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77245_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77245_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77295_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77295_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77295_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77295_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77295_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77295_total_iter = 0;
    ctx->futhark_mc_segmap_task_77293_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77293_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77293_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77293_total_time = 0;
    ctx->futhark_mc_segmap_task_77293_total_iter = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77319_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77319_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77319_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77319_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77319_total_iter = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77321_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77321_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77321_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77321_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77321_total_iter = 0;
    ctx->futhark_mc_segscan_task_77316_total_runtime = calloc(sizeof(int64_t),
                                                              ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77316_runs = calloc(sizeof(int),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77316_iter = calloc(sizeof(sizeof(int64_t)),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77316_total_time = 0;
    ctx->futhark_mc_segscan_task_77316_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77325_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77325_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77325_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77325_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77325_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77325_total_iter = 0;
    ctx->futhark_mc_segmap_task_77323_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77323_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77323_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77323_total_time = 0;
    ctx->futhark_mc_segmap_task_77323_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77329_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77329_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77329_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77329_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77329_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77329_total_iter = 0;
    ctx->futhark_mc_segmap_task_77327_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77327_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77327_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77327_total_time = 0;
    ctx->futhark_mc_segmap_task_77327_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77333_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77333_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77333_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77333_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77333_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77333_total_iter = 0;
    ctx->futhark_mc_segmap_task_77331_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77331_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77331_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77331_total_time = 0;
    ctx->futhark_mc_segmap_task_77331_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77337_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77337_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77337_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77337_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77337_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77337_total_iter = 0;
    ctx->futhark_mc_segmap_task_77335_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77335_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77335_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77335_total_time = 0;
    ctx->futhark_mc_segmap_task_77335_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77351_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77351_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77351_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77351_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77351_total_iter = 0;
    ctx->futhark_mc_segred_task_77346_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77346_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77346_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77346_total_time = 0;
    ctx->futhark_mc_segred_task_77346_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77357_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77357_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77357_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77357_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77357_total_iter = 0;
    ctx->futhark_mc_segred_task_77353_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77353_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77353_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77353_total_time = 0;
    ctx->futhark_mc_segred_task_77353_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77342_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77342_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77342_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77342_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77342_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77342_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77340_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77340_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77340_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77307_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77307_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77307_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77307_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77307_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77307_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77305_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77305_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77305_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77361_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77361_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77361_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77361_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77361_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77361_total_iter = 0;
    ctx->futhark_mc_segmap_task_77359_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77359_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77359_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77359_total_time = 0;
    ctx->futhark_mc_segmap_task_77359_total_iter = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77387_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77387_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77387_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_1_parloop_77387_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs = 0;
    ctx->futhark_mc_scan_stage_1_parloop_77387_total_iter = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77389_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77389_runs = calloc(sizeof(int),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77389_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_scan_stage_3_parloop_77389_total_total_runtime = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs = 0;
    ctx->futhark_mc_scan_stage_3_parloop_77389_total_iter = 0;
    ctx->futhark_mc_segscan_task_77384_total_runtime = calloc(sizeof(int64_t),
                                                              ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77384_runs = calloc(sizeof(int),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77384_iter = calloc(sizeof(sizeof(int64_t)),
                                                     ctx->scheduler.num_threads);
    ctx->futhark_mc_segscan_task_77384_total_time = 0;
    ctx->futhark_mc_segscan_task_77384_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77393_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77393_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77393_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77393_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77393_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77393_total_iter = 0;
    ctx->futhark_mc_segmap_task_77391_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77391_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77391_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77391_total_time = 0;
    ctx->futhark_mc_segmap_task_77391_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77397_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77397_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77397_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77397_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77397_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77397_total_iter = 0;
    ctx->futhark_mc_segmap_task_77395_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77395_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77395_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77395_total_time = 0;
    ctx->futhark_mc_segmap_task_77395_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77401_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77401_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77401_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77401_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77401_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77401_total_iter = 0;
    ctx->futhark_mc_segmap_task_77399_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77399_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77399_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77399_total_time = 0;
    ctx->futhark_mc_segmap_task_77399_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77405_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77405_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77405_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77405_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77405_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77405_total_iter = 0;
    ctx->futhark_mc_segmap_task_77403_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77403_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77403_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77403_total_time = 0;
    ctx->futhark_mc_segmap_task_77403_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77420_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77420_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77420_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77420_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77420_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77420_total_iter = 0;
    ctx->futhark_mc_segmap_task_77418_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77418_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77418_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77418_total_time = 0;
    ctx->futhark_mc_segmap_task_77418_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77429_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77429_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77429_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77429_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77429_total_iter = 0;
    ctx->futhark_mc_segred_task_77422_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77422_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77422_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77422_total_time = 0;
    ctx->futhark_mc_segred_task_77422_total_iter = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77435_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77435_runs = calloc(sizeof(int),
                                                               ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77435_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_stage_1_parloop_77435_total_total_runtime = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs = 0;
    ctx->futhark_mc_segred_stage_1_parloop_77435_total_iter = 0;
    ctx->futhark_mc_segred_task_77431_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77431_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77431_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segred_task_77431_total_time = 0;
    ctx->futhark_mc_segred_task_77431_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77412_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77412_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77412_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77412_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77412_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77412_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77410_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77410_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77410_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77375_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77375_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77375_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77375_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77375_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77375_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77373_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77373_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77373_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77439_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77439_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77439_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77439_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77439_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77439_total_iter = 0;
    ctx->futhark_mc_segmap_task_77437_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77437_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77437_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77437_total_time = 0;
    ctx->futhark_mc_segmap_task_77437_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77448_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77448_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77448_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77448_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77448_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77448_total_iter = 0;
    ctx->futhark_mc_segmap_task_77446_total_runtime = calloc(sizeof(int64_t),
                                                             ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77446_runs = calloc(sizeof(int),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77446_iter = calloc(sizeof(sizeof(int64_t)),
                                                    ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_task_77446_total_time = 0;
    ctx->futhark_mc_segmap_task_77446_total_iter = 0;
    ctx->futhark_mc_segmap_parloop_77443_total_runtime = calloc(sizeof(int64_t),
                                                                ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77443_runs = calloc(sizeof(int),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77443_iter = calloc(sizeof(sizeof(int64_t)),
                                                       ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_parloop_77443_total_total_runtime = 0;
    ctx->futhark_mc_segmap_parloop_77443_total_runs = 0;
    ctx->futhark_mc_segmap_parloop_77443_total_iter = 0;
    ctx->futhark_mc_segmap_nested_task_77441_total_runtime =
        calloc(sizeof(int64_t), ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77441_runs = calloc(sizeof(int),
                                                           ctx->scheduler.num_threads);
    ctx->futhark_mc_segmap_nested_task_77441_iter =
        calloc(sizeof(sizeof(int64_t)), ctx->scheduler.num_threads);
    init_constants(ctx);
    return ctx;
}
void futhark_context_free(struct futhark_context *ctx)
{
    free(ctx->futhark_mc_segmap_parloop_77060_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77060_runs);
    free(ctx->futhark_mc_segmap_parloop_77060_iter);
    free(ctx->futhark_mc_segmap_task_77058_total_runtime);
    free(ctx->futhark_mc_segmap_task_77058_runs);
    free(ctx->futhark_mc_segmap_task_77058_iter);
    free(ctx->futhark_mc_scan_stage_1_parloop_77080_total_runtime);
    free(ctx->futhark_mc_scan_stage_1_parloop_77080_runs);
    free(ctx->futhark_mc_scan_stage_1_parloop_77080_iter);
    free(ctx->futhark_mc_scan_stage_3_parloop_77082_total_runtime);
    free(ctx->futhark_mc_scan_stage_3_parloop_77082_runs);
    free(ctx->futhark_mc_scan_stage_3_parloop_77082_iter);
    free(ctx->futhark_mc_segscan_task_77077_total_runtime);
    free(ctx->futhark_mc_segscan_task_77077_runs);
    free(ctx->futhark_mc_segscan_task_77077_iter);
    free(ctx->futhark_mc_segmap_parloop_77086_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77086_runs);
    free(ctx->futhark_mc_segmap_parloop_77086_iter);
    free(ctx->futhark_mc_segmap_task_77084_total_runtime);
    free(ctx->futhark_mc_segmap_task_77084_runs);
    free(ctx->futhark_mc_segmap_task_77084_iter);
    free(ctx->futhark_mc_segmap_parloop_77090_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77090_runs);
    free(ctx->futhark_mc_segmap_parloop_77090_iter);
    free(ctx->futhark_mc_segmap_task_77088_total_runtime);
    free(ctx->futhark_mc_segmap_task_77088_runs);
    free(ctx->futhark_mc_segmap_task_77088_iter);
    free(ctx->futhark_mc_segmap_parloop_77094_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77094_runs);
    free(ctx->futhark_mc_segmap_parloop_77094_iter);
    free(ctx->futhark_mc_segmap_task_77092_total_runtime);
    free(ctx->futhark_mc_segmap_task_77092_runs);
    free(ctx->futhark_mc_segmap_task_77092_iter);
    free(ctx->futhark_mc_segmap_parloop_77098_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77098_runs);
    free(ctx->futhark_mc_segmap_parloop_77098_iter);
    free(ctx->futhark_mc_segmap_task_77096_total_runtime);
    free(ctx->futhark_mc_segmap_task_77096_runs);
    free(ctx->futhark_mc_segmap_task_77096_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77106_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77106_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77106_iter);
    free(ctx->futhark_mc_segred_task_77103_total_runtime);
    free(ctx->futhark_mc_segred_task_77103_runs);
    free(ctx->futhark_mc_segred_task_77103_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77111_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77111_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77111_iter);
    free(ctx->futhark_mc_segred_task_77108_total_runtime);
    free(ctx->futhark_mc_segred_task_77108_runs);
    free(ctx->futhark_mc_segred_task_77108_iter);
    free(ctx->futhark_mc_segmap_parloop_77101_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77101_runs);
    free(ctx->futhark_mc_segmap_parloop_77101_iter);
    free(ctx->futhark_mc_segmap_nested_task_77099_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77099_runs);
    free(ctx->futhark_mc_segmap_nested_task_77099_iter);
    free(ctx->futhark_mc_segmap_parloop_77069_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77069_runs);
    free(ctx->futhark_mc_segmap_parloop_77069_iter);
    free(ctx->futhark_mc_segmap_nested_task_77067_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77067_runs);
    free(ctx->futhark_mc_segmap_nested_task_77067_iter);
    free(ctx->futhark_mc_segmap_parloop_77115_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77115_runs);
    free(ctx->futhark_mc_segmap_parloop_77115_iter);
    free(ctx->futhark_mc_segmap_task_77113_total_runtime);
    free(ctx->futhark_mc_segmap_task_77113_runs);
    free(ctx->futhark_mc_segmap_task_77113_iter);
    free(ctx->futhark_mc_scan_stage_1_parloop_77137_total_runtime);
    free(ctx->futhark_mc_scan_stage_1_parloop_77137_runs);
    free(ctx->futhark_mc_scan_stage_1_parloop_77137_iter);
    free(ctx->futhark_mc_scan_stage_3_parloop_77139_total_runtime);
    free(ctx->futhark_mc_scan_stage_3_parloop_77139_runs);
    free(ctx->futhark_mc_scan_stage_3_parloop_77139_iter);
    free(ctx->futhark_mc_segscan_task_77134_total_runtime);
    free(ctx->futhark_mc_segscan_task_77134_runs);
    free(ctx->futhark_mc_segscan_task_77134_iter);
    free(ctx->futhark_mc_segmap_parloop_77143_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77143_runs);
    free(ctx->futhark_mc_segmap_parloop_77143_iter);
    free(ctx->futhark_mc_segmap_task_77141_total_runtime);
    free(ctx->futhark_mc_segmap_task_77141_runs);
    free(ctx->futhark_mc_segmap_task_77141_iter);
    free(ctx->futhark_mc_segmap_parloop_77147_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77147_runs);
    free(ctx->futhark_mc_segmap_parloop_77147_iter);
    free(ctx->futhark_mc_segmap_task_77145_total_runtime);
    free(ctx->futhark_mc_segmap_task_77145_runs);
    free(ctx->futhark_mc_segmap_task_77145_iter);
    free(ctx->futhark_mc_segmap_parloop_77151_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77151_runs);
    free(ctx->futhark_mc_segmap_parloop_77151_iter);
    free(ctx->futhark_mc_segmap_task_77149_total_runtime);
    free(ctx->futhark_mc_segmap_task_77149_runs);
    free(ctx->futhark_mc_segmap_task_77149_iter);
    free(ctx->futhark_mc_segmap_parloop_77155_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77155_runs);
    free(ctx->futhark_mc_segmap_parloop_77155_iter);
    free(ctx->futhark_mc_segmap_task_77153_total_runtime);
    free(ctx->futhark_mc_segmap_task_77153_runs);
    free(ctx->futhark_mc_segmap_task_77153_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77165_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77165_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77165_iter);
    free(ctx->futhark_mc_segred_task_77160_total_runtime);
    free(ctx->futhark_mc_segred_task_77160_runs);
    free(ctx->futhark_mc_segred_task_77160_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77171_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77171_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77171_iter);
    free(ctx->futhark_mc_segred_task_77167_total_runtime);
    free(ctx->futhark_mc_segred_task_77167_runs);
    free(ctx->futhark_mc_segred_task_77167_iter);
    free(ctx->futhark_mc_segmap_parloop_77158_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77158_runs);
    free(ctx->futhark_mc_segmap_parloop_77158_iter);
    free(ctx->futhark_mc_segmap_nested_task_77156_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77156_runs);
    free(ctx->futhark_mc_segmap_nested_task_77156_iter);
    free(ctx->futhark_mc_segmap_parloop_77125_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77125_runs);
    free(ctx->futhark_mc_segmap_parloop_77125_iter);
    free(ctx->futhark_mc_segmap_nested_task_77123_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77123_runs);
    free(ctx->futhark_mc_segmap_nested_task_77123_iter);
    free(ctx->futhark_mc_segmap_parloop_77175_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77175_runs);
    free(ctx->futhark_mc_segmap_parloop_77175_iter);
    free(ctx->futhark_mc_segmap_task_77173_total_runtime);
    free(ctx->futhark_mc_segmap_task_77173_runs);
    free(ctx->futhark_mc_segmap_task_77173_iter);
    free(ctx->futhark_mc_scan_stage_1_parloop_77197_total_runtime);
    free(ctx->futhark_mc_scan_stage_1_parloop_77197_runs);
    free(ctx->futhark_mc_scan_stage_1_parloop_77197_iter);
    free(ctx->futhark_mc_scan_stage_3_parloop_77199_total_runtime);
    free(ctx->futhark_mc_scan_stage_3_parloop_77199_runs);
    free(ctx->futhark_mc_scan_stage_3_parloop_77199_iter);
    free(ctx->futhark_mc_segscan_task_77194_total_runtime);
    free(ctx->futhark_mc_segscan_task_77194_runs);
    free(ctx->futhark_mc_segscan_task_77194_iter);
    free(ctx->futhark_mc_segmap_parloop_77203_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77203_runs);
    free(ctx->futhark_mc_segmap_parloop_77203_iter);
    free(ctx->futhark_mc_segmap_task_77201_total_runtime);
    free(ctx->futhark_mc_segmap_task_77201_runs);
    free(ctx->futhark_mc_segmap_task_77201_iter);
    free(ctx->futhark_mc_segmap_parloop_77207_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77207_runs);
    free(ctx->futhark_mc_segmap_parloop_77207_iter);
    free(ctx->futhark_mc_segmap_task_77205_total_runtime);
    free(ctx->futhark_mc_segmap_task_77205_runs);
    free(ctx->futhark_mc_segmap_task_77205_iter);
    free(ctx->futhark_mc_segmap_parloop_77211_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77211_runs);
    free(ctx->futhark_mc_segmap_parloop_77211_iter);
    free(ctx->futhark_mc_segmap_task_77209_total_runtime);
    free(ctx->futhark_mc_segmap_task_77209_runs);
    free(ctx->futhark_mc_segmap_task_77209_iter);
    free(ctx->futhark_mc_segmap_parloop_77215_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77215_runs);
    free(ctx->futhark_mc_segmap_parloop_77215_iter);
    free(ctx->futhark_mc_segmap_task_77213_total_runtime);
    free(ctx->futhark_mc_segmap_task_77213_runs);
    free(ctx->futhark_mc_segmap_task_77213_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77227_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77227_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77227_iter);
    free(ctx->futhark_mc_segred_task_77220_total_runtime);
    free(ctx->futhark_mc_segred_task_77220_runs);
    free(ctx->futhark_mc_segred_task_77220_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77233_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77233_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77233_iter);
    free(ctx->futhark_mc_segred_task_77229_total_runtime);
    free(ctx->futhark_mc_segred_task_77229_runs);
    free(ctx->futhark_mc_segred_task_77229_iter);
    free(ctx->futhark_mc_segmap_parloop_77218_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77218_runs);
    free(ctx->futhark_mc_segmap_parloop_77218_iter);
    free(ctx->futhark_mc_segmap_nested_task_77216_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77216_runs);
    free(ctx->futhark_mc_segmap_nested_task_77216_iter);
    free(ctx->futhark_mc_segmap_parloop_77185_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77185_runs);
    free(ctx->futhark_mc_segmap_parloop_77185_iter);
    free(ctx->futhark_mc_segmap_nested_task_77183_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77183_runs);
    free(ctx->futhark_mc_segmap_nested_task_77183_iter);
    free(ctx->futhark_mc_segmap_parloop_77237_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77237_runs);
    free(ctx->futhark_mc_segmap_parloop_77237_iter);
    free(ctx->futhark_mc_segmap_task_77235_total_runtime);
    free(ctx->futhark_mc_segmap_task_77235_runs);
    free(ctx->futhark_mc_segmap_task_77235_iter);
    free(ctx->futhark_mc_scan_stage_1_parloop_77258_total_runtime);
    free(ctx->futhark_mc_scan_stage_1_parloop_77258_runs);
    free(ctx->futhark_mc_scan_stage_1_parloop_77258_iter);
    free(ctx->futhark_mc_scan_stage_3_parloop_77260_total_runtime);
    free(ctx->futhark_mc_scan_stage_3_parloop_77260_runs);
    free(ctx->futhark_mc_scan_stage_3_parloop_77260_iter);
    free(ctx->futhark_mc_segscan_task_77255_total_runtime);
    free(ctx->futhark_mc_segscan_task_77255_runs);
    free(ctx->futhark_mc_segscan_task_77255_iter);
    free(ctx->futhark_mc_segmap_parloop_77264_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77264_runs);
    free(ctx->futhark_mc_segmap_parloop_77264_iter);
    free(ctx->futhark_mc_segmap_task_77262_total_runtime);
    free(ctx->futhark_mc_segmap_task_77262_runs);
    free(ctx->futhark_mc_segmap_task_77262_iter);
    free(ctx->futhark_mc_segmap_parloop_77268_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77268_runs);
    free(ctx->futhark_mc_segmap_parloop_77268_iter);
    free(ctx->futhark_mc_segmap_task_77266_total_runtime);
    free(ctx->futhark_mc_segmap_task_77266_runs);
    free(ctx->futhark_mc_segmap_task_77266_iter);
    free(ctx->futhark_mc_segmap_parloop_77272_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77272_runs);
    free(ctx->futhark_mc_segmap_parloop_77272_iter);
    free(ctx->futhark_mc_segmap_task_77270_total_runtime);
    free(ctx->futhark_mc_segmap_task_77270_runs);
    free(ctx->futhark_mc_segmap_task_77270_iter);
    free(ctx->futhark_mc_segmap_parloop_77276_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77276_runs);
    free(ctx->futhark_mc_segmap_parloop_77276_iter);
    free(ctx->futhark_mc_segmap_task_77274_total_runtime);
    free(ctx->futhark_mc_segmap_task_77274_runs);
    free(ctx->futhark_mc_segmap_task_77274_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77286_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77286_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77286_iter);
    free(ctx->futhark_mc_segred_task_77283_total_runtime);
    free(ctx->futhark_mc_segred_task_77283_runs);
    free(ctx->futhark_mc_segred_task_77283_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77291_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77291_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77291_iter);
    free(ctx->futhark_mc_segred_task_77288_total_runtime);
    free(ctx->futhark_mc_segred_task_77288_runs);
    free(ctx->futhark_mc_segred_task_77288_iter);
    free(ctx->futhark_mc_segmap_parloop_77280_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77280_runs);
    free(ctx->futhark_mc_segmap_parloop_77280_iter);
    free(ctx->futhark_mc_segmap_nested_task_77278_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77278_runs);
    free(ctx->futhark_mc_segmap_nested_task_77278_iter);
    free(ctx->futhark_mc_segmap_parloop_77247_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77247_runs);
    free(ctx->futhark_mc_segmap_parloop_77247_iter);
    free(ctx->futhark_mc_segmap_nested_task_77245_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77245_runs);
    free(ctx->futhark_mc_segmap_nested_task_77245_iter);
    free(ctx->futhark_mc_segmap_parloop_77295_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77295_runs);
    free(ctx->futhark_mc_segmap_parloop_77295_iter);
    free(ctx->futhark_mc_segmap_task_77293_total_runtime);
    free(ctx->futhark_mc_segmap_task_77293_runs);
    free(ctx->futhark_mc_segmap_task_77293_iter);
    free(ctx->futhark_mc_scan_stage_1_parloop_77319_total_runtime);
    free(ctx->futhark_mc_scan_stage_1_parloop_77319_runs);
    free(ctx->futhark_mc_scan_stage_1_parloop_77319_iter);
    free(ctx->futhark_mc_scan_stage_3_parloop_77321_total_runtime);
    free(ctx->futhark_mc_scan_stage_3_parloop_77321_runs);
    free(ctx->futhark_mc_scan_stage_3_parloop_77321_iter);
    free(ctx->futhark_mc_segscan_task_77316_total_runtime);
    free(ctx->futhark_mc_segscan_task_77316_runs);
    free(ctx->futhark_mc_segscan_task_77316_iter);
    free(ctx->futhark_mc_segmap_parloop_77325_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77325_runs);
    free(ctx->futhark_mc_segmap_parloop_77325_iter);
    free(ctx->futhark_mc_segmap_task_77323_total_runtime);
    free(ctx->futhark_mc_segmap_task_77323_runs);
    free(ctx->futhark_mc_segmap_task_77323_iter);
    free(ctx->futhark_mc_segmap_parloop_77329_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77329_runs);
    free(ctx->futhark_mc_segmap_parloop_77329_iter);
    free(ctx->futhark_mc_segmap_task_77327_total_runtime);
    free(ctx->futhark_mc_segmap_task_77327_runs);
    free(ctx->futhark_mc_segmap_task_77327_iter);
    free(ctx->futhark_mc_segmap_parloop_77333_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77333_runs);
    free(ctx->futhark_mc_segmap_parloop_77333_iter);
    free(ctx->futhark_mc_segmap_task_77331_total_runtime);
    free(ctx->futhark_mc_segmap_task_77331_runs);
    free(ctx->futhark_mc_segmap_task_77331_iter);
    free(ctx->futhark_mc_segmap_parloop_77337_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77337_runs);
    free(ctx->futhark_mc_segmap_parloop_77337_iter);
    free(ctx->futhark_mc_segmap_task_77335_total_runtime);
    free(ctx->futhark_mc_segmap_task_77335_runs);
    free(ctx->futhark_mc_segmap_task_77335_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77351_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77351_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77351_iter);
    free(ctx->futhark_mc_segred_task_77346_total_runtime);
    free(ctx->futhark_mc_segred_task_77346_runs);
    free(ctx->futhark_mc_segred_task_77346_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77357_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77357_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77357_iter);
    free(ctx->futhark_mc_segred_task_77353_total_runtime);
    free(ctx->futhark_mc_segred_task_77353_runs);
    free(ctx->futhark_mc_segred_task_77353_iter);
    free(ctx->futhark_mc_segmap_parloop_77342_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77342_runs);
    free(ctx->futhark_mc_segmap_parloop_77342_iter);
    free(ctx->futhark_mc_segmap_nested_task_77340_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77340_runs);
    free(ctx->futhark_mc_segmap_nested_task_77340_iter);
    free(ctx->futhark_mc_segmap_parloop_77307_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77307_runs);
    free(ctx->futhark_mc_segmap_parloop_77307_iter);
    free(ctx->futhark_mc_segmap_nested_task_77305_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77305_runs);
    free(ctx->futhark_mc_segmap_nested_task_77305_iter);
    free(ctx->futhark_mc_segmap_parloop_77361_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77361_runs);
    free(ctx->futhark_mc_segmap_parloop_77361_iter);
    free(ctx->futhark_mc_segmap_task_77359_total_runtime);
    free(ctx->futhark_mc_segmap_task_77359_runs);
    free(ctx->futhark_mc_segmap_task_77359_iter);
    free(ctx->futhark_mc_scan_stage_1_parloop_77387_total_runtime);
    free(ctx->futhark_mc_scan_stage_1_parloop_77387_runs);
    free(ctx->futhark_mc_scan_stage_1_parloop_77387_iter);
    free(ctx->futhark_mc_scan_stage_3_parloop_77389_total_runtime);
    free(ctx->futhark_mc_scan_stage_3_parloop_77389_runs);
    free(ctx->futhark_mc_scan_stage_3_parloop_77389_iter);
    free(ctx->futhark_mc_segscan_task_77384_total_runtime);
    free(ctx->futhark_mc_segscan_task_77384_runs);
    free(ctx->futhark_mc_segscan_task_77384_iter);
    free(ctx->futhark_mc_segmap_parloop_77393_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77393_runs);
    free(ctx->futhark_mc_segmap_parloop_77393_iter);
    free(ctx->futhark_mc_segmap_task_77391_total_runtime);
    free(ctx->futhark_mc_segmap_task_77391_runs);
    free(ctx->futhark_mc_segmap_task_77391_iter);
    free(ctx->futhark_mc_segmap_parloop_77397_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77397_runs);
    free(ctx->futhark_mc_segmap_parloop_77397_iter);
    free(ctx->futhark_mc_segmap_task_77395_total_runtime);
    free(ctx->futhark_mc_segmap_task_77395_runs);
    free(ctx->futhark_mc_segmap_task_77395_iter);
    free(ctx->futhark_mc_segmap_parloop_77401_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77401_runs);
    free(ctx->futhark_mc_segmap_parloop_77401_iter);
    free(ctx->futhark_mc_segmap_task_77399_total_runtime);
    free(ctx->futhark_mc_segmap_task_77399_runs);
    free(ctx->futhark_mc_segmap_task_77399_iter);
    free(ctx->futhark_mc_segmap_parloop_77405_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77405_runs);
    free(ctx->futhark_mc_segmap_parloop_77405_iter);
    free(ctx->futhark_mc_segmap_task_77403_total_runtime);
    free(ctx->futhark_mc_segmap_task_77403_runs);
    free(ctx->futhark_mc_segmap_task_77403_iter);
    free(ctx->futhark_mc_segmap_parloop_77420_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77420_runs);
    free(ctx->futhark_mc_segmap_parloop_77420_iter);
    free(ctx->futhark_mc_segmap_task_77418_total_runtime);
    free(ctx->futhark_mc_segmap_task_77418_runs);
    free(ctx->futhark_mc_segmap_task_77418_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77429_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77429_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77429_iter);
    free(ctx->futhark_mc_segred_task_77422_total_runtime);
    free(ctx->futhark_mc_segred_task_77422_runs);
    free(ctx->futhark_mc_segred_task_77422_iter);
    free(ctx->futhark_mc_segred_stage_1_parloop_77435_total_runtime);
    free(ctx->futhark_mc_segred_stage_1_parloop_77435_runs);
    free(ctx->futhark_mc_segred_stage_1_parloop_77435_iter);
    free(ctx->futhark_mc_segred_task_77431_total_runtime);
    free(ctx->futhark_mc_segred_task_77431_runs);
    free(ctx->futhark_mc_segred_task_77431_iter);
    free(ctx->futhark_mc_segmap_parloop_77412_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77412_runs);
    free(ctx->futhark_mc_segmap_parloop_77412_iter);
    free(ctx->futhark_mc_segmap_nested_task_77410_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77410_runs);
    free(ctx->futhark_mc_segmap_nested_task_77410_iter);
    free(ctx->futhark_mc_segmap_parloop_77375_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77375_runs);
    free(ctx->futhark_mc_segmap_parloop_77375_iter);
    free(ctx->futhark_mc_segmap_nested_task_77373_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77373_runs);
    free(ctx->futhark_mc_segmap_nested_task_77373_iter);
    free(ctx->futhark_mc_segmap_parloop_77439_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77439_runs);
    free(ctx->futhark_mc_segmap_parloop_77439_iter);
    free(ctx->futhark_mc_segmap_task_77437_total_runtime);
    free(ctx->futhark_mc_segmap_task_77437_runs);
    free(ctx->futhark_mc_segmap_task_77437_iter);
    free(ctx->futhark_mc_segmap_parloop_77448_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77448_runs);
    free(ctx->futhark_mc_segmap_parloop_77448_iter);
    free(ctx->futhark_mc_segmap_task_77446_total_runtime);
    free(ctx->futhark_mc_segmap_task_77446_runs);
    free(ctx->futhark_mc_segmap_task_77446_iter);
    free(ctx->futhark_mc_segmap_parloop_77443_total_runtime);
    free(ctx->futhark_mc_segmap_parloop_77443_runs);
    free(ctx->futhark_mc_segmap_parloop_77443_iter);
    free(ctx->futhark_mc_segmap_nested_task_77441_total_runtime);
    free(ctx->futhark_mc_segmap_nested_task_77441_runs);
    free(ctx->futhark_mc_segmap_nested_task_77441_iter);
    free_constants(ctx);
    (void) scheduler_destroy(&ctx->scheduler);
    free_lock(&ctx->lock);
    ctx->cfg->in_use = 0;
    free(ctx);
}
int futhark_context_sync(struct futhark_context *ctx)
{
    (void) ctx;
    return 0;
}
static const char *tuning_param_names[0];
static const char *tuning_param_vars[0];
static const char *tuning_param_classes[0];
int futhark_context_config_set_tuning_param(struct futhark_context_config *cfg,
                                            const char *param_name,
                                            size_t param_value)
{
    (void) cfg;
    (void) param_name;
    (void) param_value;
    return 1;
}
static int memblock_unref(struct futhark_context *ctx, struct memblock *block,
                          const char *desc)
{
    if (block->references != NULL) {
        *block->references -= 1;
        if (ctx->detail_memory)
            fprintf(ctx->log,
                    "Unreferencing block %s (allocated as %s) in %s: %d references remaining.\n",
                    desc, block->desc, "default space", *block->references);
        if (*block->references == 0) {
            ctx->cur_mem_usage_default -= block->size;
            free(block->mem);
            free(block->references);
            if (ctx->detail_memory)
                fprintf(ctx->log,
                        "%lld bytes freed (now allocated: %lld bytes)\n",
                        (long long) block->size,
                        (long long) ctx->cur_mem_usage_default);
        }
        block->references = NULL;
    }
    return 0;
}
static int memblock_alloc(struct futhark_context *ctx, struct memblock *block,
                          int64_t size, const char *desc)
{
    if (size < 0)
        futhark_panic(1,
                      "Negative allocation of %lld bytes attempted for %s in %s.\n",
                      (long long) size, desc, "default space",
                      ctx->cur_mem_usage_default);
    
    int ret = memblock_unref(ctx, block, desc);
    
    ctx->cur_mem_usage_default += size;
    if (ctx->detail_memory)
        fprintf(ctx->log,
                "Allocating %lld bytes for %s in %s (then allocated: %lld bytes)",
                (long long) size, desc, "default space",
                (long long) ctx->cur_mem_usage_default);
    if (ctx->cur_mem_usage_default > ctx->peak_mem_usage_default) {
        ctx->peak_mem_usage_default = ctx->cur_mem_usage_default;
        if (ctx->detail_memory)
            fprintf(ctx->log, " (new peak).\n");
    } else if (ctx->detail_memory)
        fprintf(ctx->log, ".\n");
    block->mem = (unsigned char *) malloc((size_t) size);
    block->references = (int *) malloc(sizeof(int));
    *block->references = 1;
    block->size = size;
    block->desc = desc;
    return ret;
}
static int memblock_set(struct futhark_context *ctx, struct memblock *lhs,
                        struct memblock *rhs, const char *lhs_desc)
{
    int ret = memblock_unref(ctx, lhs, lhs_desc);
    
    if (rhs->references != NULL)
        (*rhs->references)++;
    *lhs = *rhs;
    return ret;
}
int futhark_get_tuning_param_count(void)
{
    return sizeof(tuning_param_names) / sizeof(tuning_param_names[0]);
}
const char *futhark_get_tuning_param_name(int i)
{
    return tuning_param_names[i];
}
const char *futhark_get_tuning_param_class(int i)
{
    return tuning_param_classes[i];
}
char *futhark_context_report(struct futhark_context *ctx)
{
    if (futhark_context_sync(ctx) != 0)
        return NULL;
    
    struct str_builder builder;
    
    str_builder_init(&builder);
    if (ctx->detail_memory || ctx->profiling || ctx->logging) {
        { }
    }
    if (ctx->profiling) {
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77060          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77060_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77060_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77060_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77060_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77060_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77060_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77060_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77060_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77060_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77060_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77060_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77060_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77060_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77060_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77060_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77060_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77060_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77060_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77060_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77060_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77060_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77060_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77060_total_iter /
                (ctx->futhark_mc_segmap_parloop_77060_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77060_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77060_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77060_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_1_parloop_77080    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_1_parloop_77080_runs[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77080_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77080_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77080_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77080_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_1_parloop_77080_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77080_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77080_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77080_iter[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77080_iter[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77080_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77080_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_1_parloop_77080_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77080_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77080_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_1_parloop_77080_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77080_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77080_total_iter),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77080_total_iter,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77080_total_iter /
                (ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_1_parloop_77080_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_3_parloop_77082    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_3_parloop_77082_runs[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77082_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77082_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77082_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77082_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_3_parloop_77082_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77082_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77082_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77082_iter[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77082_iter[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77082_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77082_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_3_parloop_77082_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77082_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77082_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_3_parloop_77082_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77082_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77082_total_iter),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77082_total_iter,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77082_total_iter /
                (ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_3_parloop_77082_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segscan_task_77077            ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segscan_task_77077_runs[i],
                    (long) ctx->futhark_mc_segscan_task_77077_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77077_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77077_runs[i] : 1),
                    (long) ctx->futhark_mc_segscan_task_77077_total_runtime[i],
                    (double) ctx->futhark_mc_segscan_task_77077_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77077_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segscan_task_77077_iter[i]),
                    (long) ctx->futhark_mc_segscan_task_77077_iter[i],
                    (long) ctx->futhark_mc_segscan_task_77077_iter[i] /
                    (ctx->futhark_mc_segscan_task_77077_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77077_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77086          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77086_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77086_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77086_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77086_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77086_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77086_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77086_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77086_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77086_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77086_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77086_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77086_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77086_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77086_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77086_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77086_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77086_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77086_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77086_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77086_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77086_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77086_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77086_total_iter /
                (ctx->futhark_mc_segmap_parloop_77086_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77086_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77086_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77086_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77084             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77084_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77084_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77084_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77084_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77084_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77084_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77084_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77084_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77084_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77084_iter[i] /
                    (ctx->futhark_mc_segmap_task_77084_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77084_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77090          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77090_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77090_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77090_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77090_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77090_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77090_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77090_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77090_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77090_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77090_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77090_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77090_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77090_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77090_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77090_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77090_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77090_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77090_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77090_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77090_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77090_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77090_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77090_total_iter /
                (ctx->futhark_mc_segmap_parloop_77090_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77090_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77090_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77090_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77088             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77088_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77088_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77088_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77088_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77088_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77088_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77088_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77088_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77088_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77088_iter[i] /
                    (ctx->futhark_mc_segmap_task_77088_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77088_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77094          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77094_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77094_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77094_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77094_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77094_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77094_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77094_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77094_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77094_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77094_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77094_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77094_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77094_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77094_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77094_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77094_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77094_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77094_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77094_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77094_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77094_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77094_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77094_total_iter /
                (ctx->futhark_mc_segmap_parloop_77094_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77094_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77094_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77094_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77092             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77092_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77092_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77092_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77092_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77092_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77092_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77092_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77092_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77092_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77092_iter[i] /
                    (ctx->futhark_mc_segmap_task_77092_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77092_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77098          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77098_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77098_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77098_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77098_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77098_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77098_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77098_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77098_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77098_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77098_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77098_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77098_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77098_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77098_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77098_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77098_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77098_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77098_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77098_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77098_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77098_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77098_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77098_total_iter /
                (ctx->futhark_mc_segmap_parloop_77098_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77098_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77098_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77098_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77106  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77106_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77106_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77106_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77106_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77106_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77106_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77106_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77106_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77106_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77106_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77106_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77106_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77106_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77106_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77106_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77106_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77106_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77106_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77106_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77106_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77106_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77103             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77103_runs[i],
                    (long) ctx->futhark_mc_segred_task_77103_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77103_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77103_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77103_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77103_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77103_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77103_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77103_iter[i],
                    (long) ctx->futhark_mc_segred_task_77103_iter[i] /
                    (ctx->futhark_mc_segred_task_77103_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77103_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77111  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77111_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77111_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77111_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77111_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77111_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77111_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77111_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77111_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77111_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77111_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77111_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77111_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77111_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77111_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77111_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77111_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77111_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77111_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77111_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77111_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77111_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77108             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77108_runs[i],
                    (long) ctx->futhark_mc_segred_task_77108_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77108_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77108_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77108_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77108_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77108_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77108_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77108_iter[i],
                    (long) ctx->futhark_mc_segred_task_77108_iter[i] /
                    (ctx->futhark_mc_segred_task_77108_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77108_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77101          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77101_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77101_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77101_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77101_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77101_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77101_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77101_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77101_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77101_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77101_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77101_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77101_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77101_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77101_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77101_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77101_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77101_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77101_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77101_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77101_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77101_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77101_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77101_total_iter /
                (ctx->futhark_mc_segmap_parloop_77101_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77101_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77101_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77101_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77096             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77096_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77096_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77096_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77096_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77096_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77096_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77096_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77096_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77096_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77096_iter[i] /
                    (ctx->futhark_mc_segmap_task_77096_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77096_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77099      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77099_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77099_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77099_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77099_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77099_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77099_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77099_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77099_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77099_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77099_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77099_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77099_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77069          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77069_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77069_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77069_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77069_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77069_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77069_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77069_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77069_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77069_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77069_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77069_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77069_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77069_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77069_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77069_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77069_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77069_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77069_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77069_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77069_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77069_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77069_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77069_total_iter /
                (ctx->futhark_mc_segmap_parloop_77069_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77069_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77069_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77069_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77058             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77058_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77058_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77058_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77058_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77058_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77058_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77058_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77058_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77058_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77058_iter[i] /
                    (ctx->futhark_mc_segmap_task_77058_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77058_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77067      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77067_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77067_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77067_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77067_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77067_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77067_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77067_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77067_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77067_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77067_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77067_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77067_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77115          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77115_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77115_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77115_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77115_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77115_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77115_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77115_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77115_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77115_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77115_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77115_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77115_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77115_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77115_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77115_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77115_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77115_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77115_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77115_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77115_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77115_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77115_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77115_total_iter /
                (ctx->futhark_mc_segmap_parloop_77115_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77115_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77115_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77115_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_1_parloop_77137    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_1_parloop_77137_runs[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77137_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77137_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77137_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77137_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_1_parloop_77137_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77137_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77137_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77137_iter[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77137_iter[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77137_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77137_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_1_parloop_77137_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77137_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77137_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_1_parloop_77137_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77137_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77137_total_iter),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77137_total_iter,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77137_total_iter /
                (ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_1_parloop_77137_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_3_parloop_77139    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_3_parloop_77139_runs[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77139_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77139_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77139_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77139_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_3_parloop_77139_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77139_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77139_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77139_iter[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77139_iter[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77139_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77139_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_3_parloop_77139_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77139_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77139_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_3_parloop_77139_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77139_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77139_total_iter),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77139_total_iter,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77139_total_iter /
                (ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_3_parloop_77139_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segscan_task_77134            ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segscan_task_77134_runs[i],
                    (long) ctx->futhark_mc_segscan_task_77134_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77134_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77134_runs[i] : 1),
                    (long) ctx->futhark_mc_segscan_task_77134_total_runtime[i],
                    (double) ctx->futhark_mc_segscan_task_77134_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77134_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segscan_task_77134_iter[i]),
                    (long) ctx->futhark_mc_segscan_task_77134_iter[i],
                    (long) ctx->futhark_mc_segscan_task_77134_iter[i] /
                    (ctx->futhark_mc_segscan_task_77134_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77134_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77143          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77143_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77143_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77143_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77143_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77143_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77143_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77143_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77143_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77143_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77143_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77143_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77143_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77143_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77143_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77143_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77143_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77143_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77143_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77143_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77143_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77143_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77143_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77143_total_iter /
                (ctx->futhark_mc_segmap_parloop_77143_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77143_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77143_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77143_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77141             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77141_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77141_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77141_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77141_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77141_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77141_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77141_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77141_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77141_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77141_iter[i] /
                    (ctx->futhark_mc_segmap_task_77141_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77141_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77147          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77147_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77147_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77147_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77147_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77147_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77147_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77147_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77147_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77147_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77147_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77147_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77147_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77147_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77147_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77147_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77147_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77147_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77147_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77147_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77147_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77147_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77147_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77147_total_iter /
                (ctx->futhark_mc_segmap_parloop_77147_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77147_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77147_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77147_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77145             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77145_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77145_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77145_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77145_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77145_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77145_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77145_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77145_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77145_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77145_iter[i] /
                    (ctx->futhark_mc_segmap_task_77145_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77145_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77151          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77151_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77151_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77151_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77151_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77151_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77151_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77151_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77151_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77151_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77151_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77151_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77151_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77151_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77151_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77151_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77151_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77151_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77151_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77151_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77151_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77151_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77151_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77151_total_iter /
                (ctx->futhark_mc_segmap_parloop_77151_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77151_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77151_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77151_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77149             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77149_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77149_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77149_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77149_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77149_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77149_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77149_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77149_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77149_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77149_iter[i] /
                    (ctx->futhark_mc_segmap_task_77149_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77149_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77155          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77155_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77155_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77155_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77155_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77155_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77155_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77155_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77155_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77155_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77155_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77155_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77155_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77155_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77155_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77155_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77155_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77155_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77155_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77155_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77155_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77155_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77155_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77155_total_iter /
                (ctx->futhark_mc_segmap_parloop_77155_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77155_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77155_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77155_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77165  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77165_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77165_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77165_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77165_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77165_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77165_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77165_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77165_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77165_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77165_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77165_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77165_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77165_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77165_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77165_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77165_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77165_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77165_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77165_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77165_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77165_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77160             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77160_runs[i],
                    (long) ctx->futhark_mc_segred_task_77160_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77160_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77160_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77160_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77160_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77160_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77160_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77160_iter[i],
                    (long) ctx->futhark_mc_segred_task_77160_iter[i] /
                    (ctx->futhark_mc_segred_task_77160_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77160_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77171  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77171_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77171_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77171_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77171_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77171_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77171_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77171_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77171_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77171_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77171_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77171_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77171_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77171_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77171_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77171_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77171_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77171_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77171_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77171_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77171_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77171_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77167             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77167_runs[i],
                    (long) ctx->futhark_mc_segred_task_77167_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77167_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77167_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77167_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77167_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77167_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77167_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77167_iter[i],
                    (long) ctx->futhark_mc_segred_task_77167_iter[i] /
                    (ctx->futhark_mc_segred_task_77167_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77167_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77158          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77158_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77158_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77158_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77158_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77158_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77158_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77158_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77158_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77158_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77158_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77158_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77158_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77158_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77158_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77158_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77158_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77158_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77158_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77158_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77158_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77158_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77158_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77158_total_iter /
                (ctx->futhark_mc_segmap_parloop_77158_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77158_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77158_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77158_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77153             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77153_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77153_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77153_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77153_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77153_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77153_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77153_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77153_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77153_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77153_iter[i] /
                    (ctx->futhark_mc_segmap_task_77153_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77153_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77156      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77156_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77156_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77156_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77156_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77156_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77156_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77156_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77156_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77156_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77156_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77156_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77156_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77125          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77125_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77125_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77125_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77125_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77125_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77125_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77125_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77125_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77125_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77125_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77125_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77125_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77125_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77125_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77125_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77125_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77125_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77125_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77125_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77125_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77125_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77125_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77125_total_iter /
                (ctx->futhark_mc_segmap_parloop_77125_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77125_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77125_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77125_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77113             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77113_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77113_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77113_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77113_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77113_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77113_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77113_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77113_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77113_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77113_iter[i] /
                    (ctx->futhark_mc_segmap_task_77113_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77113_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77123      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77123_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77123_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77123_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77123_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77123_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77123_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77123_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77123_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77123_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77123_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77123_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77123_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77175          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77175_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77175_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77175_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77175_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77175_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77175_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77175_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77175_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77175_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77175_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77175_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77175_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77175_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77175_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77175_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77175_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77175_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77175_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77175_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77175_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77175_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77175_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77175_total_iter /
                (ctx->futhark_mc_segmap_parloop_77175_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77175_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77175_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77175_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_1_parloop_77197    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_1_parloop_77197_runs[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77197_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77197_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77197_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77197_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_1_parloop_77197_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77197_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77197_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77197_iter[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77197_iter[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77197_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77197_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_1_parloop_77197_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77197_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77197_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_1_parloop_77197_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77197_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77197_total_iter),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77197_total_iter,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77197_total_iter /
                (ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_1_parloop_77197_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_3_parloop_77199    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_3_parloop_77199_runs[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77199_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77199_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77199_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77199_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_3_parloop_77199_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77199_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77199_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77199_iter[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77199_iter[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77199_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77199_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_3_parloop_77199_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77199_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77199_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_3_parloop_77199_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77199_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77199_total_iter),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77199_total_iter,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77199_total_iter /
                (ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_3_parloop_77199_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segscan_task_77194            ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segscan_task_77194_runs[i],
                    (long) ctx->futhark_mc_segscan_task_77194_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77194_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77194_runs[i] : 1),
                    (long) ctx->futhark_mc_segscan_task_77194_total_runtime[i],
                    (double) ctx->futhark_mc_segscan_task_77194_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77194_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segscan_task_77194_iter[i]),
                    (long) ctx->futhark_mc_segscan_task_77194_iter[i],
                    (long) ctx->futhark_mc_segscan_task_77194_iter[i] /
                    (ctx->futhark_mc_segscan_task_77194_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77194_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77203          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77203_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77203_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77203_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77203_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77203_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77203_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77203_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77203_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77203_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77203_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77203_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77203_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77203_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77203_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77203_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77203_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77203_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77203_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77203_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77203_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77203_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77203_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77203_total_iter /
                (ctx->futhark_mc_segmap_parloop_77203_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77203_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77203_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77203_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77201             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77201_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77201_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77201_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77201_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77201_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77201_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77201_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77201_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77201_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77201_iter[i] /
                    (ctx->futhark_mc_segmap_task_77201_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77201_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77207          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77207_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77207_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77207_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77207_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77207_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77207_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77207_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77207_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77207_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77207_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77207_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77207_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77207_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77207_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77207_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77207_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77207_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77207_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77207_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77207_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77207_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77207_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77207_total_iter /
                (ctx->futhark_mc_segmap_parloop_77207_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77207_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77207_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77207_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77205             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77205_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77205_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77205_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77205_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77205_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77205_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77205_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77205_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77205_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77205_iter[i] /
                    (ctx->futhark_mc_segmap_task_77205_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77205_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77211          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77211_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77211_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77211_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77211_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77211_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77211_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77211_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77211_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77211_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77211_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77211_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77211_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77211_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77211_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77211_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77211_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77211_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77211_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77211_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77211_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77211_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77211_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77211_total_iter /
                (ctx->futhark_mc_segmap_parloop_77211_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77211_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77211_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77211_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77209             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77209_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77209_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77209_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77209_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77209_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77209_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77209_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77209_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77209_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77209_iter[i] /
                    (ctx->futhark_mc_segmap_task_77209_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77209_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77215          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77215_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77215_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77215_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77215_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77215_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77215_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77215_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77215_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77215_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77215_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77215_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77215_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77215_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77215_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77215_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77215_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77215_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77215_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77215_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77215_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77215_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77215_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77215_total_iter /
                (ctx->futhark_mc_segmap_parloop_77215_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77215_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77215_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77215_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77227  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77227_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77227_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77227_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77227_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77227_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77227_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77227_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77227_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77227_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77227_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77227_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77227_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77227_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77227_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77227_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77227_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77227_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77227_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77227_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77227_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77227_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77220             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77220_runs[i],
                    (long) ctx->futhark_mc_segred_task_77220_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77220_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77220_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77220_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77220_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77220_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77220_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77220_iter[i],
                    (long) ctx->futhark_mc_segred_task_77220_iter[i] /
                    (ctx->futhark_mc_segred_task_77220_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77220_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77233  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77233_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77233_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77233_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77233_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77233_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77233_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77233_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77233_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77233_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77233_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77233_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77233_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77233_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77233_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77233_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77233_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77233_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77233_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77233_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77233_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77233_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77229             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77229_runs[i],
                    (long) ctx->futhark_mc_segred_task_77229_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77229_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77229_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77229_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77229_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77229_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77229_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77229_iter[i],
                    (long) ctx->futhark_mc_segred_task_77229_iter[i] /
                    (ctx->futhark_mc_segred_task_77229_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77229_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77218          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77218_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77218_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77218_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77218_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77218_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77218_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77218_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77218_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77218_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77218_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77218_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77218_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77218_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77218_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77218_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77218_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77218_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77218_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77218_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77218_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77218_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77218_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77218_total_iter /
                (ctx->futhark_mc_segmap_parloop_77218_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77218_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77218_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77218_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77213             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77213_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77213_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77213_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77213_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77213_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77213_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77213_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77213_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77213_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77213_iter[i] /
                    (ctx->futhark_mc_segmap_task_77213_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77213_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77216      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77216_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77216_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77216_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77216_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77216_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77216_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77216_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77216_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77216_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77216_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77216_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77216_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77185          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77185_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77185_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77185_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77185_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77185_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77185_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77185_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77185_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77185_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77185_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77185_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77185_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77185_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77185_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77185_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77185_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77185_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77185_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77185_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77185_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77185_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77185_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77185_total_iter /
                (ctx->futhark_mc_segmap_parloop_77185_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77185_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77185_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77185_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77173             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77173_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77173_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77173_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77173_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77173_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77173_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77173_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77173_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77173_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77173_iter[i] /
                    (ctx->futhark_mc_segmap_task_77173_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77173_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77183      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77183_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77183_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77183_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77183_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77183_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77183_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77183_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77183_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77183_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77183_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77183_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77183_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77237          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77237_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77237_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77237_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77237_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77237_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77237_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77237_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77237_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77237_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77237_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77237_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77237_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77237_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77237_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77237_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77237_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77237_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77237_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77237_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77237_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77237_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77237_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77237_total_iter /
                (ctx->futhark_mc_segmap_parloop_77237_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77237_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77237_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77237_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_1_parloop_77258    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_1_parloop_77258_runs[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77258_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77258_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77258_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77258_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_1_parloop_77258_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77258_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77258_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77258_iter[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77258_iter[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77258_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77258_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_1_parloop_77258_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77258_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77258_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_1_parloop_77258_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77258_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77258_total_iter),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77258_total_iter,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77258_total_iter /
                (ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_1_parloop_77258_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_3_parloop_77260    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_3_parloop_77260_runs[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77260_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77260_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77260_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77260_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_3_parloop_77260_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77260_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77260_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77260_iter[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77260_iter[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77260_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77260_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_3_parloop_77260_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77260_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77260_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_3_parloop_77260_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77260_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77260_total_iter),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77260_total_iter,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77260_total_iter /
                (ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_3_parloop_77260_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segscan_task_77255            ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segscan_task_77255_runs[i],
                    (long) ctx->futhark_mc_segscan_task_77255_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77255_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77255_runs[i] : 1),
                    (long) ctx->futhark_mc_segscan_task_77255_total_runtime[i],
                    (double) ctx->futhark_mc_segscan_task_77255_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77255_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segscan_task_77255_iter[i]),
                    (long) ctx->futhark_mc_segscan_task_77255_iter[i],
                    (long) ctx->futhark_mc_segscan_task_77255_iter[i] /
                    (ctx->futhark_mc_segscan_task_77255_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77255_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77264          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77264_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77264_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77264_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77264_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77264_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77264_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77264_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77264_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77264_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77264_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77264_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77264_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77264_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77264_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77264_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77264_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77264_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77264_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77264_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77264_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77264_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77264_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77264_total_iter /
                (ctx->futhark_mc_segmap_parloop_77264_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77264_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77264_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77264_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77262             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77262_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77262_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77262_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77262_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77262_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77262_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77262_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77262_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77262_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77262_iter[i] /
                    (ctx->futhark_mc_segmap_task_77262_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77262_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77268          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77268_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77268_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77268_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77268_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77268_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77268_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77268_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77268_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77268_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77268_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77268_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77268_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77268_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77268_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77268_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77268_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77268_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77268_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77268_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77268_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77268_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77268_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77268_total_iter /
                (ctx->futhark_mc_segmap_parloop_77268_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77268_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77268_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77268_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77266             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77266_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77266_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77266_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77266_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77266_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77266_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77266_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77266_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77266_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77266_iter[i] /
                    (ctx->futhark_mc_segmap_task_77266_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77266_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77272          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77272_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77272_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77272_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77272_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77272_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77272_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77272_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77272_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77272_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77272_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77272_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77272_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77272_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77272_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77272_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77272_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77272_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77272_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77272_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77272_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77272_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77272_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77272_total_iter /
                (ctx->futhark_mc_segmap_parloop_77272_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77272_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77272_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77272_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77270             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77270_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77270_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77270_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77270_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77270_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77270_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77270_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77270_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77270_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77270_iter[i] /
                    (ctx->futhark_mc_segmap_task_77270_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77270_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77276          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77276_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77276_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77276_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77276_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77276_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77276_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77276_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77276_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77276_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77276_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77276_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77276_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77276_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77276_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77276_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77276_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77276_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77276_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77276_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77276_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77276_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77276_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77276_total_iter /
                (ctx->futhark_mc_segmap_parloop_77276_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77276_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77276_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77276_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77286  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77286_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77286_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77286_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77286_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77286_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77286_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77286_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77286_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77286_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77286_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77286_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77286_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77286_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77286_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77286_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77286_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77286_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77286_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77286_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77286_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77286_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77283             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77283_runs[i],
                    (long) ctx->futhark_mc_segred_task_77283_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77283_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77283_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77283_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77283_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77283_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77283_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77283_iter[i],
                    (long) ctx->futhark_mc_segred_task_77283_iter[i] /
                    (ctx->futhark_mc_segred_task_77283_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77283_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77291  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77291_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77291_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77291_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77291_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77291_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77291_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77291_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77291_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77291_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77291_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77291_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77291_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77291_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77291_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77291_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77291_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77291_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77291_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77291_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77291_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77291_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77288             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77288_runs[i],
                    (long) ctx->futhark_mc_segred_task_77288_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77288_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77288_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77288_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77288_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77288_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77288_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77288_iter[i],
                    (long) ctx->futhark_mc_segred_task_77288_iter[i] /
                    (ctx->futhark_mc_segred_task_77288_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77288_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77280          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77280_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77280_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77280_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77280_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77280_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77280_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77280_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77280_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77280_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77280_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77280_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77280_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77280_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77280_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77280_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77280_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77280_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77280_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77280_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77280_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77280_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77280_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77280_total_iter /
                (ctx->futhark_mc_segmap_parloop_77280_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77280_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77280_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77280_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77274             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77274_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77274_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77274_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77274_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77274_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77274_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77274_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77274_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77274_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77274_iter[i] /
                    (ctx->futhark_mc_segmap_task_77274_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77274_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77278      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77278_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77278_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77278_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77278_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77278_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77278_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77278_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77278_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77278_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77278_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77278_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77278_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77247          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77247_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77247_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77247_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77247_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77247_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77247_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77247_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77247_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77247_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77247_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77247_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77247_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77247_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77247_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77247_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77247_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77247_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77247_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77247_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77247_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77247_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77247_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77247_total_iter /
                (ctx->futhark_mc_segmap_parloop_77247_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77247_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77247_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77247_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77235             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77235_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77235_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77235_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77235_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77235_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77235_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77235_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77235_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77235_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77235_iter[i] /
                    (ctx->futhark_mc_segmap_task_77235_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77235_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77245      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77245_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77245_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77245_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77245_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77245_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77245_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77245_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77245_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77245_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77245_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77245_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77245_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77295          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77295_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77295_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77295_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77295_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77295_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77295_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77295_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77295_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77295_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77295_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77295_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77295_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77295_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77295_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77295_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77295_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77295_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77295_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77295_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77295_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77295_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77295_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77295_total_iter /
                (ctx->futhark_mc_segmap_parloop_77295_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77295_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77295_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77295_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_1_parloop_77319    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_1_parloop_77319_runs[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77319_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77319_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77319_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77319_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_1_parloop_77319_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77319_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77319_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77319_iter[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77319_iter[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77319_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77319_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_1_parloop_77319_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77319_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77319_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_1_parloop_77319_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77319_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77319_total_iter),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77319_total_iter,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77319_total_iter /
                (ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_1_parloop_77319_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_3_parloop_77321    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_3_parloop_77321_runs[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77321_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77321_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77321_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77321_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_3_parloop_77321_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77321_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77321_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77321_iter[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77321_iter[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77321_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77321_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_3_parloop_77321_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77321_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77321_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_3_parloop_77321_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77321_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77321_total_iter),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77321_total_iter,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77321_total_iter /
                (ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_3_parloop_77321_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segscan_task_77316            ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segscan_task_77316_runs[i],
                    (long) ctx->futhark_mc_segscan_task_77316_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77316_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77316_runs[i] : 1),
                    (long) ctx->futhark_mc_segscan_task_77316_total_runtime[i],
                    (double) ctx->futhark_mc_segscan_task_77316_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77316_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segscan_task_77316_iter[i]),
                    (long) ctx->futhark_mc_segscan_task_77316_iter[i],
                    (long) ctx->futhark_mc_segscan_task_77316_iter[i] /
                    (ctx->futhark_mc_segscan_task_77316_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77316_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77325          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77325_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77325_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77325_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77325_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77325_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77325_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77325_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77325_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77325_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77325_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77325_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77325_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77325_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77325_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77325_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77325_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77325_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77325_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77325_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77325_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77325_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77325_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77325_total_iter /
                (ctx->futhark_mc_segmap_parloop_77325_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77325_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77325_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77325_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77323             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77323_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77323_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77323_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77323_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77323_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77323_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77323_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77323_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77323_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77323_iter[i] /
                    (ctx->futhark_mc_segmap_task_77323_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77323_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77329          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77329_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77329_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77329_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77329_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77329_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77329_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77329_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77329_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77329_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77329_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77329_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77329_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77329_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77329_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77329_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77329_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77329_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77329_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77329_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77329_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77329_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77329_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77329_total_iter /
                (ctx->futhark_mc_segmap_parloop_77329_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77329_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77329_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77329_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77327             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77327_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77327_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77327_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77327_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77327_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77327_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77327_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77327_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77327_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77327_iter[i] /
                    (ctx->futhark_mc_segmap_task_77327_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77327_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77333          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77333_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77333_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77333_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77333_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77333_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77333_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77333_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77333_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77333_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77333_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77333_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77333_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77333_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77333_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77333_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77333_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77333_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77333_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77333_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77333_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77333_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77333_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77333_total_iter /
                (ctx->futhark_mc_segmap_parloop_77333_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77333_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77333_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77333_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77331             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77331_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77331_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77331_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77331_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77331_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77331_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77331_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77331_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77331_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77331_iter[i] /
                    (ctx->futhark_mc_segmap_task_77331_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77331_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77337          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77337_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77337_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77337_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77337_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77337_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77337_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77337_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77337_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77337_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77337_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77337_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77337_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77337_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77337_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77337_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77337_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77337_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77337_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77337_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77337_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77337_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77337_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77337_total_iter /
                (ctx->futhark_mc_segmap_parloop_77337_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77337_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77337_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77337_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77351  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77351_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77351_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77351_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77351_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77351_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77351_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77351_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77351_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77351_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77351_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77351_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77351_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77351_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77351_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77351_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77351_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77351_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77351_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77351_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77351_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77351_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77346             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77346_runs[i],
                    (long) ctx->futhark_mc_segred_task_77346_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77346_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77346_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77346_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77346_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77346_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77346_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77346_iter[i],
                    (long) ctx->futhark_mc_segred_task_77346_iter[i] /
                    (ctx->futhark_mc_segred_task_77346_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77346_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77357  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77357_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77357_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77357_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77357_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77357_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77357_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77357_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77357_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77357_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77357_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77357_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77357_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77357_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77357_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77357_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77357_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77357_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77357_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77357_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77357_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77357_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77353             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77353_runs[i],
                    (long) ctx->futhark_mc_segred_task_77353_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77353_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77353_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77353_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77353_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77353_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77353_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77353_iter[i],
                    (long) ctx->futhark_mc_segred_task_77353_iter[i] /
                    (ctx->futhark_mc_segred_task_77353_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77353_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77342          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77342_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77342_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77342_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77342_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77342_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77342_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77342_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77342_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77342_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77342_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77342_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77342_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77342_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77342_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77342_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77342_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77342_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77342_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77342_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77342_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77342_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77342_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77342_total_iter /
                (ctx->futhark_mc_segmap_parloop_77342_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77342_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77342_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77342_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77335             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77335_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77335_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77335_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77335_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77335_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77335_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77335_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77335_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77335_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77335_iter[i] /
                    (ctx->futhark_mc_segmap_task_77335_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77335_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77340      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77340_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77340_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77340_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77340_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77340_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77340_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77340_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77340_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77340_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77340_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77340_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77340_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77307          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77307_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77307_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77307_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77307_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77307_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77307_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77307_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77307_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77307_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77307_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77307_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77307_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77307_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77307_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77307_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77307_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77307_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77307_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77307_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77307_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77307_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77307_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77307_total_iter /
                (ctx->futhark_mc_segmap_parloop_77307_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77307_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77307_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77307_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77293             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77293_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77293_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77293_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77293_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77293_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77293_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77293_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77293_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77293_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77293_iter[i] /
                    (ctx->futhark_mc_segmap_task_77293_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77293_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77305      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77305_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77305_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77305_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77305_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77305_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77305_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77305_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77305_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77305_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77305_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77305_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77305_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77361          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77361_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77361_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77361_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77361_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77361_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77361_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77361_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77361_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77361_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77361_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77361_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77361_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77361_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77361_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77361_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77361_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77361_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77361_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77361_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77361_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77361_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77361_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77361_total_iter /
                (ctx->futhark_mc_segmap_parloop_77361_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77361_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77361_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77361_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_1_parloop_77387    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_1_parloop_77387_runs[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77387_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77387_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77387_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77387_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_1_parloop_77387_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77387_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77387_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77387_iter[i],
                    (long) ctx->futhark_mc_scan_stage_1_parloop_77387_iter[i] /
                    (ctx->futhark_mc_scan_stage_1_parloop_77387_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_1_parloop_77387_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_1_parloop_77387_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77387_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77387_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_1_parloop_77387_total_total_runtime /
                (ctx->futhark_mc_scan_stage_1_parloop_77387_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_1_parloop_77387_total_iter),
                (long) ctx->futhark_mc_scan_stage_1_parloop_77387_total_iter,
                (long) ctx->futhark_mc_scan_stage_1_parloop_77387_total_iter /
                (ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_1_parloop_77387_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_scan_stage_3_parloop_77389    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_scan_stage_3_parloop_77389_runs[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77389_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77389_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77389_runs[i] : 1),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77389_total_runtime[i],
                    (double) ctx->futhark_mc_scan_stage_3_parloop_77389_total_runtime[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77389_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77389_iter[i]),
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77389_iter[i],
                    (long) ctx->futhark_mc_scan_stage_3_parloop_77389_iter[i] /
                    (ctx->futhark_mc_scan_stage_3_parloop_77389_runs[i] !=
                     0 ? ctx->futhark_mc_scan_stage_3_parloop_77389_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_scan_stage_3_parloop_77389_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77389_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs : 1),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77389_total_total_runtime,
                (double) ctx->futhark_mc_scan_stage_3_parloop_77389_total_total_runtime /
                (ctx->futhark_mc_scan_stage_3_parloop_77389_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_scan_stage_3_parloop_77389_total_iter),
                (long) ctx->futhark_mc_scan_stage_3_parloop_77389_total_iter,
                (long) ctx->futhark_mc_scan_stage_3_parloop_77389_total_iter /
                (ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs !=
                 0 ? ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_scan_stage_3_parloop_77389_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segscan_task_77384            ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segscan_task_77384_runs[i],
                    (long) ctx->futhark_mc_segscan_task_77384_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77384_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77384_runs[i] : 1),
                    (long) ctx->futhark_mc_segscan_task_77384_total_runtime[i],
                    (double) ctx->futhark_mc_segscan_task_77384_total_runtime[i] /
                    (ctx->futhark_mc_segscan_task_77384_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segscan_task_77384_iter[i]),
                    (long) ctx->futhark_mc_segscan_task_77384_iter[i],
                    (long) ctx->futhark_mc_segscan_task_77384_iter[i] /
                    (ctx->futhark_mc_segscan_task_77384_runs[i] !=
                     0 ? ctx->futhark_mc_segscan_task_77384_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77393          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77393_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77393_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77393_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77393_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77393_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77393_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77393_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77393_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77393_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77393_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77393_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77393_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77393_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77393_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77393_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77393_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77393_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77393_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77393_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77393_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77393_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77393_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77393_total_iter /
                (ctx->futhark_mc_segmap_parloop_77393_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77393_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77393_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77393_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77391             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77391_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77391_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77391_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77391_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77391_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77391_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77391_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77391_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77391_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77391_iter[i] /
                    (ctx->futhark_mc_segmap_task_77391_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77391_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77397          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77397_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77397_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77397_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77397_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77397_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77397_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77397_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77397_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77397_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77397_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77397_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77397_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77397_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77397_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77397_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77397_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77397_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77397_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77397_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77397_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77397_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77397_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77397_total_iter /
                (ctx->futhark_mc_segmap_parloop_77397_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77397_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77397_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77397_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77395             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77395_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77395_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77395_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77395_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77395_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77395_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77395_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77395_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77395_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77395_iter[i] /
                    (ctx->futhark_mc_segmap_task_77395_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77395_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77401          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77401_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77401_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77401_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77401_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77401_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77401_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77401_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77401_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77401_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77401_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77401_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77401_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77401_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77401_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77401_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77401_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77401_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77401_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77401_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77401_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77401_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77401_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77401_total_iter /
                (ctx->futhark_mc_segmap_parloop_77401_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77401_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77401_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77401_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77399             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77399_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77399_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77399_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77399_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77399_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77399_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77399_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77399_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77399_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77399_iter[i] /
                    (ctx->futhark_mc_segmap_task_77399_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77399_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77405          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77405_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77405_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77405_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77405_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77405_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77405_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77405_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77405_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77405_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77405_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77405_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77405_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77405_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77405_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77405_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77405_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77405_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77405_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77405_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77405_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77405_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77405_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77405_total_iter /
                (ctx->futhark_mc_segmap_parloop_77405_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77405_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77405_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77405_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77420          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77420_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77420_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77420_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77420_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77420_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77420_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77420_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77420_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77420_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77420_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77420_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77420_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77420_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77420_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77420_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77420_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77420_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77420_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77420_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77420_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77420_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77420_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77420_total_iter /
                (ctx->futhark_mc_segmap_parloop_77420_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77420_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77420_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77420_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77418             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77418_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77418_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77418_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77418_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77418_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77418_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77418_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77418_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77418_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77418_iter[i] /
                    (ctx->futhark_mc_segmap_task_77418_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77418_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77429  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77429_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77429_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77429_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77429_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77429_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77429_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77429_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77429_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77429_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77429_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77429_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77429_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77429_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77429_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77429_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77429_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77429_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77429_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77429_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77429_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77429_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77422             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77422_runs[i],
                    (long) ctx->futhark_mc_segred_task_77422_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77422_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77422_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77422_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77422_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77422_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77422_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77422_iter[i],
                    (long) ctx->futhark_mc_segred_task_77422_iter[i] /
                    (ctx->futhark_mc_segred_task_77422_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77422_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_stage_1_parloop_77435  ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_stage_1_parloop_77435_runs[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77435_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77435_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77435_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77435_total_runtime[i],
                    (double) ctx->futhark_mc_segred_stage_1_parloop_77435_total_runtime[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77435_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77435_iter[i]),
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77435_iter[i],
                    (long) ctx->futhark_mc_segred_stage_1_parloop_77435_iter[i] /
                    (ctx->futhark_mc_segred_stage_1_parloop_77435_runs[i] !=
                     0 ? ctx->futhark_mc_segred_stage_1_parloop_77435_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segred_stage_1_parloop_77435_total ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77435_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs : 1),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77435_total_total_runtime,
                (double) ctx->futhark_mc_segred_stage_1_parloop_77435_total_total_runtime /
                (ctx->futhark_mc_segred_stage_1_parloop_77435_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segred_stage_1_parloop_77435_total_iter),
                (long) ctx->futhark_mc_segred_stage_1_parloop_77435_total_iter,
                (long) ctx->futhark_mc_segred_stage_1_parloop_77435_total_iter /
                (ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs !=
                 0 ? ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segred_stage_1_parloop_77435_total_total_runtime;
        ctx->total_runs +=
            ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segred_task_77431             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segred_task_77431_runs[i],
                    (long) ctx->futhark_mc_segred_task_77431_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77431_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77431_runs[i] : 1),
                    (long) ctx->futhark_mc_segred_task_77431_total_runtime[i],
                    (double) ctx->futhark_mc_segred_task_77431_total_runtime[i] /
                    (ctx->futhark_mc_segred_task_77431_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segred_task_77431_iter[i]),
                    (long) ctx->futhark_mc_segred_task_77431_iter[i],
                    (long) ctx->futhark_mc_segred_task_77431_iter[i] /
                    (ctx->futhark_mc_segred_task_77431_runs[i] !=
                     0 ? ctx->futhark_mc_segred_task_77431_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77412          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77412_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77412_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77412_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77412_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77412_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77412_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77412_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77412_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77412_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77412_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77412_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77412_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77412_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77412_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77412_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77412_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77412_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77412_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77412_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77412_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77412_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77412_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77412_total_iter /
                (ctx->futhark_mc_segmap_parloop_77412_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77412_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77412_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77412_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77403             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77403_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77403_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77403_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77403_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77403_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77403_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77403_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77403_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77403_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77403_iter[i] /
                    (ctx->futhark_mc_segmap_task_77403_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77403_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77410      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77410_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77410_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77410_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77410_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77410_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77410_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77410_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77410_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77410_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77410_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77410_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77410_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77375          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77375_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77375_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77375_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77375_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77375_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77375_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77375_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77375_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77375_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77375_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77375_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77375_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77375_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77375_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77375_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77375_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77375_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77375_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77375_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77375_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77375_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77375_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77375_total_iter /
                (ctx->futhark_mc_segmap_parloop_77375_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77375_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77375_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77375_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77359             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77359_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77359_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77359_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77359_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77359_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77359_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77359_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77359_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77359_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77359_iter[i] /
                    (ctx->futhark_mc_segmap_task_77359_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77359_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77373      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77373_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77373_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77373_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77373_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77373_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77373_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77373_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77373_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77373_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77373_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77373_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77373_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77439          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77439_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77439_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77439_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77439_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77439_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77439_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77439_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77439_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77439_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77439_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77439_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77439_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77439_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77439_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77439_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77439_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77439_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77439_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77439_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77439_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77439_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77439_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77439_total_iter /
                (ctx->futhark_mc_segmap_parloop_77439_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77439_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77439_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77439_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77448          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77448_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77448_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77448_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77448_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77448_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77448_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77448_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77448_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77448_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77448_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77448_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77448_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77448_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77448_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77448_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77448_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77448_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77448_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77448_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77448_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77448_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77448_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77448_total_iter /
                (ctx->futhark_mc_segmap_parloop_77448_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77448_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77448_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77448_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77446             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77446_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77446_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77446_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77446_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77446_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77446_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77446_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77446_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77446_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77446_iter[i] /
                    (ctx->futhark_mc_segmap_task_77446_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77446_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_parloop_77443          ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_parloop_77443_runs[i],
                    (long) ctx->futhark_mc_segmap_parloop_77443_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77443_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77443_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_parloop_77443_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_parloop_77443_total_runtime[i] /
                    (ctx->futhark_mc_segmap_parloop_77443_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77443_iter[i]),
                    (long) ctx->futhark_mc_segmap_parloop_77443_iter[i],
                    (long) ctx->futhark_mc_segmap_parloop_77443_iter[i] /
                    (ctx->futhark_mc_segmap_parloop_77443_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_parloop_77443_runs[i] : 1));
        fprintf(ctx->log,
                "         futhark_mc_segmap_parloop_77443_total    ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                ctx->futhark_mc_segmap_parloop_77443_total_runs,
                (long) ctx->futhark_mc_segmap_parloop_77443_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77443_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77443_total_runs : 1),
                (long) ctx->futhark_mc_segmap_parloop_77443_total_total_runtime,
                (double) ctx->futhark_mc_segmap_parloop_77443_total_total_runtime /
                (ctx->futhark_mc_segmap_parloop_77443_total_iter ==
                 0 ? 1 : (double) ctx->futhark_mc_segmap_parloop_77443_total_iter),
                (long) ctx->futhark_mc_segmap_parloop_77443_total_iter,
                (long) ctx->futhark_mc_segmap_parloop_77443_total_iter /
                (ctx->futhark_mc_segmap_parloop_77443_total_runs !=
                 0 ? ctx->futhark_mc_segmap_parloop_77443_total_runs : 1));
        ctx->total_runtime +=
            ctx->futhark_mc_segmap_parloop_77443_total_total_runtime;
        ctx->total_runs += ctx->futhark_mc_segmap_parloop_77443_total_runs;
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_task_77437             ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_task_77437_runs[i],
                    (long) ctx->futhark_mc_segmap_task_77437_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77437_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77437_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_task_77437_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_task_77437_total_runtime[i] /
                    (ctx->futhark_mc_segmap_task_77437_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_task_77437_iter[i]),
                    (long) ctx->futhark_mc_segmap_task_77437_iter[i],
                    (long) ctx->futhark_mc_segmap_task_77437_iter[i] /
                    (ctx->futhark_mc_segmap_task_77437_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_task_77437_runs[i] : 1));
        for (int i = 0; i < ctx->scheduler.num_threads; i++)
            fprintf(ctx->log,
                    "tid %2d - futhark_mc_segmap_nested_task_77441      ran %10d times; avg: %10ldus; total: %10ldus; time pr. iter %9.6f; iters %9ld; avg %ld\n",
                    i, ctx->futhark_mc_segmap_nested_task_77441_runs[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77441_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77441_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77441_runs[i] : 1),
                    (long) ctx->futhark_mc_segmap_nested_task_77441_total_runtime[i],
                    (double) ctx->futhark_mc_segmap_nested_task_77441_total_runtime[i] /
                    (ctx->futhark_mc_segmap_nested_task_77441_iter[i] ==
                     0 ? 1 : (double) ctx->futhark_mc_segmap_nested_task_77441_iter[i]),
                    (long) ctx->futhark_mc_segmap_nested_task_77441_iter[i],
                    (long) ctx->futhark_mc_segmap_nested_task_77441_iter[i] /
                    (ctx->futhark_mc_segmap_nested_task_77441_runs[i] !=
                     0 ? ctx->futhark_mc_segmap_nested_task_77441_runs[i] : 1));
    }
    return builder.str;
}
char *futhark_context_get_error(struct futhark_context *ctx)
{
    char *error = ctx->error;
    
    ctx->error = NULL;
    return error;
}
void futhark_context_set_logging_file(struct futhark_context *ctx, FILE *f)
{
    ctx->log = f;
}
void futhark_context_pause_profiling(struct futhark_context *ctx)
{
    ctx->profiling_paused = 1;
}
void futhark_context_unpause_profiling(struct futhark_context *ctx)
{
    ctx->profiling_paused = 0;
}
int futhark_context_clear_caches(struct futhark_context *ctx)
{
    lock_lock(&ctx->lock);
    worker_local = &ctx->scheduler.workers[0];
    ctx->peak_mem_usage_default = 0;
    lock_unlock(&ctx->lock);
    return ctx->error != NULL;
}

static int futrts_entry_main(struct futhark_context *ctx,
                             struct memblock *mem_out_p_77056,
                             struct memblock Y_mem_70603, int64_t m_65377,
                             int64_t n_65378, int64_t q_65380,
                             int64_t degree_65381, int64_t jump_65382,
                             int64_t jump_threshold_65383,
                             int64_t q_threshold_65384);

static int init_constants(struct futhark_context *ctx)
{
    (void) ctx;
    
    int err = 0;
    
    
  cleanup:
    return err;
}
static int free_constants(struct futhark_context *ctx)
{
    (void) ctx;
    return 0;
}
struct futhark_mc_task_77057 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70609;
    int64_t free_bytes_70621;
    int64_t free_bytes_70624;
    unsigned char *free_mem_70719;
};
struct futhark_mc_segmap_parloop_struct_77059 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70609;
    int64_t free_bytes_70621;
    int64_t free_bytes_70624;
    unsigned char *free_mem_70719;
};
static int futhark_mc_segmap_parloop_77060(void *args, int64_t start,
                                           int64_t end, int flat_tid_66726,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77059
    *futhark_mc_segmap_parloop_struct_77059 =
    (struct futhark_mc_segmap_parloop_struct_77059 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77059->ctx;
    uint64_t futhark_mc_segmap_parloop_77060_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77060_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77059->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77059->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77059->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77059->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77059->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77059->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77059->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77059->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77059->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77059->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77059->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70609 =
            futhark_mc_segmap_parloop_struct_77059->free_bytes_70609;
    int64_t bytes_70621 =
            futhark_mc_segmap_parloop_struct_77059->free_bytes_70621;
    int64_t bytes_70624 =
            futhark_mc_segmap_parloop_struct_77059->free_bytes_70624;
    struct memblock mem_70719 = {.desc ="mem_70719", .mem =
                                 futhark_mc_segmap_parloop_struct_77059->free_mem_70719,
                                 .size =0, .references =NULL};
    size_t mem_70628_cached_sizze_77061 = 0;
    unsigned char *mem_70628 = NULL;
    size_t mem_70643_cached_sizze_77062 = 0;
    unsigned char *mem_70643 = NULL;
    size_t mem_70646_cached_sizze_77063 = 0;
    unsigned char *mem_70646 = NULL;
    size_t mem_70673_cached_sizze_77064 = 0;
    unsigned char *mem_70673 = NULL;
    size_t mem_70688_cached_sizze_77065 = 0;
    unsigned char *mem_70688 = NULL;
    size_t mem_70703_cached_sizze_77066 = 0;
    unsigned char *mem_70703 = NULL;
    int64_t iterations = end - start;
    int64_t iter_71656 = start;
    
    if (mem_70628_cached_sizze_77061 < (size_t) bytes_70609) {
        mem_70628 = realloc(mem_70628, bytes_70609);
        mem_70628_cached_sizze_77061 = bytes_70609;
    }
    if (mem_70643_cached_sizze_77062 < (size_t) bytes_70609) {
        mem_70643 = realloc(mem_70643, bytes_70609);
        mem_70643_cached_sizze_77062 = bytes_70609;
    }
    if (mem_70646_cached_sizze_77063 < (size_t) bytes_70609) {
        mem_70646 = realloc(mem_70646, bytes_70609);
        mem_70646_cached_sizze_77063 = bytes_70609;
    }
    if (mem_70673_cached_sizze_77064 < (size_t) bytes_70609) {
        mem_70673 = realloc(mem_70673, bytes_70609);
        mem_70673_cached_sizze_77064 = bytes_70609;
    }
    if (mem_70688_cached_sizze_77065 < (size_t) bytes_70621) {
        mem_70688 = realloc(mem_70688, bytes_70621);
        mem_70688_cached_sizze_77065 = bytes_70621;
    }
    if (mem_70703_cached_sizze_77066 < (size_t) bytes_70624) {
        mem_70703 = realloc(mem_70703, bytes_70624);
        mem_70703_cached_sizze_77066 = bytes_70624;
    }
    for (; iter_71656 < end; iter_71656++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_71823 = m_65377;
        int64_t gtid_66727 = iter_71656;
        int64_t remnant_71824 = iter_71656 - gtid_66727;
        int64_t discard_70218;
        int64_t scanacc_71658 = (int64_t) 0;
        
        for (int64_t i_71657 = 0; i_71657 < n_65378; i_71657++) {
            double x_71660;
            
            x_71660 = ((double *) Y_mem_70603.mem)[gtid_66727 * n_65378 +
                                                   i_71657];
            
            bool isnan_res_71661;
            
            isnan_res_71661 = futrts_isnan64(x_71660);
            
            bool defunc_0_p_res_71662 = !isnan_res_71661;
            int64_t defunc_0_f_res_71663 = btoi_bool_i64(defunc_0_p_res_71662);
            int64_t defunc_1_op_res_71664 = add64(defunc_0_f_res_71663,
                                                  scanacc_71658);
            
            ((int64_t *) mem_70628)[i_71657] = defunc_1_op_res_71664;
            
            int64_t scanacc_tmp_71825 = defunc_1_op_res_71664;
            
            scanacc_71658 = scanacc_tmp_71825;
        }
        discard_70218 = scanacc_71658;
        
        int64_t last_res_65427;
        
        last_res_65427 = ((int64_t *) mem_70628)[i_65392];
        for (int64_t i_71827 = 0; i_71827 < n_65378; i_71827++) {
            ((double *) mem_70643)[i_71827] = 0.0;
        }
        for (int64_t i_71828 = 0; i_71828 < n_65378; i_71828++) {
            ((int64_t *) mem_70646)[i_71828] = (int64_t) -1;
        }
        for (int64_t write_iter_71666 = 0; write_iter_71666 < n_65378;
             write_iter_71666++) {
            double write_iv_71669;
            
            write_iv_71669 = ((double *) Y_mem_70603.mem)[gtid_66727 * n_65378 +
                                                          write_iter_71666];
            
            bool isnan_res_71670;
            
            isnan_res_71670 = futrts_isnan64(write_iv_71669);
            
            bool defunc_0_p_res_71671 = !isnan_res_71670;
            int64_t defunc_1_f_res_71672;
            
            if (defunc_0_p_res_71671) {
                int64_t write_iv_71673;
                
                write_iv_71673 = ((int64_t *) mem_70628)[write_iter_71666];
                
                int64_t defunc_1_f_res_t_res_71674 = sub64(write_iv_71673,
                                                           (int64_t) 1);
                
                defunc_1_f_res_71672 = defunc_1_f_res_t_res_71674;
            } else {
                defunc_1_f_res_71672 = (int64_t) -1;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_71672) &&
                slt64(defunc_1_f_res_71672, n_65378)) {
                ((int64_t *) mem_70646)[defunc_1_f_res_71672] =
                    write_iter_71666;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_71672) &&
                slt64(defunc_1_f_res_71672, n_65378)) {
                if ((int64_t) 8 > 0)
                    memmove(mem_70643 + defunc_1_f_res_71672 * (int64_t) 8,
                            Y_mem_70603.mem + (gtid_66727 * n_65378 +
                                               write_iter_71666) * (int64_t) 8,
                            (int64_t) 8);
            }
        }
        for (int64_t i_71678 = 0; i_71678 < n_65378; i_71678++) {
            int64_t x_71680;
            
            x_71680 = ((int64_t *) mem_70646)[i_71678];
            
            int64_t defunc_0_f_res_71681 = add64((int64_t) 1, x_71680);
            
            ((int64_t *) mem_70673)[i_71678] = defunc_0_f_res_71681;
        }
        
        int64_t min_arg_65442 = sub64(last_res_65427, (int64_t) 1);
        int64_t min_arg_65443 = sub64(last_res_65427, min_res_65398);
        int64_t min_res_65444 = smin64(q_65380, last_res_65427);
        double i64_res_65445 = sitofp_i64_f64(last_res_65427);
        double x_65446 = i64_res_65404 - i64_res_65445;
        double max_arg_65447 = x_65446 / 2.0;
        double max_res_65448 = fmax64(0.0, max_arg_65447);
        
        for (int64_t i_71683 = 0; i_71683 < q_65380; i_71683++) {
            bool cond_71685 = sle64(last_res_65427, i_71683);
            double defunc_0_f_res_71686;
            
            if (cond_71685) {
                defunc_0_f_res_71686 = 0.0;
            } else {
                defunc_0_f_res_71686 = 1.0;
            }
            ((double *) mem_70688)[i_71683] = defunc_0_f_res_71686;
        }
        for (int64_t i_71688 = 0; i_71688 < n_m_65386; i_71688++) {
            int64_t min_arg_71690 = mul64(jump_65382, i_71688);
            int64_t min_res_71691 = smin64(i_65392, min_arg_71690);
            int64_t defunc_0_g_res_71692 = add64((int64_t) 1, min_res_71691);
            bool init_idx_71693;
            int64_t init_idx_71694;
            int64_t init_idx_71695;
            bool loop_while_71696;
            int64_t low_71697;
            int64_t high_71698;
            
            loop_while_71696 = x_65393;
            low_71697 = (int64_t) 0;
            high_71698 = i_65392;
            while (loop_while_71696) {
                int64_t x_71699 = add64(low_71697, high_71698);
                int64_t mid_71700 = sdiv64(x_71699, (int64_t) 2);
                bool x_71701 = sle64((int64_t) 0, mid_71700);
                bool y_71702 = slt64(mid_71700, n_65378);
                bool bounds_check_71703 = x_71701 && y_71702;
                bool index_certs_71704;
                
                if (!bounds_check_71703) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) mid_71700,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t mid_id_71705;
                
                mid_id_71705 = ((int64_t *) mem_70673)[mid_71700];
                
                bool cond_71706 = slt64(mid_id_71705, (int64_t) 0);
                int64_t mid_idx_71707;
                
                if (cond_71706) {
                    mid_idx_71707 = (int64_t) 9223372036854775807;
                } else {
                    mid_idx_71707 = mid_id_71705;
                }
                
                bool cond_71708 = sle64(defunc_0_g_res_71692, mid_idx_71707);
                int64_t loopres_71709;
                int64_t loopres_71710;
                
                if (cond_71708) {
                    int64_t loopres_t_res_71711 = sub64(mid_71700, (int64_t) 1);
                    
                    loopres_71709 = low_71697;
                    loopres_71710 = loopres_t_res_71711;
                } else {
                    int64_t loopres_f_res_71712 = add64((int64_t) 1, mid_71700);
                    
                    loopres_71709 = loopres_f_res_71712;
                    loopres_71710 = high_71698;
                }
                
                bool loop_cond_71713 = sle64(loopres_71709, loopres_71710);
                bool loop_while_tmp_71834 = loop_cond_71713;
                int64_t low_tmp_71835 = loopres_71709;
                int64_t high_tmp_71836 = loopres_71710;
                
                loop_while_71696 = loop_while_tmp_71834;
                low_71697 = low_tmp_71835;
                high_71698 = high_tmp_71836;
            }
            init_idx_71693 = loop_while_71696;
            init_idx_71694 = low_71697;
            init_idx_71695 = high_71698;
            
            bool idx_71714;
            int64_t idx_71715;
            int64_t idx_71716;
            int64_t idx_71717;
            bool loop_while_71718;
            int64_t l_idx_71719;
            int64_t r_idx_71720;
            int64_t span_71721;
            
            loop_while_71718 = loop_cond_65403;
            l_idx_71719 = init_idx_71694;
            r_idx_71720 = init_idx_71694;
            span_71721 = (int64_t) 1;
            while (loop_while_71718) {
                int64_t max_arg_71722 = sub64(l_idx_71719, (int64_t) 1);
                int64_t max_res_71723 = smax64((int64_t) 0, max_arg_71722);
                int64_t min_arg_71724 = add64((int64_t) 1, r_idx_71720);
                int64_t min_res_71725 = smin64(min_arg_65442, min_arg_71724);
                bool x_71726 = sle64((int64_t) 0, max_res_71723);
                bool y_71727 = slt64(max_res_71723, n_65378);
                bool bounds_check_71728 = x_71726 && y_71727;
                bool index_certs_71729;
                
                if (!bounds_check_71728) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) max_res_71723,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_71730;
                
                x_71730 = ((int64_t *) mem_70673)[max_res_71723];
                
                int64_t abs_arg_71731 = sub64(x_71730, defunc_0_g_res_71692);
                int64_t abs_res_71732 = abs64(abs_arg_71731);
                bool x_71733 = sle64((int64_t) 0, min_res_71725);
                bool y_71734 = slt64(min_res_71725, n_65378);
                bool bounds_check_71735 = x_71733 && y_71734;
                bool index_certs_71736;
                
                if (!bounds_check_71735) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) min_res_71725,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_71737;
                
                x_71737 = ((int64_t *) mem_70673)[min_res_71725];
                
                int64_t abs_arg_71738 = sub64(x_71737, defunc_0_g_res_71692);
                int64_t abs_res_71739 = abs64(abs_arg_71738);
                bool cond_71740 = max_res_71723 == l_idx_71719;
                int64_t loopres_71741;
                int64_t loopres_71742;
                int64_t loopres_71743;
                
                if (cond_71740) {
                    loopres_71741 = l_idx_71719;
                    loopres_71742 = r_idx_71720;
                    loopres_71743 = min_res_65398;
                } else {
                    bool cond_71744 = slt64(abs_res_71732, abs_res_71739);
                    bool cond_f_res_71745 = min_res_71725 == r_idx_71720;
                    bool x_71746 = !cond_71744;
                    bool y_71747 = cond_f_res_71745 && x_71746;
                    bool cond_71748 = cond_71744 || y_71747;
                    int64_t loopres_f_res_71749;
                    
                    if (cond_71748) {
                        loopres_f_res_71749 = max_res_71723;
                    } else {
                        loopres_f_res_71749 = l_idx_71719;
                    }
                    
                    int64_t loopres_f_res_71750;
                    
                    if (cond_71748) {
                        loopres_f_res_71750 = r_idx_71720;
                    } else {
                        loopres_f_res_71750 = min_res_71725;
                    }
                    
                    int64_t loopres_f_res_71751;
                    
                    if (cond_71748) {
                        int64_t loopres_f_res_t_res_71752 = add64((int64_t) 1,
                                                                  span_71721);
                        
                        loopres_f_res_71751 = loopres_f_res_t_res_71752;
                    } else {
                        int64_t loopres_f_res_f_res_71753 = add64((int64_t) 1,
                                                                  span_71721);
                        
                        loopres_f_res_71751 = loopres_f_res_f_res_71753;
                    }
                    loopres_71741 = loopres_f_res_71749;
                    loopres_71742 = loopres_f_res_71750;
                    loopres_71743 = loopres_f_res_71751;
                }
                
                bool loop_cond_71754 = slt64(loopres_71743, min_res_65398);
                bool loop_while_tmp_71837 = loop_cond_71754;
                int64_t l_idx_tmp_71838 = loopres_71741;
                int64_t r_idx_tmp_71839 = loopres_71742;
                int64_t span_tmp_71840 = loopres_71743;
                
                loop_while_71718 = loop_while_tmp_71837;
                l_idx_71719 = l_idx_tmp_71838;
                r_idx_71720 = r_idx_tmp_71839;
                span_71721 = span_tmp_71840;
            }
            idx_71714 = loop_while_71718;
            idx_71715 = l_idx_71719;
            idx_71716 = r_idx_71720;
            idx_71717 = span_71721;
            
            int64_t min_res_71755 = smin64(min_arg_65443, idx_71715);
            int64_t max_res_71756 = smax64((int64_t) 0, min_res_71755);
            int64_t x_71757 = add64(min_res_65444, max_res_71756);
            int64_t r_71758 = sub64(x_71757, (int64_t) 1);
            bool x_71759 = sle64((int64_t) 0, r_71758);
            bool y_71760 = slt64(r_71758, n_65378);
            bool bounds_check_71761 = x_71759 && y_71760;
            bool index_certs_71762;
            
            if (!bounds_check_71761) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) r_71758,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_71763;
            
            x_71763 = ((int64_t *) mem_70646)[r_71758];
            
            int64_t abs_arg_71764 = sub64(x_71763, min_res_71691);
            int64_t abs_res_71765 = abs64(abs_arg_71764);
            bool x_71766 = sle64((int64_t) 0, max_res_71756);
            bool y_71767 = slt64(max_res_71756, n_65378);
            bool bounds_check_71768 = x_71766 && y_71767;
            bool index_certs_71769;
            
            if (!bounds_check_71768) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_71756,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_71770;
            
            x_71770 = ((int64_t *) mem_70646)[max_res_71756];
            
            int64_t abs_arg_71771 = sub64(x_71770, min_res_71691);
            int64_t abs_res_71772 = abs64(abs_arg_71771);
            int64_t max_res_71773 = smax64(abs_res_71765, abs_res_71772);
            double defunc_0_f_res_71774 = sitofp_i64_f64(max_res_71773);
            double defunc_1_f_res_71775 = max_res_65448 + defunc_0_f_res_71774;
            double defunc_2_reduce_res_71776;
            double redout_71778 = 0.0;
            
            for (int64_t i_71777 = 0; i_71777 < q_65380; i_71777++) {
                double x_71779;
                
                x_71779 = ((double *) mem_70688)[i_71777];
                
                bool cond_71780 = sle64(last_res_65427, i_71777);
                int64_t defunc_0_f_res_71781;
                
                if (cond_71780) {
                    defunc_0_f_res_71781 = (int64_t) 0;
                } else {
                    int64_t i_71782 = add64(max_res_71756, i_71777);
                    int64_t defunc_0_add_arg_71783;
                    
                    defunc_0_add_arg_71783 = ((int64_t *) mem_70646)[i_71782];
                    
                    int64_t defunc_1_add_res_71784 = add64((int64_t) 1,
                                                           defunc_0_add_arg_71783);
                    
                    defunc_0_f_res_71781 = defunc_1_add_res_71784;
                }
                
                int64_t binop_p_71785 = sub64(defunc_0_f_res_71781,
                                              min_res_71691);
                double defunc_0_f_res_71786 = sitofp_i64_f64(binop_p_71785);
                double abs_res_71787 = fabs(defunc_0_f_res_71786);
                double tmp1_71788 = abs_res_71787 / defunc_1_f_res_71775;
                double x_71789 = tmp1_71788 * tmp1_71788;
                double y_71790 = tmp1_71788 * x_71789;
                double tmp2_71791 = 1.0 - y_71790;
                double x_71792 = tmp2_71791 * tmp2_71791;
                double tmp3_71793 = tmp2_71791 * x_71792;
                double w_j_71794 = x_71779 * tmp3_71793;
                double defunc_1_op_res_71795 = w_j_71794 + redout_71778;
                double redout_tmp_71841 = defunc_1_op_res_71795;
                
                redout_71778 = redout_tmp_71841;
            }
            defunc_2_reduce_res_71776 = redout_71778;
            
            double a0_71796 = 1.0 / defunc_2_reduce_res_71776;
            double defunc_2_reduce_res_71797;
            double redout_71799 = 0.0;
            
            for (int64_t i_71798 = 0; i_71798 < q_65380; i_71798++) {
                double x_71800;
                
                x_71800 = ((double *) mem_70688)[i_71798];
                
                bool cond_71801 = sle64(last_res_65427, i_71798);
                int64_t defunc_0_f_res_71802;
                
                if (cond_71801) {
                    defunc_0_f_res_71802 = (int64_t) 0;
                } else {
                    int64_t i_71803 = add64(max_res_71756, i_71798);
                    int64_t defunc_0_add_arg_71804;
                    
                    defunc_0_add_arg_71804 = ((int64_t *) mem_70646)[i_71803];
                    
                    int64_t defunc_1_add_res_71805 = add64((int64_t) 1,
                                                           defunc_0_add_arg_71804);
                    
                    defunc_0_f_res_71802 = defunc_1_add_res_71805;
                }
                
                int64_t binop_p_71806 = sub64(defunc_0_f_res_71802,
                                              min_res_71691);
                double defunc_0_f_res_71807 = sitofp_i64_f64(binop_p_71806);
                double abs_res_71808 = fabs(defunc_0_f_res_71807);
                double tmp1_71809 = abs_res_71808 / defunc_1_f_res_71775;
                double x_71810 = tmp1_71809 * tmp1_71809;
                double y_71811 = tmp1_71809 * x_71810;
                double tmp2_71812 = 1.0 - y_71811;
                double x_71813 = tmp2_71812 * tmp2_71812;
                double tmp3_71814 = tmp2_71812 * x_71813;
                double tmp4_71815 = x_71800 * tmp3_71814;
                double defunc_0_f_res_71816;
                
                if (cond_71801) {
                    defunc_0_f_res_71816 = 0.0;
                } else {
                    int64_t i_71817 = add64(max_res_71756, i_71798);
                    double defunc_0_add_arg_71818;
                    
                    defunc_0_add_arg_71818 = ((double *) mem_70643)[i_71817];
                    defunc_0_f_res_71816 = defunc_0_add_arg_71818;
                }
                
                double x_71819 = a0_71796 * tmp4_71815;
                double defunc_9_fit_fun_res_71820 = defunc_0_f_res_71816 *
                       x_71819;
                double defunc_1_op_res_71821 = defunc_9_fit_fun_res_71820 +
                       redout_71799;
                double redout_tmp_71842 = defunc_1_op_res_71821;
                
                redout_71799 = redout_tmp_71842;
            }
            defunc_2_reduce_res_71797 = redout_71799;
            ((double *) mem_70703)[i_71688] = defunc_2_reduce_res_71797;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70719.mem + gtid_66727 * n_m_65386 * (int64_t) 8,
                    mem_70703 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70628);
    free(mem_70643);
    free(mem_70646);
    free(mem_70673);
    free(mem_70688);
    free(mem_70703);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77060_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77060_end -
                 futhark_mc_segmap_parloop_77060_start;
        
        ctx->futhark_mc_segmap_parloop_77060_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77060_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77060_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77058(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_66726 = tid;
    int num_tasks_71655 = info.nsubtasks;
    struct futhark_mc_task_77057 *futhark_mc_task_77057 =
                                 (struct futhark_mc_task_77057 *) args;
    struct futhark_context *ctx = futhark_mc_task_77057->ctx;
    uint64_t futhark_mc_segmap_task_77058_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77058_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77057->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77057->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77057->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77057->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77057->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77057->free_i_65392;
    bool x_65393 = futhark_mc_task_77057->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77057->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77057->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77057->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77057->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70609 = futhark_mc_task_77057->free_bytes_70609;
    int64_t bytes_70621 = futhark_mc_task_77057->free_bytes_70621;
    int64_t bytes_70624 = futhark_mc_task_77057->free_bytes_70624;
    struct memblock mem_70719 = {.desc ="mem_70719", .mem =
                                 futhark_mc_task_77057->free_mem_70719, .size =
                                 0, .references =NULL};
    int64_t iter_71656;
    struct futhark_mc_segmap_parloop_struct_77059
    futhark_mc_segmap_parloop_struct_77059;
    
    futhark_mc_segmap_parloop_struct_77059.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77059.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77059.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77059.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77059.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77059.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77059.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77059.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77059.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77059.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77059.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77059.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77059.free_bytes_70609 = bytes_70609;
    futhark_mc_segmap_parloop_struct_77059.free_bytes_70621 = bytes_70621;
    futhark_mc_segmap_parloop_struct_77059.free_bytes_70624 = bytes_70624;
    futhark_mc_segmap_parloop_struct_77059.free_mem_70719 = mem_70719.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77060_task;
    
    futhark_mc_segmap_parloop_77060_task.name =
        "futhark_mc_segmap_parloop_77060";
    futhark_mc_segmap_parloop_77060_task.fn = futhark_mc_segmap_parloop_77060;
    futhark_mc_segmap_parloop_77060_task.args =
        &futhark_mc_segmap_parloop_struct_77059;
    futhark_mc_segmap_parloop_77060_task.iterations = iterations;
    futhark_mc_segmap_parloop_77060_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77060_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77060_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77060_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77060_task);
    
    if (futhark_mc_segmap_parloop_77060_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77060_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77060_total_end -
                 futhark_mc_segmap_parloop_77060_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77060_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77060_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77060_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77058_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77058_end -
                 futhark_mc_segmap_task_77058_start;
        
        ctx->futhark_mc_segmap_task_77058_runs[tid]++;
        ctx->futhark_mc_segmap_task_77058_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77058_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77068 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70609;
    int64_t free_bytes_70621;
    int64_t free_bytes_70624;
    unsigned char *free_mem_70719;
};
struct futhark_mc_task_77076 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_66888;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70610;
};
struct futhark_mc_scan_stage_1_parloop_struct_77079 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_66888;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70610;
};
static int futhark_mc_scan_stage_1_parloop_77080(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_71844, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_1_parloop_struct_77079
    *futhark_mc_scan_stage_1_parloop_struct_77079 =
    (struct futhark_mc_scan_stage_1_parloop_struct_77079 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_1_parloop_struct_77079->ctx;
    uint64_t futhark_mc_scan_stage_1_parloop_77080_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77080_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_1_parloop_struct_77079->free_n_65378;
    int64_t gtid_66888 =
            futhark_mc_scan_stage_1_parloop_struct_77079->free_gtid_66888;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_1_parloop_struct_77079->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70610 = {.desc ="mem_70610", .mem =
                                 futhark_mc_scan_stage_1_parloop_struct_77079->free_mem_70610,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72144 = start;
    int64_t x_71846;
    int64_t x_71847;
    
    x_71846 = (int64_t) 0;
    for (; iter_72144 < end; iter_72144++) {
        int64_t gtid_71845 = iter_72144;
        
        // stage 1 scan body
        {
            double x_71849;
            
            x_71849 = ((double *) Y_mem_70603.mem)[gtid_66888 * n_65378 +
                                                   gtid_71845];
            
            bool isnan_res_71850;
            
            isnan_res_71850 = futrts_isnan64(x_71849);
            
            bool defunc_0_p_res_71851 = !isnan_res_71850;
            int64_t defunc_0_f_res_71852 = btoi_bool_i64(defunc_0_p_res_71851);
            
            // write mapped values results to memory
            { }
            x_71846 = x_71846;
            // Read next values
            {
                x_71847 = defunc_0_f_res_71852;
            }
            
            int64_t defunc_1_op_res_71848 = add64(x_71846, x_71847);
            
            ((int64_t *) mem_70610.mem)[gtid_71845] = defunc_1_op_res_71848;
            x_71846 = defunc_1_op_res_71848;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77080_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77080_end -
                 futhark_mc_scan_stage_1_parloop_77080_start;
        
        ctx->futhark_mc_scan_stage_1_parloop_77080_runs[tid]++;
        ctx->futhark_mc_scan_stage_1_parloop_77080_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_1_parloop_77080_iter[tid] += iterations;
    }
    return err;
}
struct futhark_mc_scan_stage_3_parloop_struct_77081 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_66888;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70610;
};
static int futhark_mc_scan_stage_3_parloop_77082(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_71844, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_3_parloop_struct_77081
    *futhark_mc_scan_stage_3_parloop_struct_77081 =
    (struct futhark_mc_scan_stage_3_parloop_struct_77081 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_3_parloop_struct_77081->ctx;
    uint64_t futhark_mc_scan_stage_3_parloop_77082_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_3_parloop_77082_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_3_parloop_struct_77081->free_n_65378;
    int64_t gtid_66888 =
            futhark_mc_scan_stage_3_parloop_struct_77081->free_gtid_66888;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_3_parloop_struct_77081->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70610 = {.desc ="mem_70610", .mem =
                                 futhark_mc_scan_stage_3_parloop_struct_77081->free_mem_70610,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72156 = start;
    int64_t x_72153;
    int64_t x_72154;
    
    if (iter_72156 == (int64_t) 0) {
        x_72153 = (int64_t) 0;
    } else {
        x_72153 = ((int64_t *) mem_70610.mem)[iter_72156 - (int64_t) 1];
    }
    for (; iter_72156 < end; iter_72156++) {
        int64_t gtid_71845 = iter_72156;
        
        // stage 3 scan body
        {
            double x_71849;
            
            x_71849 = ((double *) Y_mem_70603.mem)[gtid_66888 * n_65378 +
                                                   gtid_71845];
            
            bool isnan_res_71850;
            
            isnan_res_71850 = futrts_isnan64(x_71849);
            
            bool defunc_0_p_res_71851 = !isnan_res_71850;
            int64_t defunc_0_f_res_71852 = btoi_bool_i64(defunc_0_p_res_71851);
            
            x_72153 = x_72153;
            x_72154 = defunc_0_f_res_71852;
            
            int64_t defunc_1_op_res_72155 = add64(x_72153, x_72154);
            
            ((int64_t *) mem_70610.mem)[gtid_71845] = defunc_1_op_res_72155;
            x_72153 = defunc_1_op_res_72155;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_3_parloop_77082_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77082_end -
                 futhark_mc_scan_stage_3_parloop_77082_start;
        
        ctx->futhark_mc_scan_stage_3_parloop_77082_runs[tid]++;
        ctx->futhark_mc_scan_stage_3_parloop_77082_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_3_parloop_77082_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segscan_task_77077(void *args, int64_t iterations, int tid,
                                  struct scheduler_info info)
{
    int err = 0;
    int flat_tid_71844 = tid;
    int num_tasks_72143 = info.nsubtasks;
    struct futhark_mc_task_77076 *futhark_mc_task_77076 =
                                 (struct futhark_mc_task_77076 *) args;
    struct futhark_context *ctx = futhark_mc_task_77076->ctx;
    uint64_t futhark_mc_segscan_task_77077_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segscan_task_77077_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77076->free_n_65378;
    int64_t gtid_66888 = futhark_mc_task_77076->free_gtid_66888;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77076->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70610 = {.desc ="mem_70610", .mem =
                                 futhark_mc_task_77076->free_mem_70610, .size =
                                 0, .references =NULL};
    size_t scan_stage_2_accum_mem_72150_cached_sizze_77078 = 0;
    unsigned char *scan_stage_2_accum_mem_72150 = NULL;
    int64_t iter_72144;
    struct futhark_mc_scan_stage_1_parloop_struct_77079
    futhark_mc_scan_stage_1_parloop_struct_77079;
    
    futhark_mc_scan_stage_1_parloop_struct_77079.ctx = ctx;
    futhark_mc_scan_stage_1_parloop_struct_77079.free_n_65378 = n_65378;
    futhark_mc_scan_stage_1_parloop_struct_77079.free_gtid_66888 = gtid_66888;
    futhark_mc_scan_stage_1_parloop_struct_77079.free_Y_mem_70603 =
        Y_mem_70603.mem;
    futhark_mc_scan_stage_1_parloop_struct_77079.free_mem_70610 = mem_70610.mem;
    
    struct scheduler_parloop futhark_mc_scan_stage_1_parloop_77080_task;
    
    futhark_mc_scan_stage_1_parloop_77080_task.name =
        "futhark_mc_scan_stage_1_parloop_77080";
    futhark_mc_scan_stage_1_parloop_77080_task.fn =
        futhark_mc_scan_stage_1_parloop_77080;
    futhark_mc_scan_stage_1_parloop_77080_task.args =
        &futhark_mc_scan_stage_1_parloop_struct_77079;
    futhark_mc_scan_stage_1_parloop_77080_task.iterations = iterations;
    futhark_mc_scan_stage_1_parloop_77080_task.info = info;
    
    uint64_t futhark_mc_scan_stage_1_parloop_77080_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77080_total_start = get_wall_time();
    
    int futhark_mc_scan_stage_1_parloop_77080_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_scan_stage_1_parloop_77080_task);
    
    if (futhark_mc_scan_stage_1_parloop_77080_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77080_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77080_total_end -
                 futhark_mc_scan_stage_1_parloop_77080_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77080_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77080_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77080_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    if (slt32(1, num_tasks_72143)) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmentedScan stage 2");
        
        int64_t x_72145;
        int64_t x_72146;
        int64_t offset_72148 = (int64_t) 0;
        int64_t offset_index_72149 = (int64_t) 0;
        
        if (scan_stage_2_accum_mem_72150_cached_sizze_77078 <
            (size_t) (int64_t) 8) {
            scan_stage_2_accum_mem_72150 = realloc(scan_stage_2_accum_mem_72150,
                                                   (int64_t) 8);
            scan_stage_2_accum_mem_72150_cached_sizze_77078 = (int64_t) 8;
        }
        ((int64_t *) scan_stage_2_accum_mem_72150)[(int64_t) 0] = (int64_t) 0;
        for (int32_t i_72152 = 0; i_72152 < num_tasks_72143 - 1; i_72152++) {
            offset_72148 = squot64(n_65378, sext_i32_i64(num_tasks_72143));
            if (slt64(sext_i32_i64(i_72152), srem64(n_65378,
                                                    sext_i32_i64(num_tasks_72143)))) {
                offset_72148 += (int64_t) 1;
            }
            offset_index_72149 += offset_72148;
            
            int64_t gtid_71845 = offset_index_72149;
            double x_71849;
            
            x_71849 = ((double *) Y_mem_70603.mem)[gtid_66888 * n_65378 +
                                                   gtid_71845];
            
            bool isnan_res_71850;
            
            isnan_res_71850 = futrts_isnan64(x_71849);
            
            bool defunc_0_p_res_71851 = !isnan_res_71850;
            int64_t defunc_0_f_res_71852 = btoi_bool_i64(defunc_0_p_res_71851);
            
            // Read carry in
            {
                x_72145 =
                    ((int64_t *) scan_stage_2_accum_mem_72150)[(int64_t) 0];
            }
            // Read next values
            {
                x_72146 = ((int64_t *) mem_70610.mem)[offset_index_72149 -
                                                      (int64_t) 1];
            }
            
            int64_t defunc_1_op_res_72147 = add64(x_72145, x_72146);
            
            ((int64_t *) mem_70610.mem)[offset_index_72149 - (int64_t) 1] =
                defunc_1_op_res_72147;
            ((int64_t *) scan_stage_2_accum_mem_72150)[(int64_t) 0] =
                defunc_1_op_res_72147;
        }
        
        int64_t iter_72156 = (int64_t) 0;
        struct futhark_mc_scan_stage_3_parloop_struct_77081
        futhark_mc_scan_stage_3_parloop_struct_77081;
        
        futhark_mc_scan_stage_3_parloop_struct_77081.ctx = ctx;
        futhark_mc_scan_stage_3_parloop_struct_77081.free_n_65378 = n_65378;
        futhark_mc_scan_stage_3_parloop_struct_77081.free_gtid_66888 =
            gtid_66888;
        futhark_mc_scan_stage_3_parloop_struct_77081.free_Y_mem_70603 =
            Y_mem_70603.mem;
        futhark_mc_scan_stage_3_parloop_struct_77081.free_mem_70610 =
            mem_70610.mem;
        
        struct scheduler_parloop futhark_mc_scan_stage_3_parloop_77082_task;
        
        futhark_mc_scan_stage_3_parloop_77082_task.name =
            "futhark_mc_scan_stage_3_parloop_77082";
        futhark_mc_scan_stage_3_parloop_77082_task.fn =
            futhark_mc_scan_stage_3_parloop_77082;
        futhark_mc_scan_stage_3_parloop_77082_task.args =
            &futhark_mc_scan_stage_3_parloop_struct_77081;
        futhark_mc_scan_stage_3_parloop_77082_task.iterations = iterations;
        futhark_mc_scan_stage_3_parloop_77082_task.info = info;
        
        uint64_t futhark_mc_scan_stage_3_parloop_77082_total_start = 0;
        
        if (ctx->profiling && !ctx->profiling_paused)
            futhark_mc_scan_stage_3_parloop_77082_total_start = get_wall_time();
        
        int futhark_mc_scan_stage_3_parloop_77082_err =
            scheduler_execute_task(&ctx->scheduler,
                                   &futhark_mc_scan_stage_3_parloop_77082_task);
        
        if (futhark_mc_scan_stage_3_parloop_77082_err != 0) {
            err = 1;
            goto cleanup;
        }
        if (ctx->profiling && !ctx->profiling_paused) {
            uint64_t futhark_mc_scan_stage_3_parloop_77082_total_end =
                     get_wall_time();
            uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77082_total_end -
                     futhark_mc_scan_stage_3_parloop_77082_total_start;
            
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77082_total_runs,
                               1, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77082_total_total_runtime,
                               elapsed, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77082_total_iter,
                               iterations, __ATOMIC_RELAXED);
        }
    }
    
  cleanup:
    {
        free(scan_stage_2_accum_mem_72150);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segscan_task_77077_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segscan_task_77077_end -
                 futhark_mc_segscan_task_77077_start;
        
        ctx->futhark_mc_segscan_task_77077_runs[tid]++;
        ctx->futhark_mc_segscan_task_77077_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segscan_task_77077_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77083 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_66888;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70610;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
};
struct futhark_mc_segmap_parloop_struct_77085 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_66888;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70610;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
};
static int futhark_mc_segmap_parloop_77086(void *args, int64_t start,
                                           int64_t end, int flat_tid_71853,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77085
    *futhark_mc_segmap_parloop_struct_77085 =
    (struct futhark_mc_segmap_parloop_struct_77085 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77085->ctx;
    uint64_t futhark_mc_segmap_parloop_77086_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77086_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77085->free_n_65378;
    int64_t gtid_66888 =
            futhark_mc_segmap_parloop_struct_77085->free_gtid_66888;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77085->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70610 = {.desc ="mem_70610", .mem =
                                 futhark_mc_segmap_parloop_struct_77085->free_mem_70610,
                                 .size =0, .references =NULL};
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_segmap_parloop_struct_77085->free_mem_70613,
                                 .size =0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_segmap_parloop_struct_77085->free_mem_70616,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72160 = start;
    
    for (; iter_72160 < end; iter_72160++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72163 = n_65378;
        int64_t gtid_71854 = iter_72160;
        int64_t remnant_72164 = iter_72160 - gtid_71854;
        double x_71855;
        
        x_71855 = ((double *) Y_mem_70603.mem)[gtid_66888 * n_65378 +
                                               gtid_71854];
        
        bool isnan_res_71856;
        
        isnan_res_71856 = futrts_isnan64(x_71855);
        
        bool defunc_0_p_res_71857 = !isnan_res_71856;
        int64_t defunc_1_f_res_71858;
        
        if (defunc_0_p_res_71857) {
            int64_t x_72161;
            
            x_72161 = ((int64_t *) mem_70610.mem)[gtid_71854];
            
            int64_t defunc_1_f_res_t_res_72162 = sub64(x_72161, (int64_t) 1);
            
            defunc_1_f_res_71858 = defunc_1_f_res_t_res_72162;
        } else {
            defunc_1_f_res_71858 = (int64_t) -1;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_71858) &&
            slt64(defunc_1_f_res_71858, n_65378)) {
            ((int64_t *) mem_70616.mem)[defunc_1_f_res_71858] = gtid_71854;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_71858) &&
            slt64(defunc_1_f_res_71858, n_65378)) {
            ((double *) mem_70613.mem)[defunc_1_f_res_71858] = x_71855;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77086_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77086_end -
                 futhark_mc_segmap_parloop_77086_start;
        
        ctx->futhark_mc_segmap_parloop_77086_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77086_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77086_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77084(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_71853 = tid;
    int num_tasks_72159 = info.nsubtasks;
    struct futhark_mc_task_77083 *futhark_mc_task_77083 =
                                 (struct futhark_mc_task_77083 *) args;
    struct futhark_context *ctx = futhark_mc_task_77083->ctx;
    uint64_t futhark_mc_segmap_task_77084_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77084_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77083->free_n_65378;
    int64_t gtid_66888 = futhark_mc_task_77083->free_gtid_66888;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77083->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70610 = {.desc ="mem_70610", .mem =
                                 futhark_mc_task_77083->free_mem_70610, .size =
                                 0, .references =NULL};
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_task_77083->free_mem_70613, .size =
                                 0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_task_77083->free_mem_70616, .size =
                                 0, .references =NULL};
    int64_t iter_72160;
    struct futhark_mc_segmap_parloop_struct_77085
    futhark_mc_segmap_parloop_struct_77085;
    
    futhark_mc_segmap_parloop_struct_77085.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77085.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77085.free_gtid_66888 = gtid_66888;
    futhark_mc_segmap_parloop_struct_77085.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77085.free_mem_70610 = mem_70610.mem;
    futhark_mc_segmap_parloop_struct_77085.free_mem_70613 = mem_70613.mem;
    futhark_mc_segmap_parloop_struct_77085.free_mem_70616 = mem_70616.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77086_task;
    
    futhark_mc_segmap_parloop_77086_task.name =
        "futhark_mc_segmap_parloop_77086";
    futhark_mc_segmap_parloop_77086_task.fn = futhark_mc_segmap_parloop_77086;
    futhark_mc_segmap_parloop_77086_task.args =
        &futhark_mc_segmap_parloop_struct_77085;
    futhark_mc_segmap_parloop_77086_task.iterations = iterations;
    futhark_mc_segmap_parloop_77086_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77086_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77086_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77086_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77086_task);
    
    if (futhark_mc_segmap_parloop_77086_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77086_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77086_total_end -
                 futhark_mc_segmap_parloop_77086_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77086_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77086_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77086_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77084_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77084_end -
                 futhark_mc_segmap_task_77084_start;
        
        ctx->futhark_mc_segmap_task_77084_runs[tid]++;
        ctx->futhark_mc_segmap_task_77084_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77084_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77087 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70619;
};
struct futhark_mc_segmap_parloop_struct_77089 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70619;
};
static int futhark_mc_segmap_parloop_77090(void *args, int64_t start,
                                           int64_t end, int flat_tid_71861,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77089
    *futhark_mc_segmap_parloop_struct_77089 =
    (struct futhark_mc_segmap_parloop_struct_77089 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77089->ctx;
    uint64_t futhark_mc_segmap_parloop_77090_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77090_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77089->free_n_65378;
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_segmap_parloop_struct_77089->free_mem_70616,
                                 .size =0, .references =NULL};
    struct memblock mem_70619 = {.desc ="mem_70619", .mem =
                                 futhark_mc_segmap_parloop_struct_77089->free_mem_70619,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72166 = start;
    
    for (; iter_72166 < end; iter_72166++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72167 = n_65378;
        int64_t gtid_71862 = iter_72166;
        int64_t remnant_72168 = iter_72166 - gtid_71862;
        int64_t x_71863;
        
        x_71863 = ((int64_t *) mem_70616.mem)[gtid_71862];
        
        int64_t defunc_0_f_res_71864 = add64((int64_t) 1, x_71863);
        
        ((int64_t *) mem_70619.mem)[gtid_71862] = defunc_0_f_res_71864;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77090_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77090_end -
                 futhark_mc_segmap_parloop_77090_start;
        
        ctx->futhark_mc_segmap_parloop_77090_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77090_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77090_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77088(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_71861 = tid;
    int num_tasks_72165 = info.nsubtasks;
    struct futhark_mc_task_77087 *futhark_mc_task_77087 =
                                 (struct futhark_mc_task_77087 *) args;
    struct futhark_context *ctx = futhark_mc_task_77087->ctx;
    uint64_t futhark_mc_segmap_task_77088_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77088_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77087->free_n_65378;
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_task_77087->free_mem_70616, .size =
                                 0, .references =NULL};
    struct memblock mem_70619 = {.desc ="mem_70619", .mem =
                                 futhark_mc_task_77087->free_mem_70619, .size =
                                 0, .references =NULL};
    int64_t iter_72166;
    struct futhark_mc_segmap_parloop_struct_77089
    futhark_mc_segmap_parloop_struct_77089;
    
    futhark_mc_segmap_parloop_struct_77089.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77089.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77089.free_mem_70616 = mem_70616.mem;
    futhark_mc_segmap_parloop_struct_77089.free_mem_70619 = mem_70619.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77090_task;
    
    futhark_mc_segmap_parloop_77090_task.name =
        "futhark_mc_segmap_parloop_77090";
    futhark_mc_segmap_parloop_77090_task.fn = futhark_mc_segmap_parloop_77090;
    futhark_mc_segmap_parloop_77090_task.args =
        &futhark_mc_segmap_parloop_struct_77089;
    futhark_mc_segmap_parloop_77090_task.iterations = iterations;
    futhark_mc_segmap_parloop_77090_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77090_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77090_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77090_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77090_task);
    
    if (futhark_mc_segmap_parloop_77090_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77090_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77090_total_end -
                 futhark_mc_segmap_parloop_77090_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77090_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77090_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77090_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77088_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77088_end -
                 futhark_mc_segmap_task_77088_start;
        
        ctx->futhark_mc_segmap_task_77088_runs[tid]++;
        ctx->futhark_mc_segmap_task_77088_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77088_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77091 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_66900;
    unsigned char *free_mem_70622;
};
struct futhark_mc_segmap_parloop_struct_77093 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_66900;
    unsigned char *free_mem_70622;
};
static int futhark_mc_segmap_parloop_77094(void *args, int64_t start,
                                           int64_t end, int flat_tid_71865,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77093
    *futhark_mc_segmap_parloop_struct_77093 =
    (struct futhark_mc_segmap_parloop_struct_77093 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77093->ctx;
    uint64_t futhark_mc_segmap_parloop_77094_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77094_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77093->free_q_65380;
    int64_t last_res_66900 =
            futhark_mc_segmap_parloop_struct_77093->free_last_res_66900;
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_segmap_parloop_struct_77093->free_mem_70622,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72170 = start;
    
    for (; iter_72170 < end; iter_72170++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72171 = q_65380;
        int64_t gtid_71866 = iter_72170;
        int64_t remnant_72172 = iter_72170 - gtid_71866;
        bool cond_71867 = sle64(last_res_66900, gtid_71866);
        double defunc_0_f_res_71868;
        
        if (cond_71867) {
            defunc_0_f_res_71868 = 0.0;
        } else {
            defunc_0_f_res_71868 = 1.0;
        }
        ((double *) mem_70622.mem)[gtid_71866] = defunc_0_f_res_71868;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77094_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77094_end -
                 futhark_mc_segmap_parloop_77094_start;
        
        ctx->futhark_mc_segmap_parloop_77094_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77094_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77094_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77092(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_71865 = tid;
    int num_tasks_72169 = info.nsubtasks;
    struct futhark_mc_task_77091 *futhark_mc_task_77091 =
                                 (struct futhark_mc_task_77091 *) args;
    struct futhark_context *ctx = futhark_mc_task_77091->ctx;
    uint64_t futhark_mc_segmap_task_77092_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77092_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77091->free_q_65380;
    int64_t last_res_66900 = futhark_mc_task_77091->free_last_res_66900;
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_task_77091->free_mem_70622, .size =
                                 0, .references =NULL};
    int64_t iter_72170;
    struct futhark_mc_segmap_parloop_struct_77093
    futhark_mc_segmap_parloop_struct_77093;
    
    futhark_mc_segmap_parloop_struct_77093.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77093.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77093.free_last_res_66900 = last_res_66900;
    futhark_mc_segmap_parloop_struct_77093.free_mem_70622 = mem_70622.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77094_task;
    
    futhark_mc_segmap_parloop_77094_task.name =
        "futhark_mc_segmap_parloop_77094";
    futhark_mc_segmap_parloop_77094_task.fn = futhark_mc_segmap_parloop_77094;
    futhark_mc_segmap_parloop_77094_task.args =
        &futhark_mc_segmap_parloop_struct_77093;
    futhark_mc_segmap_parloop_77094_task.iterations = iterations;
    futhark_mc_segmap_parloop_77094_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77094_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77094_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77094_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77094_task);
    
    if (futhark_mc_segmap_parloop_77094_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77094_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77094_total_end -
                 futhark_mc_segmap_parloop_77094_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77094_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77094_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77094_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77092_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77092_end -
                 futhark_mc_segmap_task_77092_start;
        
        ctx->futhark_mc_segmap_task_77092_runs[tid]++;
        ctx->futhark_mc_segmap_task_77092_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77092_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77095 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_66900;
    int64_t free_min_arg_66919;
    int64_t free_min_arg_66920;
    int64_t free_min_res_66921;
    double free_max_res_66925;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70619;
    unsigned char *free_mem_70622;
    unsigned char *free_mem_70625;
};
struct futhark_mc_segmap_parloop_struct_77097 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_66900;
    int64_t free_min_arg_66919;
    int64_t free_min_arg_66920;
    int64_t free_min_res_66921;
    double free_max_res_66925;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70619;
    unsigned char *free_mem_70622;
    unsigned char *free_mem_70625;
};
static int futhark_mc_segmap_parloop_77098(void *args, int64_t start,
                                           int64_t end, int flat_tid_72007,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77097
    *futhark_mc_segmap_parloop_struct_77097 =
    (struct futhark_mc_segmap_parloop_struct_77097 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77097->ctx;
    uint64_t futhark_mc_segmap_parloop_77098_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77098_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77097->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77097->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77097->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77097->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77097->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77097->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77097->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77097->free_loop_cond_65403;
    int64_t last_res_66900 =
            futhark_mc_segmap_parloop_struct_77097->free_last_res_66900;
    int64_t min_arg_66919 =
            futhark_mc_segmap_parloop_struct_77097->free_min_arg_66919;
    int64_t min_arg_66920 =
            futhark_mc_segmap_parloop_struct_77097->free_min_arg_66920;
    int64_t min_res_66921 =
            futhark_mc_segmap_parloop_struct_77097->free_min_res_66921;
    double max_res_66925 =
           futhark_mc_segmap_parloop_struct_77097->free_max_res_66925;
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_segmap_parloop_struct_77097->free_mem_70613,
                                 .size =0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_segmap_parloop_struct_77097->free_mem_70616,
                                 .size =0, .references =NULL};
    struct memblock mem_70619 = {.desc ="mem_70619", .mem =
                                 futhark_mc_segmap_parloop_struct_77097->free_mem_70619,
                                 .size =0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_segmap_parloop_struct_77097->free_mem_70622,
                                 .size =0, .references =NULL};
    struct memblock mem_70625 = {.desc ="mem_70625", .mem =
                                 futhark_mc_segmap_parloop_struct_77097->free_mem_70625,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72174 = start;
    
    for (; iter_72174 < end; iter_72174++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72273 = n_m_65386;
        int64_t gtid_72008 = iter_72174;
        int64_t remnant_72274 = iter_72174 - gtid_72008;
        int64_t min_arg_72009 = mul64(jump_65382, gtid_72008);
        int64_t min_res_72010 = smin64(i_65392, min_arg_72009);
        int64_t defunc_0_g_res_72011 = add64((int64_t) 1, min_res_72010);
        bool init_idx_72012;
        int64_t init_idx_72013;
        int64_t init_idx_72014;
        bool loop_while_72175;
        int64_t low_72176;
        int64_t high_72177;
        
        loop_while_72175 = x_65393;
        low_72176 = (int64_t) 0;
        high_72177 = i_65392;
        while (loop_while_72175) {
            int64_t x_72178 = add64(low_72176, high_72177);
            int64_t mid_72179 = sdiv64(x_72178, (int64_t) 2);
            bool x_72180 = sle64((int64_t) 0, mid_72179);
            bool y_72181 = slt64(mid_72179, n_65378);
            bool bounds_check_72182 = x_72180 && y_72181;
            bool index_certs_72183;
            
            if (!bounds_check_72182) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_72179,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_72184;
            
            mid_id_72184 = ((int64_t *) mem_70619.mem)[mid_72179];
            
            bool cond_72185 = slt64(mid_id_72184, (int64_t) 0);
            int64_t mid_idx_72186;
            
            if (cond_72185) {
                mid_idx_72186 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_72186 = mid_id_72184;
            }
            
            bool cond_72187 = sle64(defunc_0_g_res_72011, mid_idx_72186);
            int64_t loopres_72188;
            int64_t loopres_72189;
            
            if (cond_72187) {
                int64_t loopres_t_res_72190 = sub64(mid_72179, (int64_t) 1);
                
                loopres_72188 = low_72176;
                loopres_72189 = loopres_t_res_72190;
            } else {
                int64_t loopres_f_res_72191 = add64((int64_t) 1, mid_72179);
                
                loopres_72188 = loopres_f_res_72191;
                loopres_72189 = high_72177;
            }
            
            bool loop_cond_72192 = sle64(loopres_72188, loopres_72189);
            bool loop_while_tmp_72275 = loop_cond_72192;
            int64_t low_tmp_72276 = loopres_72188;
            int64_t high_tmp_72277 = loopres_72189;
            
            loop_while_72175 = loop_while_tmp_72275;
            low_72176 = low_tmp_72276;
            high_72177 = high_tmp_72277;
        }
        init_idx_72012 = loop_while_72175;
        init_idx_72013 = low_72176;
        init_idx_72014 = high_72177;
        
        bool idx_72033;
        int64_t idx_72034;
        int64_t idx_72035;
        int64_t idx_72036;
        bool loop_while_72193;
        int64_t l_idx_72194;
        int64_t r_idx_72195;
        int64_t span_72196;
        
        loop_while_72193 = loop_cond_65403;
        l_idx_72194 = init_idx_72013;
        r_idx_72195 = init_idx_72013;
        span_72196 = (int64_t) 1;
        while (loop_while_72193) {
            int64_t max_arg_72197 = sub64(l_idx_72194, (int64_t) 1);
            int64_t max_res_72198 = smax64((int64_t) 0, max_arg_72197);
            int64_t min_arg_72199 = add64((int64_t) 1, r_idx_72195);
            int64_t min_res_72200 = smin64(min_arg_66919, min_arg_72199);
            bool x_72201 = sle64((int64_t) 0, max_res_72198);
            bool y_72202 = slt64(max_res_72198, n_65378);
            bool bounds_check_72203 = x_72201 && y_72202;
            bool index_certs_72204;
            
            if (!bounds_check_72203) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_72198,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_72205;
            
            x_72205 = ((int64_t *) mem_70619.mem)[max_res_72198];
            
            int64_t abs_arg_72206 = sub64(x_72205, defunc_0_g_res_72011);
            int64_t abs_res_72207 = abs64(abs_arg_72206);
            bool x_72208 = sle64((int64_t) 0, min_res_72200);
            bool y_72209 = slt64(min_res_72200, n_65378);
            bool bounds_check_72210 = x_72208 && y_72209;
            bool index_certs_72211;
            
            if (!bounds_check_72210) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_72200,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_72212;
            
            x_72212 = ((int64_t *) mem_70619.mem)[min_res_72200];
            
            int64_t abs_arg_72213 = sub64(x_72212, defunc_0_g_res_72011);
            int64_t abs_res_72214 = abs64(abs_arg_72213);
            bool cond_72215 = max_res_72198 == l_idx_72194;
            int64_t loopres_72216;
            int64_t loopres_72217;
            int64_t loopres_72218;
            
            if (cond_72215) {
                loopres_72216 = l_idx_72194;
                loopres_72217 = r_idx_72195;
                loopres_72218 = min_res_65398;
            } else {
                bool cond_72219 = slt64(abs_res_72207, abs_res_72214);
                bool cond_f_res_72220 = min_res_72200 == r_idx_72195;
                bool x_72221 = !cond_72219;
                bool y_72222 = cond_f_res_72220 && x_72221;
                bool cond_72223 = cond_72219 || y_72222;
                int64_t loopres_f_res_72224;
                
                if (cond_72223) {
                    loopres_f_res_72224 = max_res_72198;
                } else {
                    loopres_f_res_72224 = l_idx_72194;
                }
                
                int64_t loopres_f_res_72225;
                
                if (cond_72223) {
                    loopres_f_res_72225 = r_idx_72195;
                } else {
                    loopres_f_res_72225 = min_res_72200;
                }
                
                int64_t loopres_f_res_72226;
                
                if (cond_72223) {
                    int64_t loopres_f_res_t_res_72227 = add64((int64_t) 1,
                                                              span_72196);
                    
                    loopres_f_res_72226 = loopres_f_res_t_res_72227;
                } else {
                    int64_t loopres_f_res_f_res_72228 = add64((int64_t) 1,
                                                              span_72196);
                    
                    loopres_f_res_72226 = loopres_f_res_f_res_72228;
                }
                loopres_72216 = loopres_f_res_72224;
                loopres_72217 = loopres_f_res_72225;
                loopres_72218 = loopres_f_res_72226;
            }
            
            bool loop_cond_72229 = slt64(loopres_72218, min_res_65398);
            bool loop_while_tmp_72278 = loop_cond_72229;
            int64_t l_idx_tmp_72279 = loopres_72216;
            int64_t r_idx_tmp_72280 = loopres_72217;
            int64_t span_tmp_72281 = loopres_72218;
            
            loop_while_72193 = loop_while_tmp_72278;
            l_idx_72194 = l_idx_tmp_72279;
            r_idx_72195 = r_idx_tmp_72280;
            span_72196 = span_tmp_72281;
        }
        idx_72033 = loop_while_72193;
        idx_72034 = l_idx_72194;
        idx_72035 = r_idx_72195;
        idx_72036 = span_72196;
        
        int64_t min_res_72074 = smin64(min_arg_66920, idx_72034);
        int64_t max_res_72075 = smax64((int64_t) 0, min_res_72074);
        int64_t x_72076 = add64(min_res_66921, max_res_72075);
        int64_t r_72077 = sub64(x_72076, (int64_t) 1);
        bool x_72078 = sle64((int64_t) 0, r_72077);
        bool y_72079 = slt64(r_72077, n_65378);
        bool bounds_check_72080 = x_72078 && y_72079;
        bool index_certs_72081;
        
        if (!bounds_check_72080) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_72077,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_72082;
        
        x_72082 = ((int64_t *) mem_70616.mem)[r_72077];
        
        int64_t abs_arg_72083 = sub64(x_72082, min_res_72010);
        int64_t abs_res_72084 = abs64(abs_arg_72083);
        bool x_72085 = sle64((int64_t) 0, max_res_72075);
        bool y_72086 = slt64(max_res_72075, n_65378);
        bool bounds_check_72087 = x_72085 && y_72086;
        bool index_certs_72088;
        
        if (!bounds_check_72087) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_72075,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_72089;
        
        x_72089 = ((int64_t *) mem_70616.mem)[max_res_72075];
        
        int64_t abs_arg_72090 = sub64(x_72089, min_res_72010);
        int64_t abs_res_72091 = abs64(abs_arg_72090);
        int64_t max_res_72092 = smax64(abs_res_72084, abs_res_72091);
        double defunc_0_f_res_72093 = sitofp_i64_f64(max_res_72092);
        double defunc_1_f_res_72094 = max_res_66925 + defunc_0_f_res_72093;
        double defunc_2_reduce_res_72095;
        double redout_72231 = 0.0;
        
        for (int64_t i_72230 = 0; i_72230 < q_65380; i_72230++) {
            double x_72232;
            
            x_72232 = ((double *) mem_70622.mem)[i_72230];
            
            bool cond_72233 = sle64(last_res_66900, i_72230);
            int64_t defunc_0_f_res_72234;
            
            if (cond_72233) {
                defunc_0_f_res_72234 = (int64_t) 0;
            } else {
                int64_t i_72235 = add64(max_res_72075, i_72230);
                int64_t defunc_0_add_arg_72236;
                
                defunc_0_add_arg_72236 = ((int64_t *) mem_70616.mem)[i_72235];
                
                int64_t defunc_1_add_res_72237 = add64((int64_t) 1,
                                                       defunc_0_add_arg_72236);
                
                defunc_0_f_res_72234 = defunc_1_add_res_72237;
            }
            
            int64_t binop_p_72238 = sub64(defunc_0_f_res_72234, min_res_72010);
            double defunc_0_f_res_72239 = sitofp_i64_f64(binop_p_72238);
            double abs_res_72240 = fabs(defunc_0_f_res_72239);
            double tmp1_72241 = abs_res_72240 / defunc_1_f_res_72094;
            double x_72242 = tmp1_72241 * tmp1_72241;
            double y_72243 = tmp1_72241 * x_72242;
            double tmp2_72244 = 1.0 - y_72243;
            double x_72245 = tmp2_72244 * tmp2_72244;
            double tmp3_72246 = tmp2_72244 * x_72245;
            double w_j_72247 = x_72232 * tmp3_72246;
            double defunc_1_op_res_72248 = w_j_72247 + redout_72231;
            double redout_tmp_72282 = defunc_1_op_res_72248;
            
            redout_72231 = redout_tmp_72282;
        }
        defunc_2_reduce_res_72095 = redout_72231;
        
        double a0_72115 = 1.0 / defunc_2_reduce_res_72095;
        double defunc_2_reduce_res_72116;
        double redout_72250 = 0.0;
        
        for (int64_t i_72249 = 0; i_72249 < q_65380; i_72249++) {
            double x_72251;
            
            x_72251 = ((double *) mem_70622.mem)[i_72249];
            
            bool cond_72252 = sle64(last_res_66900, i_72249);
            int64_t defunc_0_f_res_72253;
            
            if (cond_72252) {
                defunc_0_f_res_72253 = (int64_t) 0;
            } else {
                int64_t i_72254 = add64(max_res_72075, i_72249);
                int64_t defunc_0_add_arg_72255;
                
                defunc_0_add_arg_72255 = ((int64_t *) mem_70616.mem)[i_72254];
                
                int64_t defunc_1_add_res_72256 = add64((int64_t) 1,
                                                       defunc_0_add_arg_72255);
                
                defunc_0_f_res_72253 = defunc_1_add_res_72256;
            }
            
            int64_t binop_p_72257 = sub64(defunc_0_f_res_72253, min_res_72010);
            double defunc_0_f_res_72258 = sitofp_i64_f64(binop_p_72257);
            double abs_res_72259 = fabs(defunc_0_f_res_72258);
            double tmp1_72260 = abs_res_72259 / defunc_1_f_res_72094;
            double x_72261 = tmp1_72260 * tmp1_72260;
            double y_72262 = tmp1_72260 * x_72261;
            double tmp2_72263 = 1.0 - y_72262;
            double x_72264 = tmp2_72263 * tmp2_72263;
            double tmp3_72265 = tmp2_72263 * x_72264;
            double tmp4_72266 = x_72251 * tmp3_72265;
            double defunc_0_f_res_72267;
            
            if (cond_72252) {
                defunc_0_f_res_72267 = 0.0;
            } else {
                int64_t i_72268 = add64(max_res_72075, i_72249);
                double defunc_0_add_arg_72269;
                
                defunc_0_add_arg_72269 = ((double *) mem_70613.mem)[i_72268];
                defunc_0_f_res_72267 = defunc_0_add_arg_72269;
            }
            
            double x_72270 = a0_72115 * tmp4_72266;
            double defunc_9_fit_fun_res_72271 = defunc_0_f_res_72267 * x_72270;
            double defunc_1_op_res_72272 = defunc_9_fit_fun_res_72271 +
                   redout_72250;
            double redout_tmp_72283 = defunc_1_op_res_72272;
            
            redout_72250 = redout_tmp_72283;
        }
        defunc_2_reduce_res_72116 = redout_72250;
        ((double *) mem_70625.mem)[gtid_72008] = defunc_2_reduce_res_72116;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77098_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77098_end -
                 futhark_mc_segmap_parloop_77098_start;
        
        ctx->futhark_mc_segmap_parloop_77098_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77098_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77098_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77096(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72007 = tid;
    int num_tasks_72173 = info.nsubtasks;
    struct futhark_mc_task_77095 *futhark_mc_task_77095 =
                                 (struct futhark_mc_task_77095 *) args;
    struct futhark_context *ctx = futhark_mc_task_77095->ctx;
    uint64_t futhark_mc_segmap_task_77096_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77096_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77095->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77095->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77095->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77095->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77095->free_i_65392;
    bool x_65393 = futhark_mc_task_77095->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77095->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77095->free_loop_cond_65403;
    int64_t last_res_66900 = futhark_mc_task_77095->free_last_res_66900;
    int64_t min_arg_66919 = futhark_mc_task_77095->free_min_arg_66919;
    int64_t min_arg_66920 = futhark_mc_task_77095->free_min_arg_66920;
    int64_t min_res_66921 = futhark_mc_task_77095->free_min_res_66921;
    double max_res_66925 = futhark_mc_task_77095->free_max_res_66925;
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_task_77095->free_mem_70613, .size =
                                 0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_task_77095->free_mem_70616, .size =
                                 0, .references =NULL};
    struct memblock mem_70619 = {.desc ="mem_70619", .mem =
                                 futhark_mc_task_77095->free_mem_70619, .size =
                                 0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_task_77095->free_mem_70622, .size =
                                 0, .references =NULL};
    struct memblock mem_70625 = {.desc ="mem_70625", .mem =
                                 futhark_mc_task_77095->free_mem_70625, .size =
                                 0, .references =NULL};
    int64_t iter_72174;
    struct futhark_mc_segmap_parloop_struct_77097
    futhark_mc_segmap_parloop_struct_77097;
    
    futhark_mc_segmap_parloop_struct_77097.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77097.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77097.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77097.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77097.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77097.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77097.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77097.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77097.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77097.free_last_res_66900 = last_res_66900;
    futhark_mc_segmap_parloop_struct_77097.free_min_arg_66919 = min_arg_66919;
    futhark_mc_segmap_parloop_struct_77097.free_min_arg_66920 = min_arg_66920;
    futhark_mc_segmap_parloop_struct_77097.free_min_res_66921 = min_res_66921;
    futhark_mc_segmap_parloop_struct_77097.free_max_res_66925 = max_res_66925;
    futhark_mc_segmap_parloop_struct_77097.free_mem_70613 = mem_70613.mem;
    futhark_mc_segmap_parloop_struct_77097.free_mem_70616 = mem_70616.mem;
    futhark_mc_segmap_parloop_struct_77097.free_mem_70619 = mem_70619.mem;
    futhark_mc_segmap_parloop_struct_77097.free_mem_70622 = mem_70622.mem;
    futhark_mc_segmap_parloop_struct_77097.free_mem_70625 = mem_70625.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77098_task;
    
    futhark_mc_segmap_parloop_77098_task.name =
        "futhark_mc_segmap_parloop_77098";
    futhark_mc_segmap_parloop_77098_task.fn = futhark_mc_segmap_parloop_77098;
    futhark_mc_segmap_parloop_77098_task.args =
        &futhark_mc_segmap_parloop_struct_77097;
    futhark_mc_segmap_parloop_77098_task.iterations = iterations;
    futhark_mc_segmap_parloop_77098_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77098_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77098_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77098_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77098_task);
    
    if (futhark_mc_segmap_parloop_77098_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77098_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77098_total_end -
                 futhark_mc_segmap_parloop_77098_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77098_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77098_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77098_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77096_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77096_end -
                 futhark_mc_segmap_task_77096_start;
        
        ctx->futhark_mc_segmap_task_77096_runs[tid]++;
        ctx->futhark_mc_segmap_task_77096_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77096_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77100 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_66900;
    int64_t free_min_arg_66919;
    int64_t free_min_arg_66920;
    int64_t free_min_res_66921;
    double free_max_res_66925;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70619;
    unsigned char *free_mem_70622;
    unsigned char *free_mem_70625;
};
struct futhark_mc_task_77102 {
    struct futhark_context *ctx;
    int64_t free_last_res_66900;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70622;
    int64_t free_min_res_71872;
    int64_t free_max_res_71937;
    double free_defunc_1_f_res_71956;
    double *retval_defunc_2_reduce_res_71957;
};
struct futhark_mc_segred_stage_1_parloop_struct_77105 {
    struct futhark_context *ctx;
    int64_t free_last_res_66900;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70622;
    int64_t free_min_res_71872;
    int64_t free_max_res_71937;
    double free_defunc_1_f_res_71956;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_72397;
};
static int futhark_mc_segred_stage_1_parloop_77106(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_72340, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77105
    *futhark_mc_segred_stage_1_parloop_struct_77105 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77105 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77105->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77106_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77106_start = get_wall_time();
    
    int64_t last_res_66900 =
            futhark_mc_segred_stage_1_parloop_struct_77105->free_last_res_66900;
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77105->free_mem_70616,
                                 .size =0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77105->free_mem_70622,
                                 .size =0, .references =NULL};
    int64_t min_res_71872 =
            futhark_mc_segred_stage_1_parloop_struct_77105->free_min_res_71872;
    int64_t max_res_71937 =
            futhark_mc_segred_stage_1_parloop_struct_77105->free_max_res_71937;
    double defunc_1_f_res_71956 =
           futhark_mc_segred_stage_1_parloop_struct_77105->free_defunc_1_f_res_71956;
    struct memblock reduce_stage_1_tid_res_arr_mem_72397 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_72397",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77105->free_reduce_stage_1_tid_res_arr_mem_72397,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72399 = start;
    double x_72342;
    double x_72343;
    double local_acc_72400 = 0.0;
    
    for (; iter_72399 < end; iter_72399++) {
        int64_t gtid_72341 = iter_72399;
        double x_72345;
        
        x_72345 = ((double *) mem_70622.mem)[gtid_72341];
        
        bool cond_72346 = sle64(last_res_66900, gtid_72341);
        int64_t defunc_0_f_res_72347;
        
        if (cond_72346) {
            defunc_0_f_res_72347 = (int64_t) 0;
        } else {
            int64_t i_72348 = add64(max_res_71937, gtid_72341);
            int64_t defunc_0_add_arg_72349;
            
            defunc_0_add_arg_72349 = ((int64_t *) mem_70616.mem)[i_72348];
            
            int64_t defunc_1_add_res_72350 = add64((int64_t) 1,
                                                   defunc_0_add_arg_72349);
            
            defunc_0_f_res_72347 = defunc_1_add_res_72350;
        }
        
        int64_t binop_p_72351 = sub64(defunc_0_f_res_72347, min_res_71872);
        double defunc_0_f_res_72352 = sitofp_i64_f64(binop_p_72351);
        double abs_res_72353 = fabs(defunc_0_f_res_72352);
        double tmp1_72354 = abs_res_72353 / defunc_1_f_res_71956;
        double x_72355 = tmp1_72354 * tmp1_72354;
        double y_72356 = tmp1_72354 * x_72355;
        double tmp2_72357 = 1.0 - y_72356;
        double x_72358 = tmp2_72357 * tmp2_72357;
        double tmp3_72359 = tmp2_72357 * x_72358;
        double w_j_72360 = x_72345 * tmp3_72359;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_72342 = local_acc_72400;
        }
        // Load next params
        {
            x_72343 = w_j_72360;
        }
        // Red body
        {
            double defunc_1_op_res_72344 = x_72342 + x_72343;
            
            local_acc_72400 = defunc_1_op_res_72344;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_72397.mem)[flat_tid_72340] =
        local_acc_72400;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77106_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77106_end -
                 futhark_mc_segred_stage_1_parloop_77106_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77106_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77106_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77106_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77103(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72340 = tid;
    int num_tasks_72396 = info.nsubtasks;
    struct futhark_mc_task_77102 *futhark_mc_task_77102 =
                                 (struct futhark_mc_task_77102 *) args;
    struct futhark_context *ctx = futhark_mc_task_77102->ctx;
    uint64_t futhark_mc_segred_task_77103_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77103_start = get_wall_time();
    
    int64_t last_res_66900 = futhark_mc_task_77102->free_last_res_66900;
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_task_77102->free_mem_70616, .size =
                                 0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_task_77102->free_mem_70622, .size =
                                 0, .references =NULL};
    int64_t min_res_71872 = futhark_mc_task_77102->free_min_res_71872;
    int64_t max_res_71937 = futhark_mc_task_77102->free_max_res_71937;
    double defunc_1_f_res_71956 =
           futhark_mc_task_77102->free_defunc_1_f_res_71956;
    double defunc_2_reduce_res_71957 =
           *futhark_mc_task_77102->retval_defunc_2_reduce_res_71957;
    size_t reduce_stage_1_tid_res_arr_mem_72397_cached_sizze_77104 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_72397 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_72397_cached_sizze_77104 <
        (size_t) ((int64_t) 8 * num_tasks_72396)) {
        reduce_stage_1_tid_res_arr_mem_72397 =
            realloc(reduce_stage_1_tid_res_arr_mem_72397, (int64_t) 8 *
                    num_tasks_72396);
        reduce_stage_1_tid_res_arr_mem_72397_cached_sizze_77104 = (int64_t) 8 *
            num_tasks_72396;
    }
    
    int64_t iter_72399;
    struct futhark_mc_segred_stage_1_parloop_struct_77105
    futhark_mc_segred_stage_1_parloop_struct_77105;
    
    futhark_mc_segred_stage_1_parloop_struct_77105.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_last_res_66900 =
        last_res_66900;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_mem_70616 =
        mem_70616.mem;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_mem_70622 =
        mem_70622.mem;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_min_res_71872 =
        min_res_71872;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_max_res_71937 =
        max_res_71937;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_defunc_1_f_res_71956 =
        defunc_1_f_res_71956;
    futhark_mc_segred_stage_1_parloop_struct_77105.free_reduce_stage_1_tid_res_arr_mem_72397 =
        reduce_stage_1_tid_res_arr_mem_72397;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77106_task;
    
    futhark_mc_segred_stage_1_parloop_77106_task.name =
        "futhark_mc_segred_stage_1_parloop_77106";
    futhark_mc_segred_stage_1_parloop_77106_task.fn =
        futhark_mc_segred_stage_1_parloop_77106;
    futhark_mc_segred_stage_1_parloop_77106_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77105;
    futhark_mc_segred_stage_1_parloop_77106_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77106_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77106_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77106_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77106_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77106_task);
    
    if (futhark_mc_segred_stage_1_parloop_77106_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77106_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77106_total_end -
                 futhark_mc_segred_stage_1_parloop_77106_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77106_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77106_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77106_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_71957 = 0.0;
    }
    
    double x_72401;
    double x_72402;
    
    for (int32_t i_72404 = 0; i_72404 < num_tasks_72396; i_72404++) {
        flat_tid_72340 = i_72404;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_72401 = defunc_2_reduce_res_71957;
            }
            // load next params
            {
                x_72402 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_72397)[flat_tid_72340];
            }
            // red body
            {
                double defunc_1_op_res_72403 = x_72401 + x_72402;
                
                defunc_2_reduce_res_71957 = defunc_1_op_res_72403;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_72397);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77103_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77103_end -
                 futhark_mc_segred_task_77103_start;
        
        ctx->futhark_mc_segred_task_77103_runs[tid]++;
        ctx->futhark_mc_segred_task_77103_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77103_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77102->retval_defunc_2_reduce_res_71957 =
            defunc_2_reduce_res_71957;
    }
    return err;
}
struct futhark_mc_task_77107 {
    struct futhark_context *ctx;
    int64_t free_last_res_66900;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70622;
    int64_t free_min_res_71872;
    int64_t free_max_res_71937;
    double free_defunc_1_f_res_71956;
    double free_a0_71979;
    double *retval_defunc_2_reduce_res_71980;
};
struct futhark_mc_segred_stage_1_parloop_struct_77110 {
    struct futhark_context *ctx;
    int64_t free_last_res_66900;
    unsigned char *free_mem_70613;
    unsigned char *free_mem_70616;
    unsigned char *free_mem_70622;
    int64_t free_min_res_71872;
    int64_t free_max_res_71937;
    double free_defunc_1_f_res_71956;
    double free_a0_71979;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_72406;
};
static int futhark_mc_segred_stage_1_parloop_77111(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_72361, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77110
    *futhark_mc_segred_stage_1_parloop_struct_77110 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77110 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77110->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77111_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77111_start = get_wall_time();
    
    int64_t last_res_66900 =
            futhark_mc_segred_stage_1_parloop_struct_77110->free_last_res_66900;
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77110->free_mem_70613,
                                 .size =0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77110->free_mem_70616,
                                 .size =0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77110->free_mem_70622,
                                 .size =0, .references =NULL};
    int64_t min_res_71872 =
            futhark_mc_segred_stage_1_parloop_struct_77110->free_min_res_71872;
    int64_t max_res_71937 =
            futhark_mc_segred_stage_1_parloop_struct_77110->free_max_res_71937;
    double defunc_1_f_res_71956 =
           futhark_mc_segred_stage_1_parloop_struct_77110->free_defunc_1_f_res_71956;
    double a0_71979 =
           futhark_mc_segred_stage_1_parloop_struct_77110->free_a0_71979;
    struct memblock reduce_stage_1_tid_res_arr_mem_72406 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_72406",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77110->free_reduce_stage_1_tid_res_arr_mem_72406,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72408 = start;
    double x_72363;
    double x_72364;
    double local_acc_72409 = 0.0;
    
    for (; iter_72408 < end; iter_72408++) {
        int64_t gtid_72362 = iter_72408;
        double x_72366;
        
        x_72366 = ((double *) mem_70622.mem)[gtid_72362];
        
        bool cond_72367 = sle64(last_res_66900, gtid_72362);
        int64_t defunc_0_f_res_72368;
        
        if (cond_72367) {
            defunc_0_f_res_72368 = (int64_t) 0;
        } else {
            int64_t i_72369 = add64(max_res_71937, gtid_72362);
            int64_t defunc_0_add_arg_72370;
            
            defunc_0_add_arg_72370 = ((int64_t *) mem_70616.mem)[i_72369];
            
            int64_t defunc_1_add_res_72371 = add64((int64_t) 1,
                                                   defunc_0_add_arg_72370);
            
            defunc_0_f_res_72368 = defunc_1_add_res_72371;
        }
        
        int64_t binop_p_72372 = sub64(defunc_0_f_res_72368, min_res_71872);
        double defunc_0_f_res_72373 = sitofp_i64_f64(binop_p_72372);
        double abs_res_72374 = fabs(defunc_0_f_res_72373);
        double tmp1_72375 = abs_res_72374 / defunc_1_f_res_71956;
        double x_72376 = tmp1_72375 * tmp1_72375;
        double y_72377 = tmp1_72375 * x_72376;
        double tmp2_72378 = 1.0 - y_72377;
        double x_72379 = tmp2_72378 * tmp2_72378;
        double tmp3_72380 = tmp2_72378 * x_72379;
        double tmp4_72381 = x_72366 * tmp3_72380;
        double defunc_0_f_res_72382;
        
        if (cond_72367) {
            defunc_0_f_res_72382 = 0.0;
        } else {
            int64_t i_72383 = add64(max_res_71937, gtid_72362);
            double defunc_0_add_arg_72384;
            
            defunc_0_add_arg_72384 = ((double *) mem_70613.mem)[i_72383];
            defunc_0_f_res_72382 = defunc_0_add_arg_72384;
        }
        
        double x_72385 = a0_71979 * tmp4_72381;
        double defunc_9_fit_fun_res_72386 = defunc_0_f_res_72382 * x_72385;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_72363 = local_acc_72409;
        }
        // Load next params
        {
            x_72364 = defunc_9_fit_fun_res_72386;
        }
        // Red body
        {
            double defunc_1_op_res_72365 = x_72363 + x_72364;
            
            local_acc_72409 = defunc_1_op_res_72365;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_72406.mem)[flat_tid_72361] =
        local_acc_72409;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77111_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77111_end -
                 futhark_mc_segred_stage_1_parloop_77111_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77111_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77111_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77111_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77108(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72361 = tid;
    int num_tasks_72405 = info.nsubtasks;
    struct futhark_mc_task_77107 *futhark_mc_task_77107 =
                                 (struct futhark_mc_task_77107 *) args;
    struct futhark_context *ctx = futhark_mc_task_77107->ctx;
    uint64_t futhark_mc_segred_task_77108_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77108_start = get_wall_time();
    
    int64_t last_res_66900 = futhark_mc_task_77107->free_last_res_66900;
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_task_77107->free_mem_70613, .size =
                                 0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_task_77107->free_mem_70616, .size =
                                 0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_task_77107->free_mem_70622, .size =
                                 0, .references =NULL};
    int64_t min_res_71872 = futhark_mc_task_77107->free_min_res_71872;
    int64_t max_res_71937 = futhark_mc_task_77107->free_max_res_71937;
    double defunc_1_f_res_71956 =
           futhark_mc_task_77107->free_defunc_1_f_res_71956;
    double a0_71979 = futhark_mc_task_77107->free_a0_71979;
    double defunc_2_reduce_res_71980 =
           *futhark_mc_task_77107->retval_defunc_2_reduce_res_71980;
    size_t reduce_stage_1_tid_res_arr_mem_72406_cached_sizze_77109 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_72406 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_72406_cached_sizze_77109 <
        (size_t) ((int64_t) 8 * num_tasks_72405)) {
        reduce_stage_1_tid_res_arr_mem_72406 =
            realloc(reduce_stage_1_tid_res_arr_mem_72406, (int64_t) 8 *
                    num_tasks_72405);
        reduce_stage_1_tid_res_arr_mem_72406_cached_sizze_77109 = (int64_t) 8 *
            num_tasks_72405;
    }
    
    int64_t iter_72408;
    struct futhark_mc_segred_stage_1_parloop_struct_77110
    futhark_mc_segred_stage_1_parloop_struct_77110;
    
    futhark_mc_segred_stage_1_parloop_struct_77110.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_last_res_66900 =
        last_res_66900;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_mem_70613 =
        mem_70613.mem;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_mem_70616 =
        mem_70616.mem;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_mem_70622 =
        mem_70622.mem;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_min_res_71872 =
        min_res_71872;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_max_res_71937 =
        max_res_71937;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_defunc_1_f_res_71956 =
        defunc_1_f_res_71956;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_a0_71979 = a0_71979;
    futhark_mc_segred_stage_1_parloop_struct_77110.free_reduce_stage_1_tid_res_arr_mem_72406 =
        reduce_stage_1_tid_res_arr_mem_72406;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77111_task;
    
    futhark_mc_segred_stage_1_parloop_77111_task.name =
        "futhark_mc_segred_stage_1_parloop_77111";
    futhark_mc_segred_stage_1_parloop_77111_task.fn =
        futhark_mc_segred_stage_1_parloop_77111;
    futhark_mc_segred_stage_1_parloop_77111_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77110;
    futhark_mc_segred_stage_1_parloop_77111_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77111_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77111_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77111_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77111_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77111_task);
    
    if (futhark_mc_segred_stage_1_parloop_77111_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77111_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77111_total_end -
                 futhark_mc_segred_stage_1_parloop_77111_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77111_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77111_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77111_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_71980 = 0.0;
    }
    
    double x_72410;
    double x_72411;
    
    for (int32_t i_72413 = 0; i_72413 < num_tasks_72405; i_72413++) {
        flat_tid_72361 = i_72413;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_72410 = defunc_2_reduce_res_71980;
            }
            // load next params
            {
                x_72411 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_72406)[flat_tid_72361];
            }
            // red body
            {
                double defunc_1_op_res_72412 = x_72410 + x_72411;
                
                defunc_2_reduce_res_71980 = defunc_1_op_res_72412;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_72406);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77108_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77108_end -
                 futhark_mc_segred_task_77108_start;
        
        ctx->futhark_mc_segred_task_77108_runs[tid]++;
        ctx->futhark_mc_segred_task_77108_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77108_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77107->retval_defunc_2_reduce_res_71980 =
            defunc_2_reduce_res_71980;
    }
    return err;
}
static int futhark_mc_segmap_parloop_77101(void *args, int64_t start,
                                           int64_t end, int flat_tid_71869,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77100
    *futhark_mc_segmap_parloop_struct_77100 =
    (struct futhark_mc_segmap_parloop_struct_77100 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77100->ctx;
    uint64_t futhark_mc_segmap_parloop_77101_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77101_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77100->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77100->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77100->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77100->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77100->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77100->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77100->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77100->free_loop_cond_65403;
    int64_t last_res_66900 =
            futhark_mc_segmap_parloop_struct_77100->free_last_res_66900;
    int64_t min_arg_66919 =
            futhark_mc_segmap_parloop_struct_77100->free_min_arg_66919;
    int64_t min_arg_66920 =
            futhark_mc_segmap_parloop_struct_77100->free_min_arg_66920;
    int64_t min_res_66921 =
            futhark_mc_segmap_parloop_struct_77100->free_min_res_66921;
    double max_res_66925 =
           futhark_mc_segmap_parloop_struct_77100->free_max_res_66925;
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_segmap_parloop_struct_77100->free_mem_70613,
                                 .size =0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_segmap_parloop_struct_77100->free_mem_70616,
                                 .size =0, .references =NULL};
    struct memblock mem_70619 = {.desc ="mem_70619", .mem =
                                 futhark_mc_segmap_parloop_struct_77100->free_mem_70619,
                                 .size =0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_segmap_parloop_struct_77100->free_mem_70622,
                                 .size =0, .references =NULL};
    struct memblock mem_70625 = {.desc ="mem_70625", .mem =
                                 futhark_mc_segmap_parloop_struct_77100->free_mem_70625,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72284 = start;
    
    for (; iter_72284 < end; iter_72284++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72387 = n_m_65386;
        int64_t gtid_71870 = iter_72284;
        int64_t remnant_72388 = iter_72284 - gtid_71870;
        int64_t min_arg_71871 = mul64(jump_65382, gtid_71870);
        int64_t min_res_71872 = smin64(i_65392, min_arg_71871);
        int64_t defunc_0_g_res_71873 = add64((int64_t) 1, min_res_71872);
        bool init_idx_71874;
        int64_t init_idx_71875;
        int64_t init_idx_71876;
        bool loop_while_72285;
        int64_t low_72286;
        int64_t high_72287;
        
        loop_while_72285 = x_65393;
        low_72286 = (int64_t) 0;
        high_72287 = i_65392;
        while (loop_while_72285) {
            int64_t x_72288 = add64(low_72286, high_72287);
            int64_t mid_72289 = sdiv64(x_72288, (int64_t) 2);
            bool x_72290 = sle64((int64_t) 0, mid_72289);
            bool y_72291 = slt64(mid_72289, n_65378);
            bool bounds_check_72292 = x_72290 && y_72291;
            bool index_certs_72293;
            
            if (!bounds_check_72292) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_72289,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_72294;
            
            mid_id_72294 = ((int64_t *) mem_70619.mem)[mid_72289];
            
            bool cond_72295 = slt64(mid_id_72294, (int64_t) 0);
            int64_t mid_idx_72296;
            
            if (cond_72295) {
                mid_idx_72296 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_72296 = mid_id_72294;
            }
            
            bool cond_72297 = sle64(defunc_0_g_res_71873, mid_idx_72296);
            int64_t loopres_72298;
            int64_t loopres_72299;
            
            if (cond_72297) {
                int64_t loopres_t_res_72300 = sub64(mid_72289, (int64_t) 1);
                
                loopres_72298 = low_72286;
                loopres_72299 = loopres_t_res_72300;
            } else {
                int64_t loopres_f_res_72301 = add64((int64_t) 1, mid_72289);
                
                loopres_72298 = loopres_f_res_72301;
                loopres_72299 = high_72287;
            }
            
            bool loop_cond_72302 = sle64(loopres_72298, loopres_72299);
            bool loop_while_tmp_72389 = loop_cond_72302;
            int64_t low_tmp_72390 = loopres_72298;
            int64_t high_tmp_72391 = loopres_72299;
            
            loop_while_72285 = loop_while_tmp_72389;
            low_72286 = low_tmp_72390;
            high_72287 = high_tmp_72391;
        }
        init_idx_71874 = loop_while_72285;
        init_idx_71875 = low_72286;
        init_idx_71876 = high_72287;
        
        bool idx_71895;
        int64_t idx_71896;
        int64_t idx_71897;
        int64_t idx_71898;
        bool loop_while_72303;
        int64_t l_idx_72304;
        int64_t r_idx_72305;
        int64_t span_72306;
        
        loop_while_72303 = loop_cond_65403;
        l_idx_72304 = init_idx_71875;
        r_idx_72305 = init_idx_71875;
        span_72306 = (int64_t) 1;
        while (loop_while_72303) {
            int64_t max_arg_72307 = sub64(l_idx_72304, (int64_t) 1);
            int64_t max_res_72308 = smax64((int64_t) 0, max_arg_72307);
            int64_t min_arg_72309 = add64((int64_t) 1, r_idx_72305);
            int64_t min_res_72310 = smin64(min_arg_66919, min_arg_72309);
            bool x_72311 = sle64((int64_t) 0, max_res_72308);
            bool y_72312 = slt64(max_res_72308, n_65378);
            bool bounds_check_72313 = x_72311 && y_72312;
            bool index_certs_72314;
            
            if (!bounds_check_72313) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_72308,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_72315;
            
            x_72315 = ((int64_t *) mem_70619.mem)[max_res_72308];
            
            int64_t abs_arg_72316 = sub64(x_72315, defunc_0_g_res_71873);
            int64_t abs_res_72317 = abs64(abs_arg_72316);
            bool x_72318 = sle64((int64_t) 0, min_res_72310);
            bool y_72319 = slt64(min_res_72310, n_65378);
            bool bounds_check_72320 = x_72318 && y_72319;
            bool index_certs_72321;
            
            if (!bounds_check_72320) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_72310,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_72322;
            
            x_72322 = ((int64_t *) mem_70619.mem)[min_res_72310];
            
            int64_t abs_arg_72323 = sub64(x_72322, defunc_0_g_res_71873);
            int64_t abs_res_72324 = abs64(abs_arg_72323);
            bool cond_72325 = max_res_72308 == l_idx_72304;
            int64_t loopres_72326;
            int64_t loopres_72327;
            int64_t loopres_72328;
            
            if (cond_72325) {
                loopres_72326 = l_idx_72304;
                loopres_72327 = r_idx_72305;
                loopres_72328 = min_res_65398;
            } else {
                bool cond_72329 = slt64(abs_res_72317, abs_res_72324);
                bool cond_f_res_72330 = min_res_72310 == r_idx_72305;
                bool x_72331 = !cond_72329;
                bool y_72332 = cond_f_res_72330 && x_72331;
                bool cond_72333 = cond_72329 || y_72332;
                int64_t loopres_f_res_72334;
                
                if (cond_72333) {
                    loopres_f_res_72334 = max_res_72308;
                } else {
                    loopres_f_res_72334 = l_idx_72304;
                }
                
                int64_t loopres_f_res_72335;
                
                if (cond_72333) {
                    loopres_f_res_72335 = r_idx_72305;
                } else {
                    loopres_f_res_72335 = min_res_72310;
                }
                
                int64_t loopres_f_res_72336;
                
                if (cond_72333) {
                    int64_t loopres_f_res_t_res_72337 = add64((int64_t) 1,
                                                              span_72306);
                    
                    loopres_f_res_72336 = loopres_f_res_t_res_72337;
                } else {
                    int64_t loopres_f_res_f_res_72338 = add64((int64_t) 1,
                                                              span_72306);
                    
                    loopres_f_res_72336 = loopres_f_res_f_res_72338;
                }
                loopres_72326 = loopres_f_res_72334;
                loopres_72327 = loopres_f_res_72335;
                loopres_72328 = loopres_f_res_72336;
            }
            
            bool loop_cond_72339 = slt64(loopres_72328, min_res_65398);
            bool loop_while_tmp_72392 = loop_cond_72339;
            int64_t l_idx_tmp_72393 = loopres_72326;
            int64_t r_idx_tmp_72394 = loopres_72327;
            int64_t span_tmp_72395 = loopres_72328;
            
            loop_while_72303 = loop_while_tmp_72392;
            l_idx_72304 = l_idx_tmp_72393;
            r_idx_72305 = r_idx_tmp_72394;
            span_72306 = span_tmp_72395;
        }
        idx_71895 = loop_while_72303;
        idx_71896 = l_idx_72304;
        idx_71897 = r_idx_72305;
        idx_71898 = span_72306;
        
        int64_t min_res_71936 = smin64(min_arg_66920, idx_71896);
        int64_t max_res_71937 = smax64((int64_t) 0, min_res_71936);
        int64_t x_71938 = add64(min_res_66921, max_res_71937);
        int64_t r_71939 = sub64(x_71938, (int64_t) 1);
        bool x_71940 = sle64((int64_t) 0, r_71939);
        bool y_71941 = slt64(r_71939, n_65378);
        bool bounds_check_71942 = x_71940 && y_71941;
        bool index_certs_71943;
        
        if (!bounds_check_71942) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_71939,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_71944;
        
        x_71944 = ((int64_t *) mem_70616.mem)[r_71939];
        
        int64_t abs_arg_71945 = sub64(x_71944, min_res_71872);
        int64_t abs_res_71946 = abs64(abs_arg_71945);
        bool x_71947 = sle64((int64_t) 0, max_res_71937);
        bool y_71948 = slt64(max_res_71937, n_65378);
        bool bounds_check_71949 = x_71947 && y_71948;
        bool index_certs_71950;
        
        if (!bounds_check_71949) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_71937,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_71951;
        
        x_71951 = ((int64_t *) mem_70616.mem)[max_res_71937];
        
        int64_t abs_arg_71952 = sub64(x_71951, min_res_71872);
        int64_t abs_res_71953 = abs64(abs_arg_71952);
        int64_t max_res_71954 = smax64(abs_res_71946, abs_res_71953);
        double defunc_0_f_res_71955 = sitofp_i64_f64(max_res_71954);
        double defunc_1_f_res_71956 = max_res_66925 + defunc_0_f_res_71955;
        double defunc_2_reduce_res_71957;
        int64_t flat_tid_72340 = (int64_t) 0;
        int32_t num_tasks_72396;
        
        defunc_2_reduce_res_71957 = 0.0;
        
        struct futhark_mc_task_77102 futhark_mc_task_77102;
        
        futhark_mc_task_77102.ctx = ctx;
        futhark_mc_task_77102.free_last_res_66900 = last_res_66900;
        futhark_mc_task_77102.free_mem_70616 = mem_70616.mem;
        futhark_mc_task_77102.free_mem_70622 = mem_70622.mem;
        futhark_mc_task_77102.free_min_res_71872 = min_res_71872;
        futhark_mc_task_77102.free_max_res_71937 = max_res_71937;
        futhark_mc_task_77102.free_defunc_1_f_res_71956 = defunc_1_f_res_71956;
        futhark_mc_task_77102.retval_defunc_2_reduce_res_71957 =
            &defunc_2_reduce_res_71957;
        
        struct scheduler_segop futhark_mc_task_77102_task;
        
        futhark_mc_task_77102_task.args = &futhark_mc_task_77102;
        futhark_mc_task_77102_task.top_level_fn = futhark_mc_segred_task_77103;
        futhark_mc_task_77102_task.name = "futhark_mc_segred_task_77103";
        futhark_mc_task_77102_task.iterations = q_65380;
        futhark_mc_task_77102_task.task_time =
            &ctx->futhark_mc_segred_task_77103_total_time;
        futhark_mc_task_77102_task.task_iter =
            &ctx->futhark_mc_segred_task_77103_total_iter;
        futhark_mc_task_77102_task.sched = STATIC;
        futhark_mc_task_77102_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77103_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77102_task);
        
        if (futhark_mc_segred_task_77103_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double a0_71979 = 1.0 / defunc_2_reduce_res_71957;
        double defunc_2_reduce_res_71980;
        int64_t flat_tid_72361 = (int64_t) 0;
        int32_t num_tasks_72405;
        
        defunc_2_reduce_res_71980 = 0.0;
        
        struct futhark_mc_task_77107 futhark_mc_task_77107;
        
        futhark_mc_task_77107.ctx = ctx;
        futhark_mc_task_77107.free_last_res_66900 = last_res_66900;
        futhark_mc_task_77107.free_mem_70613 = mem_70613.mem;
        futhark_mc_task_77107.free_mem_70616 = mem_70616.mem;
        futhark_mc_task_77107.free_mem_70622 = mem_70622.mem;
        futhark_mc_task_77107.free_min_res_71872 = min_res_71872;
        futhark_mc_task_77107.free_max_res_71937 = max_res_71937;
        futhark_mc_task_77107.free_defunc_1_f_res_71956 = defunc_1_f_res_71956;
        futhark_mc_task_77107.free_a0_71979 = a0_71979;
        futhark_mc_task_77107.retval_defunc_2_reduce_res_71980 =
            &defunc_2_reduce_res_71980;
        
        struct scheduler_segop futhark_mc_task_77107_task;
        
        futhark_mc_task_77107_task.args = &futhark_mc_task_77107;
        futhark_mc_task_77107_task.top_level_fn = futhark_mc_segred_task_77108;
        futhark_mc_task_77107_task.name = "futhark_mc_segred_task_77108";
        futhark_mc_task_77107_task.iterations = q_65380;
        futhark_mc_task_77107_task.task_time =
            &ctx->futhark_mc_segred_task_77108_total_time;
        futhark_mc_task_77107_task.task_iter =
            &ctx->futhark_mc_segred_task_77108_total_iter;
        futhark_mc_task_77107_task.sched = STATIC;
        futhark_mc_task_77107_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77108_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77107_task);
        
        if (futhark_mc_segred_task_77108_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        ((double *) mem_70625.mem)[gtid_71870] = defunc_2_reduce_res_71980;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77101_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77101_end -
                 futhark_mc_segmap_parloop_77101_start;
        
        ctx->futhark_mc_segmap_parloop_77101_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77101_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77101_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77099(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_71869 = tid;
    int num_tasks_72173 = info.nsubtasks;
    struct futhark_mc_task_77095 *futhark_mc_task_77095 =
                                 (struct futhark_mc_task_77095 *) args;
    struct futhark_context *ctx = futhark_mc_task_77095->ctx;
    uint64_t futhark_mc_segmap_nested_task_77099_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77099_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77095->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77095->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77095->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77095->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77095->free_i_65392;
    bool x_65393 = futhark_mc_task_77095->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77095->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77095->free_loop_cond_65403;
    int64_t last_res_66900 = futhark_mc_task_77095->free_last_res_66900;
    int64_t min_arg_66919 = futhark_mc_task_77095->free_min_arg_66919;
    int64_t min_arg_66920 = futhark_mc_task_77095->free_min_arg_66920;
    int64_t min_res_66921 = futhark_mc_task_77095->free_min_res_66921;
    double max_res_66925 = futhark_mc_task_77095->free_max_res_66925;
    struct memblock mem_70613 = {.desc ="mem_70613", .mem =
                                 futhark_mc_task_77095->free_mem_70613, .size =
                                 0, .references =NULL};
    struct memblock mem_70616 = {.desc ="mem_70616", .mem =
                                 futhark_mc_task_77095->free_mem_70616, .size =
                                 0, .references =NULL};
    struct memblock mem_70619 = {.desc ="mem_70619", .mem =
                                 futhark_mc_task_77095->free_mem_70619, .size =
                                 0, .references =NULL};
    struct memblock mem_70622 = {.desc ="mem_70622", .mem =
                                 futhark_mc_task_77095->free_mem_70622, .size =
                                 0, .references =NULL};
    struct memblock mem_70625 = {.desc ="mem_70625", .mem =
                                 futhark_mc_task_77095->free_mem_70625, .size =
                                 0, .references =NULL};
    int64_t iter_72284;
    struct futhark_mc_segmap_parloop_struct_77100
    futhark_mc_segmap_parloop_struct_77100;
    
    futhark_mc_segmap_parloop_struct_77100.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77100.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77100.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77100.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77100.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77100.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77100.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77100.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77100.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77100.free_last_res_66900 = last_res_66900;
    futhark_mc_segmap_parloop_struct_77100.free_min_arg_66919 = min_arg_66919;
    futhark_mc_segmap_parloop_struct_77100.free_min_arg_66920 = min_arg_66920;
    futhark_mc_segmap_parloop_struct_77100.free_min_res_66921 = min_res_66921;
    futhark_mc_segmap_parloop_struct_77100.free_max_res_66925 = max_res_66925;
    futhark_mc_segmap_parloop_struct_77100.free_mem_70613 = mem_70613.mem;
    futhark_mc_segmap_parloop_struct_77100.free_mem_70616 = mem_70616.mem;
    futhark_mc_segmap_parloop_struct_77100.free_mem_70619 = mem_70619.mem;
    futhark_mc_segmap_parloop_struct_77100.free_mem_70622 = mem_70622.mem;
    futhark_mc_segmap_parloop_struct_77100.free_mem_70625 = mem_70625.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77101_task;
    
    futhark_mc_segmap_parloop_77101_task.name =
        "futhark_mc_segmap_parloop_77101";
    futhark_mc_segmap_parloop_77101_task.fn = futhark_mc_segmap_parloop_77101;
    futhark_mc_segmap_parloop_77101_task.args =
        &futhark_mc_segmap_parloop_struct_77100;
    futhark_mc_segmap_parloop_77101_task.iterations = iterations;
    futhark_mc_segmap_parloop_77101_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77101_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77101_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77101_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77101_task);
    
    if (futhark_mc_segmap_parloop_77101_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77101_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77101_total_end -
                 futhark_mc_segmap_parloop_77101_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77101_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77101_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77101_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77099_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77099_end -
                 futhark_mc_segmap_nested_task_77099_start;
        
        ctx->futhark_mc_segmap_nested_task_77099_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77099_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77099_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77069(void *args, int64_t start,
                                           int64_t end, int flat_tid_66887,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77068
    *futhark_mc_segmap_parloop_struct_77068 =
    (struct futhark_mc_segmap_parloop_struct_77068 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77068->ctx;
    uint64_t futhark_mc_segmap_parloop_77069_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77069_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77068->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77068->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77068->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77068->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77068->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77068->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77068->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77068->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77068->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77068->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77068->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70609 =
            futhark_mc_segmap_parloop_struct_77068->free_bytes_70609;
    int64_t bytes_70621 =
            futhark_mc_segmap_parloop_struct_77068->free_bytes_70621;
    int64_t bytes_70624 =
            futhark_mc_segmap_parloop_struct_77068->free_bytes_70624;
    struct memblock mem_70719 = {.desc ="mem_70719", .mem =
                                 futhark_mc_segmap_parloop_struct_77068->free_mem_70719,
                                 .size =0, .references =NULL};
    size_t mem_70610_cached_sizze_77070 = 0;
    unsigned char *mem_70610 = NULL;
    size_t mem_70613_cached_sizze_77071 = 0;
    unsigned char *mem_70613 = NULL;
    size_t mem_70616_cached_sizze_77072 = 0;
    unsigned char *mem_70616 = NULL;
    size_t mem_70619_cached_sizze_77073 = 0;
    unsigned char *mem_70619 = NULL;
    size_t mem_70622_cached_sizze_77074 = 0;
    unsigned char *mem_70622 = NULL;
    size_t mem_70625_cached_sizze_77075 = 0;
    unsigned char *mem_70625 = NULL;
    int64_t iterations = end - start;
    int64_t iter_71843 = start;
    
    if (mem_70610_cached_sizze_77070 < (size_t) bytes_70609) {
        mem_70610 = realloc(mem_70610, bytes_70609);
        mem_70610_cached_sizze_77070 = bytes_70609;
    }
    if (mem_70613_cached_sizze_77071 < (size_t) bytes_70609) {
        mem_70613 = realloc(mem_70613, bytes_70609);
        mem_70613_cached_sizze_77071 = bytes_70609;
    }
    if (mem_70616_cached_sizze_77072 < (size_t) bytes_70609) {
        mem_70616 = realloc(mem_70616, bytes_70609);
        mem_70616_cached_sizze_77072 = bytes_70609;
    }
    if (mem_70619_cached_sizze_77073 < (size_t) bytes_70609) {
        mem_70619 = realloc(mem_70619, bytes_70609);
        mem_70619_cached_sizze_77073 = bytes_70609;
    }
    if (mem_70622_cached_sizze_77074 < (size_t) bytes_70621) {
        mem_70622 = realloc(mem_70622, bytes_70621);
        mem_70622_cached_sizze_77074 = bytes_70621;
    }
    if (mem_70625_cached_sizze_77075 < (size_t) bytes_70624) {
        mem_70625 = realloc(mem_70625, bytes_70624);
        mem_70625_cached_sizze_77075 = bytes_70624;
    }
    for (; iter_71843 < end; iter_71843++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72141 = m_65377;
        int64_t gtid_66888 = iter_71843;
        int64_t remnant_72142 = iter_71843 - gtid_66888;
        int64_t flat_tid_71844 = (int64_t) 0;
        int32_t num_tasks_72143;
        
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmented segScan");
        
        struct futhark_mc_task_77076 futhark_mc_task_77076;
        
        futhark_mc_task_77076.ctx = ctx;
        futhark_mc_task_77076.free_n_65378 = n_65378;
        futhark_mc_task_77076.free_gtid_66888 = gtid_66888;
        futhark_mc_task_77076.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77076.free_mem_70610 = mem_70610;
        
        struct scheduler_segop futhark_mc_task_77076_task;
        
        futhark_mc_task_77076_task.args = &futhark_mc_task_77076;
        futhark_mc_task_77076_task.top_level_fn = futhark_mc_segscan_task_77077;
        futhark_mc_task_77076_task.name = "futhark_mc_segscan_task_77077";
        futhark_mc_task_77076_task.iterations = n_65378;
        futhark_mc_task_77076_task.task_time =
            &ctx->futhark_mc_segscan_task_77077_total_time;
        futhark_mc_task_77076_task.task_iter =
            &ctx->futhark_mc_segscan_task_77077_total_iter;
        futhark_mc_task_77076_task.sched = STATIC;
        futhark_mc_task_77076_task.nested_fn = NULL;
        
        int futhark_mc_segscan_task_77077_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77076_task);
        
        if (futhark_mc_segscan_task_77077_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t last_res_66900;
        
        last_res_66900 = ((int64_t *) mem_70610)[i_65392];
        for (int64_t i_72157 = 0; i_72157 < n_65378; i_72157++) {
            ((double *) mem_70613)[i_72157] = 0.0;
        }
        for (int64_t i_72158 = 0; i_72158 < n_65378; i_72158++) {
            ((int64_t *) mem_70616)[i_72158] = (int64_t) -1;
        }
        
        int64_t flat_tid_71853 = (int64_t) 0;
        int32_t num_tasks_72159;
        struct futhark_mc_task_77083 futhark_mc_task_77083;
        
        futhark_mc_task_77083.ctx = ctx;
        futhark_mc_task_77083.free_n_65378 = n_65378;
        futhark_mc_task_77083.free_gtid_66888 = gtid_66888;
        futhark_mc_task_77083.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77083.free_mem_70610 = mem_70610;
        futhark_mc_task_77083.free_mem_70613 = mem_70613;
        futhark_mc_task_77083.free_mem_70616 = mem_70616;
        
        struct scheduler_segop futhark_mc_task_77083_task;
        
        futhark_mc_task_77083_task.args = &futhark_mc_task_77083;
        futhark_mc_task_77083_task.top_level_fn = futhark_mc_segmap_task_77084;
        futhark_mc_task_77083_task.name = "futhark_mc_segmap_task_77084";
        futhark_mc_task_77083_task.iterations = n_65378;
        futhark_mc_task_77083_task.task_time =
            &ctx->futhark_mc_segmap_task_77084_total_time;
        futhark_mc_task_77083_task.task_iter =
            &ctx->futhark_mc_segmap_task_77084_total_iter;
        futhark_mc_task_77083_task.sched = STATIC;
        futhark_mc_task_77083_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77084_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77083_task);
        
        if (futhark_mc_segmap_task_77084_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_71861 = (int64_t) 0;
        int32_t num_tasks_72165;
        struct futhark_mc_task_77087 futhark_mc_task_77087;
        
        futhark_mc_task_77087.ctx = ctx;
        futhark_mc_task_77087.free_n_65378 = n_65378;
        futhark_mc_task_77087.free_mem_70616 = mem_70616;
        futhark_mc_task_77087.free_mem_70619 = mem_70619;
        
        struct scheduler_segop futhark_mc_task_77087_task;
        
        futhark_mc_task_77087_task.args = &futhark_mc_task_77087;
        futhark_mc_task_77087_task.top_level_fn = futhark_mc_segmap_task_77088;
        futhark_mc_task_77087_task.name = "futhark_mc_segmap_task_77088";
        futhark_mc_task_77087_task.iterations = n_65378;
        futhark_mc_task_77087_task.task_time =
            &ctx->futhark_mc_segmap_task_77088_total_time;
        futhark_mc_task_77087_task.task_iter =
            &ctx->futhark_mc_segmap_task_77088_total_iter;
        futhark_mc_task_77087_task.sched = STATIC;
        futhark_mc_task_77087_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77088_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77087_task);
        
        if (futhark_mc_segmap_task_77088_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t min_arg_66919 = sub64(last_res_66900, (int64_t) 1);
        int64_t min_arg_66920 = sub64(last_res_66900, min_res_65398);
        int64_t min_res_66921 = smin64(q_65380, last_res_66900);
        double i64_res_66922 = sitofp_i64_f64(last_res_66900);
        double x_66923 = i64_res_65404 - i64_res_66922;
        double max_arg_66924 = x_66923 / 2.0;
        double max_res_66925 = fmax64(0.0, max_arg_66924);
        int64_t flat_tid_71865 = (int64_t) 0;
        int32_t num_tasks_72169;
        struct futhark_mc_task_77091 futhark_mc_task_77091;
        
        futhark_mc_task_77091.ctx = ctx;
        futhark_mc_task_77091.free_q_65380 = q_65380;
        futhark_mc_task_77091.free_last_res_66900 = last_res_66900;
        futhark_mc_task_77091.free_mem_70622 = mem_70622;
        
        struct scheduler_segop futhark_mc_task_77091_task;
        
        futhark_mc_task_77091_task.args = &futhark_mc_task_77091;
        futhark_mc_task_77091_task.top_level_fn = futhark_mc_segmap_task_77092;
        futhark_mc_task_77091_task.name = "futhark_mc_segmap_task_77092";
        futhark_mc_task_77091_task.iterations = q_65380;
        futhark_mc_task_77091_task.task_time =
            &ctx->futhark_mc_segmap_task_77092_total_time;
        futhark_mc_task_77091_task.task_iter =
            &ctx->futhark_mc_segmap_task_77092_total_iter;
        futhark_mc_task_77091_task.sched = STATIC;
        futhark_mc_task_77091_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77092_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77091_task);
        
        if (futhark_mc_segmap_task_77092_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_72007 = (int64_t) 0;
        int32_t num_tasks_72173;
        int64_t flat_tid_71869 = (int64_t) 0;
        struct futhark_mc_task_77095 futhark_mc_task_77095;
        
        futhark_mc_task_77095.ctx = ctx;
        futhark_mc_task_77095.free_n_65378 = n_65378;
        futhark_mc_task_77095.free_q_65380 = q_65380;
        futhark_mc_task_77095.free_jump_65382 = jump_65382;
        futhark_mc_task_77095.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77095.free_i_65392 = i_65392;
        futhark_mc_task_77095.free_x_65393 = x_65393;
        futhark_mc_task_77095.free_min_res_65398 = min_res_65398;
        futhark_mc_task_77095.free_loop_cond_65403 = loop_cond_65403;
        futhark_mc_task_77095.free_last_res_66900 = last_res_66900;
        futhark_mc_task_77095.free_min_arg_66919 = min_arg_66919;
        futhark_mc_task_77095.free_min_arg_66920 = min_arg_66920;
        futhark_mc_task_77095.free_min_res_66921 = min_res_66921;
        futhark_mc_task_77095.free_max_res_66925 = max_res_66925;
        futhark_mc_task_77095.free_mem_70613 = mem_70613;
        futhark_mc_task_77095.free_mem_70616 = mem_70616;
        futhark_mc_task_77095.free_mem_70619 = mem_70619;
        futhark_mc_task_77095.free_mem_70622 = mem_70622;
        futhark_mc_task_77095.free_mem_70625 = mem_70625;
        
        struct scheduler_segop futhark_mc_task_77095_task;
        
        futhark_mc_task_77095_task.args = &futhark_mc_task_77095;
        futhark_mc_task_77095_task.top_level_fn = futhark_mc_segmap_task_77096;
        futhark_mc_task_77095_task.name = "futhark_mc_segmap_task_77096";
        futhark_mc_task_77095_task.iterations = n_m_65386;
        futhark_mc_task_77095_task.task_time =
            &ctx->futhark_mc_segmap_task_77096_total_time;
        futhark_mc_task_77095_task.task_iter =
            &ctx->futhark_mc_segmap_task_77096_total_iter;
        futhark_mc_task_77095_task.sched = DYNAMIC;
        futhark_mc_task_77095_task.nested_fn =
            futhark_mc_segmap_nested_task_77099;
        
        int futhark_mc_segmap_task_77096_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77095_task);
        
        if (futhark_mc_segmap_task_77096_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70719.mem + gtid_66888 * n_m_65386 * (int64_t) 8,
                    mem_70625 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70610);
    free(mem_70613);
    free(mem_70616);
    free(mem_70619);
    free(mem_70622);
    free(mem_70625);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77069_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77069_end -
                 futhark_mc_segmap_parloop_77069_start;
        
        ctx->futhark_mc_segmap_parloop_77069_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77069_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77069_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77067(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_66887 = tid;
    int num_tasks_71655 = info.nsubtasks;
    struct futhark_mc_task_77057 *futhark_mc_task_77057 =
                                 (struct futhark_mc_task_77057 *) args;
    struct futhark_context *ctx = futhark_mc_task_77057->ctx;
    uint64_t futhark_mc_segmap_nested_task_77067_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77067_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77057->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77057->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77057->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77057->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77057->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77057->free_i_65392;
    bool x_65393 = futhark_mc_task_77057->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77057->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77057->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77057->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77057->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70609 = futhark_mc_task_77057->free_bytes_70609;
    int64_t bytes_70621 = futhark_mc_task_77057->free_bytes_70621;
    int64_t bytes_70624 = futhark_mc_task_77057->free_bytes_70624;
    struct memblock mem_70719 = {.desc ="mem_70719", .mem =
                                 futhark_mc_task_77057->free_mem_70719, .size =
                                 0, .references =NULL};
    int64_t iter_71843;
    struct futhark_mc_segmap_parloop_struct_77068
    futhark_mc_segmap_parloop_struct_77068;
    
    futhark_mc_segmap_parloop_struct_77068.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77068.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77068.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77068.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77068.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77068.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77068.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77068.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77068.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77068.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77068.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77068.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77068.free_bytes_70609 = bytes_70609;
    futhark_mc_segmap_parloop_struct_77068.free_bytes_70621 = bytes_70621;
    futhark_mc_segmap_parloop_struct_77068.free_bytes_70624 = bytes_70624;
    futhark_mc_segmap_parloop_struct_77068.free_mem_70719 = mem_70719.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77069_task;
    
    futhark_mc_segmap_parloop_77069_task.name =
        "futhark_mc_segmap_parloop_77069";
    futhark_mc_segmap_parloop_77069_task.fn = futhark_mc_segmap_parloop_77069;
    futhark_mc_segmap_parloop_77069_task.args =
        &futhark_mc_segmap_parloop_struct_77068;
    futhark_mc_segmap_parloop_77069_task.iterations = iterations;
    futhark_mc_segmap_parloop_77069_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77069_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77069_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77069_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77069_task);
    
    if (futhark_mc_segmap_parloop_77069_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77069_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77069_total_end -
                 futhark_mc_segmap_parloop_77069_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77069_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77069_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77069_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77067_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77067_end -
                 futhark_mc_segmap_nested_task_77067_start;
        
        ctx->futhark_mc_segmap_nested_task_77067_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77067_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77067_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77112 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70721;
    int64_t free_bytes_70733;
    int64_t free_bytes_70736;
    unsigned char *free_mem_70849;
    unsigned char *free_mem_70853;
};
struct futhark_mc_segmap_parloop_struct_77114 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70721;
    int64_t free_bytes_70733;
    int64_t free_bytes_70736;
    unsigned char *free_mem_70849;
    unsigned char *free_mem_70853;
};
static int futhark_mc_segmap_parloop_77115(void *args, int64_t start,
                                           int64_t end, int flat_tid_67211,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77114
    *futhark_mc_segmap_parloop_struct_77114 =
    (struct futhark_mc_segmap_parloop_struct_77114 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77114->ctx;
    uint64_t futhark_mc_segmap_parloop_77115_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77115_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77114->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77114->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77114->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77114->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77114->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77114->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77114->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77114->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77114->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77114->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77114->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70721 =
            futhark_mc_segmap_parloop_struct_77114->free_bytes_70721;
    int64_t bytes_70733 =
            futhark_mc_segmap_parloop_struct_77114->free_bytes_70733;
    int64_t bytes_70736 =
            futhark_mc_segmap_parloop_struct_77114->free_bytes_70736;
    struct memblock mem_70849 = {.desc ="mem_70849", .mem =
                                 futhark_mc_segmap_parloop_struct_77114->free_mem_70849,
                                 .size =0, .references =NULL};
    struct memblock mem_70853 = {.desc ="mem_70853", .mem =
                                 futhark_mc_segmap_parloop_struct_77114->free_mem_70853,
                                 .size =0, .references =NULL};
    size_t mem_70743_cached_sizze_77116 = 0;
    unsigned char *mem_70743 = NULL;
    size_t mem_70758_cached_sizze_77117 = 0;
    unsigned char *mem_70758 = NULL;
    size_t mem_70761_cached_sizze_77118 = 0;
    unsigned char *mem_70761 = NULL;
    size_t mem_70788_cached_sizze_77119 = 0;
    unsigned char *mem_70788 = NULL;
    size_t mem_70803_cached_sizze_77120 = 0;
    unsigned char *mem_70803 = NULL;
    size_t mem_70818_cached_sizze_77121 = 0;
    unsigned char *mem_70818 = NULL;
    size_t mem_70821_cached_sizze_77122 = 0;
    unsigned char *mem_70821 = NULL;
    int64_t iterations = end - start;
    int64_t iter_72415 = start;
    
    if (mem_70743_cached_sizze_77116 < (size_t) bytes_70721) {
        mem_70743 = realloc(mem_70743, bytes_70721);
        mem_70743_cached_sizze_77116 = bytes_70721;
    }
    if (mem_70758_cached_sizze_77117 < (size_t) bytes_70721) {
        mem_70758 = realloc(mem_70758, bytes_70721);
        mem_70758_cached_sizze_77117 = bytes_70721;
    }
    if (mem_70761_cached_sizze_77118 < (size_t) bytes_70721) {
        mem_70761 = realloc(mem_70761, bytes_70721);
        mem_70761_cached_sizze_77118 = bytes_70721;
    }
    if (mem_70788_cached_sizze_77119 < (size_t) bytes_70721) {
        mem_70788 = realloc(mem_70788, bytes_70721);
        mem_70788_cached_sizze_77119 = bytes_70721;
    }
    if (mem_70803_cached_sizze_77120 < (size_t) bytes_70733) {
        mem_70803 = realloc(mem_70803, bytes_70733);
        mem_70803_cached_sizze_77120 = bytes_70733;
    }
    if (mem_70818_cached_sizze_77121 < (size_t) bytes_70736) {
        mem_70818 = realloc(mem_70818, bytes_70736);
        mem_70818_cached_sizze_77121 = bytes_70736;
    }
    if (mem_70821_cached_sizze_77122 < (size_t) bytes_70736) {
        mem_70821 = realloc(mem_70821, bytes_70736);
        mem_70821_cached_sizze_77122 = bytes_70736;
    }
    for (; iter_72415 < end; iter_72415++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72609 = m_65377;
        int64_t gtid_67212 = iter_72415;
        int64_t remnant_72610 = iter_72415 - gtid_67212;
        int64_t discard_70255;
        int64_t scanacc_72417 = (int64_t) 0;
        
        for (int64_t i_72416 = 0; i_72416 < n_65378; i_72416++) {
            double x_72419;
            
            x_72419 = ((double *) Y_mem_70603.mem)[gtid_67212 * n_65378 +
                                                   i_72416];
            
            bool isnan_res_72420;
            
            isnan_res_72420 = futrts_isnan64(x_72419);
            
            bool defunc_0_p_res_72421 = !isnan_res_72420;
            int64_t defunc_0_f_res_72422 = btoi_bool_i64(defunc_0_p_res_72421);
            int64_t defunc_1_op_res_72423 = add64(defunc_0_f_res_72422,
                                                  scanacc_72417);
            
            ((int64_t *) mem_70743)[i_72416] = defunc_1_op_res_72423;
            
            int64_t scanacc_tmp_72611 = defunc_1_op_res_72423;
            
            scanacc_72417 = scanacc_tmp_72611;
        }
        discard_70255 = scanacc_72417;
        
        int64_t last_res_65606;
        
        last_res_65606 = ((int64_t *) mem_70743)[i_65392];
        for (int64_t i_72613 = 0; i_72613 < n_65378; i_72613++) {
            ((double *) mem_70758)[i_72613] = 0.0;
        }
        for (int64_t i_72614 = 0; i_72614 < n_65378; i_72614++) {
            ((int64_t *) mem_70761)[i_72614] = (int64_t) -1;
        }
        for (int64_t write_iter_72425 = 0; write_iter_72425 < n_65378;
             write_iter_72425++) {
            double write_iv_72428;
            
            write_iv_72428 = ((double *) Y_mem_70603.mem)[gtid_67212 * n_65378 +
                                                          write_iter_72425];
            
            bool isnan_res_72429;
            
            isnan_res_72429 = futrts_isnan64(write_iv_72428);
            
            bool defunc_0_p_res_72430 = !isnan_res_72429;
            int64_t defunc_1_f_res_72431;
            
            if (defunc_0_p_res_72430) {
                int64_t write_iv_72432;
                
                write_iv_72432 = ((int64_t *) mem_70743)[write_iter_72425];
                
                int64_t defunc_1_f_res_t_res_72433 = sub64(write_iv_72432,
                                                           (int64_t) 1);
                
                defunc_1_f_res_72431 = defunc_1_f_res_t_res_72433;
            } else {
                defunc_1_f_res_72431 = (int64_t) -1;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_72431) &&
                slt64(defunc_1_f_res_72431, n_65378)) {
                ((int64_t *) mem_70761)[defunc_1_f_res_72431] =
                    write_iter_72425;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_72431) &&
                slt64(defunc_1_f_res_72431, n_65378)) {
                if ((int64_t) 8 > 0)
                    memmove(mem_70758 + defunc_1_f_res_72431 * (int64_t) 8,
                            Y_mem_70603.mem + (gtid_67212 * n_65378 +
                                               write_iter_72425) * (int64_t) 8,
                            (int64_t) 8);
            }
        }
        for (int64_t i_72437 = 0; i_72437 < n_65378; i_72437++) {
            int64_t x_72439;
            
            x_72439 = ((int64_t *) mem_70761)[i_72437];
            
            int64_t defunc_0_f_res_72440 = add64((int64_t) 1, x_72439);
            
            ((int64_t *) mem_70788)[i_72437] = defunc_0_f_res_72440;
        }
        
        int64_t min_arg_65621 = sub64(last_res_65606, (int64_t) 1);
        int64_t min_arg_65622 = sub64(last_res_65606, min_res_65398);
        int64_t min_res_65623 = smin64(q_65380, last_res_65606);
        double i64_res_65624 = sitofp_i64_f64(last_res_65606);
        double x_65625 = i64_res_65404 - i64_res_65624;
        double max_arg_65626 = x_65625 / 2.0;
        double max_res_65627 = fmax64(0.0, max_arg_65626);
        
        for (int64_t i_72442 = 0; i_72442 < q_65380; i_72442++) {
            bool cond_72444 = sle64(last_res_65606, i_72442);
            double defunc_0_f_res_72445;
            
            if (cond_72444) {
                defunc_0_f_res_72445 = 0.0;
            } else {
                defunc_0_f_res_72445 = 1.0;
            }
            ((double *) mem_70803)[i_72442] = defunc_0_f_res_72445;
        }
        for (int64_t i_72447 = 0; i_72447 < n_m_65386; i_72447++) {
            int64_t min_arg_72450 = mul64(jump_65382, i_72447);
            int64_t min_res_72451 = smin64(i_65392, min_arg_72450);
            int64_t defunc_0_g_res_72452 = add64((int64_t) 1, min_res_72451);
            bool init_idx_72453;
            int64_t init_idx_72454;
            int64_t init_idx_72455;
            bool loop_while_72456;
            int64_t low_72457;
            int64_t high_72458;
            
            loop_while_72456 = x_65393;
            low_72457 = (int64_t) 0;
            high_72458 = i_65392;
            while (loop_while_72456) {
                int64_t x_72459 = add64(low_72457, high_72458);
                int64_t mid_72460 = sdiv64(x_72459, (int64_t) 2);
                bool x_72461 = sle64((int64_t) 0, mid_72460);
                bool y_72462 = slt64(mid_72460, n_65378);
                bool bounds_check_72463 = x_72461 && y_72462;
                bool index_certs_72464;
                
                if (!bounds_check_72463) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) mid_72460,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t mid_id_72465;
                
                mid_id_72465 = ((int64_t *) mem_70788)[mid_72460];
                
                bool cond_72466 = slt64(mid_id_72465, (int64_t) 0);
                int64_t mid_idx_72467;
                
                if (cond_72466) {
                    mid_idx_72467 = (int64_t) 9223372036854775807;
                } else {
                    mid_idx_72467 = mid_id_72465;
                }
                
                bool cond_72468 = sle64(defunc_0_g_res_72452, mid_idx_72467);
                int64_t loopres_72469;
                int64_t loopres_72470;
                
                if (cond_72468) {
                    int64_t loopres_t_res_72471 = sub64(mid_72460, (int64_t) 1);
                    
                    loopres_72469 = low_72457;
                    loopres_72470 = loopres_t_res_72471;
                } else {
                    int64_t loopres_f_res_72472 = add64((int64_t) 1, mid_72460);
                    
                    loopres_72469 = loopres_f_res_72472;
                    loopres_72470 = high_72458;
                }
                
                bool loop_cond_72473 = sle64(loopres_72469, loopres_72470);
                bool loop_while_tmp_72621 = loop_cond_72473;
                int64_t low_tmp_72622 = loopres_72469;
                int64_t high_tmp_72623 = loopres_72470;
                
                loop_while_72456 = loop_while_tmp_72621;
                low_72457 = low_tmp_72622;
                high_72458 = high_tmp_72623;
            }
            init_idx_72453 = loop_while_72456;
            init_idx_72454 = low_72457;
            init_idx_72455 = high_72458;
            
            bool idx_72474;
            int64_t idx_72475;
            int64_t idx_72476;
            int64_t idx_72477;
            bool loop_while_72478;
            int64_t l_idx_72479;
            int64_t r_idx_72480;
            int64_t span_72481;
            
            loop_while_72478 = loop_cond_65403;
            l_idx_72479 = init_idx_72454;
            r_idx_72480 = init_idx_72454;
            span_72481 = (int64_t) 1;
            while (loop_while_72478) {
                int64_t max_arg_72482 = sub64(l_idx_72479, (int64_t) 1);
                int64_t max_res_72483 = smax64((int64_t) 0, max_arg_72482);
                int64_t min_arg_72484 = add64((int64_t) 1, r_idx_72480);
                int64_t min_res_72485 = smin64(min_arg_65621, min_arg_72484);
                bool x_72486 = sle64((int64_t) 0, max_res_72483);
                bool y_72487 = slt64(max_res_72483, n_65378);
                bool bounds_check_72488 = x_72486 && y_72487;
                bool index_certs_72489;
                
                if (!bounds_check_72488) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) max_res_72483,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_72490;
                
                x_72490 = ((int64_t *) mem_70788)[max_res_72483];
                
                int64_t abs_arg_72491 = sub64(x_72490, defunc_0_g_res_72452);
                int64_t abs_res_72492 = abs64(abs_arg_72491);
                bool x_72493 = sle64((int64_t) 0, min_res_72485);
                bool y_72494 = slt64(min_res_72485, n_65378);
                bool bounds_check_72495 = x_72493 && y_72494;
                bool index_certs_72496;
                
                if (!bounds_check_72495) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) min_res_72485,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_72497;
                
                x_72497 = ((int64_t *) mem_70788)[min_res_72485];
                
                int64_t abs_arg_72498 = sub64(x_72497, defunc_0_g_res_72452);
                int64_t abs_res_72499 = abs64(abs_arg_72498);
                bool cond_72500 = max_res_72483 == l_idx_72479;
                int64_t loopres_72501;
                int64_t loopres_72502;
                int64_t loopres_72503;
                
                if (cond_72500) {
                    loopres_72501 = l_idx_72479;
                    loopres_72502 = r_idx_72480;
                    loopres_72503 = min_res_65398;
                } else {
                    bool cond_72504 = slt64(abs_res_72492, abs_res_72499);
                    bool cond_f_res_72505 = min_res_72485 == r_idx_72480;
                    bool x_72506 = !cond_72504;
                    bool y_72507 = cond_f_res_72505 && x_72506;
                    bool cond_72508 = cond_72504 || y_72507;
                    int64_t loopres_f_res_72509;
                    
                    if (cond_72508) {
                        loopres_f_res_72509 = max_res_72483;
                    } else {
                        loopres_f_res_72509 = l_idx_72479;
                    }
                    
                    int64_t loopres_f_res_72510;
                    
                    if (cond_72508) {
                        loopres_f_res_72510 = r_idx_72480;
                    } else {
                        loopres_f_res_72510 = min_res_72485;
                    }
                    
                    int64_t loopres_f_res_72511;
                    
                    if (cond_72508) {
                        int64_t loopres_f_res_t_res_72512 = add64((int64_t) 1,
                                                                  span_72481);
                        
                        loopres_f_res_72511 = loopres_f_res_t_res_72512;
                    } else {
                        int64_t loopres_f_res_f_res_72513 = add64((int64_t) 1,
                                                                  span_72481);
                        
                        loopres_f_res_72511 = loopres_f_res_f_res_72513;
                    }
                    loopres_72501 = loopres_f_res_72509;
                    loopres_72502 = loopres_f_res_72510;
                    loopres_72503 = loopres_f_res_72511;
                }
                
                bool loop_cond_72514 = slt64(loopres_72503, min_res_65398);
                bool loop_while_tmp_72624 = loop_cond_72514;
                int64_t l_idx_tmp_72625 = loopres_72501;
                int64_t r_idx_tmp_72626 = loopres_72502;
                int64_t span_tmp_72627 = loopres_72503;
                
                loop_while_72478 = loop_while_tmp_72624;
                l_idx_72479 = l_idx_tmp_72625;
                r_idx_72480 = r_idx_tmp_72626;
                span_72481 = span_tmp_72627;
            }
            idx_72474 = loop_while_72478;
            idx_72475 = l_idx_72479;
            idx_72476 = r_idx_72480;
            idx_72477 = span_72481;
            
            int64_t min_res_72515 = smin64(min_arg_65622, idx_72475);
            int64_t max_res_72516 = smax64((int64_t) 0, min_res_72515);
            int64_t x_72517 = add64(min_res_65623, max_res_72516);
            int64_t r_72518 = sub64(x_72517, (int64_t) 1);
            bool x_72519 = sle64((int64_t) 0, r_72518);
            bool y_72520 = slt64(r_72518, n_65378);
            bool bounds_check_72521 = x_72519 && y_72520;
            bool index_certs_72522;
            
            if (!bounds_check_72521) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) r_72518,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_72523;
            
            x_72523 = ((int64_t *) mem_70761)[r_72518];
            
            int64_t abs_arg_72524 = sub64(x_72523, min_res_72451);
            int64_t abs_res_72525 = abs64(abs_arg_72524);
            bool x_72526 = sle64((int64_t) 0, max_res_72516);
            bool y_72527 = slt64(max_res_72516, n_65378);
            bool bounds_check_72528 = x_72526 && y_72527;
            bool index_certs_72529;
            
            if (!bounds_check_72528) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_72516,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_72530;
            
            x_72530 = ((int64_t *) mem_70761)[max_res_72516];
            
            int64_t abs_arg_72531 = sub64(x_72530, min_res_72451);
            int64_t abs_res_72532 = abs64(abs_arg_72531);
            int64_t max_res_72533 = smax64(abs_res_72525, abs_res_72532);
            double defunc_0_f_res_72534 = sitofp_i64_f64(max_res_72533);
            double defunc_1_f_res_72535 = max_res_65627 + defunc_0_f_res_72534;
            double defunc_2_reduce_res_72536;
            double defunc_2_reduce_res_72537;
            double defunc_2_reduce_res_72538;
            double redout_72540;
            double redout_72541;
            double redout_72542;
            
            redout_72540 = 0.0;
            redout_72541 = 0.0;
            redout_72542 = 0.0;
            for (int64_t i_72539 = 0; i_72539 < q_65380; i_72539++) {
                double x_72543;
                
                x_72543 = ((double *) mem_70803)[i_72539];
                
                bool cond_72544 = sle64(last_res_65606, i_72539);
                int64_t defunc_0_f_res_72545;
                
                if (cond_72544) {
                    defunc_0_f_res_72545 = (int64_t) 0;
                } else {
                    int64_t i_72546 = add64(max_res_72516, i_72539);
                    int64_t defunc_0_add_arg_72547;
                    
                    defunc_0_add_arg_72547 = ((int64_t *) mem_70761)[i_72546];
                    
                    int64_t defunc_1_add_res_72548 = add64((int64_t) 1,
                                                           defunc_0_add_arg_72547);
                    
                    defunc_0_f_res_72545 = defunc_1_add_res_72548;
                }
                
                int64_t binop_p_72549 = sub64(defunc_0_f_res_72545,
                                              min_res_72451);
                double defunc_0_f_res_72550 = sitofp_i64_f64(binop_p_72549);
                double abs_res_72551 = fabs(defunc_0_f_res_72550);
                double tmp1_72552 = abs_res_72551 / defunc_1_f_res_72535;
                double x_72553 = tmp1_72552 * tmp1_72552;
                double y_72554 = tmp1_72552 * x_72553;
                double tmp2_72555 = 1.0 - y_72554;
                double x_72556 = tmp2_72555 * tmp2_72555;
                double tmp3_72557 = tmp2_72555 * x_72556;
                double w_j_72558 = x_72543 * tmp3_72557;
                double xw_j_72559 = defunc_0_f_res_72550 * w_j_72558;
                double x2w_j_72560 = defunc_0_f_res_72550 * xw_j_72559;
                double defunc_1_op_res_72561 = w_j_72558 + redout_72540;
                double defunc_1_op_res_72562 = xw_j_72559 + redout_72541;
                double defunc_1_op_res_72563 = x2w_j_72560 + redout_72542;
                double redout_tmp_72628 = defunc_1_op_res_72561;
                double redout_tmp_72629 = defunc_1_op_res_72562;
                double redout_tmp_72630 = defunc_1_op_res_72563;
                
                redout_72540 = redout_tmp_72628;
                redout_72541 = redout_tmp_72629;
                redout_72542 = redout_tmp_72630;
            }
            defunc_2_reduce_res_72536 = redout_72540;
            defunc_2_reduce_res_72537 = redout_72541;
            defunc_2_reduce_res_72538 = redout_72542;
            
            double x_72564 = defunc_2_reduce_res_72536 *
                   defunc_2_reduce_res_72538;
            double y_72565 = defunc_2_reduce_res_72537 *
                   defunc_2_reduce_res_72537;
            double y_72566 = x_72564 - y_72565;
            double det1_72567 = 1.0 / y_72566;
            double a11_72568 = defunc_2_reduce_res_72538 * det1_72567;
            double x_72569 = 0.0 - defunc_2_reduce_res_72537;
            double b11_72570 = det1_72567 * x_72569;
            double c11_72571 = defunc_2_reduce_res_72536 * det1_72567;
            double defunc_2_reduce_res_72572;
            double defunc_2_reduce_res_72573;
            double redout_72575;
            double redout_72576;
            
            redout_72575 = 0.0;
            redout_72576 = 0.0;
            for (int64_t i_72574 = 0; i_72574 < q_65380; i_72574++) {
                double x_72577;
                
                x_72577 = ((double *) mem_70803)[i_72574];
                
                bool cond_72578 = sle64(last_res_65606, i_72574);
                int64_t defunc_0_f_res_72579;
                
                if (cond_72578) {
                    defunc_0_f_res_72579 = (int64_t) 0;
                } else {
                    int64_t i_72580 = add64(max_res_72516, i_72574);
                    int64_t defunc_0_add_arg_72581;
                    
                    defunc_0_add_arg_72581 = ((int64_t *) mem_70761)[i_72580];
                    
                    int64_t defunc_1_add_res_72582 = add64((int64_t) 1,
                                                           defunc_0_add_arg_72581);
                    
                    defunc_0_f_res_72579 = defunc_1_add_res_72582;
                }
                
                int64_t binop_p_72583 = sub64(defunc_0_f_res_72579,
                                              min_res_72451);
                double defunc_0_f_res_72584 = sitofp_i64_f64(binop_p_72583);
                double abs_res_72585 = fabs(defunc_0_f_res_72584);
                double tmp1_72586 = abs_res_72585 / defunc_1_f_res_72535;
                double x_72587 = tmp1_72586 * tmp1_72586;
                double y_72588 = tmp1_72586 * x_72587;
                double tmp2_72589 = 1.0 - y_72588;
                double x_72590 = tmp2_72589 * tmp2_72589;
                double tmp3_72591 = tmp2_72589 * x_72590;
                double tmp4_72592 = x_72577 * tmp3_72591;
                double defunc_1_f_res_72593 = defunc_0_f_res_72584 * tmp4_72592;
                double defunc_0_f_res_72594;
                
                if (cond_72578) {
                    defunc_0_f_res_72594 = 0.0;
                } else {
                    int64_t i_72595 = add64(max_res_72516, i_72574);
                    double defunc_0_add_arg_72596;
                    
                    defunc_0_add_arg_72596 = ((double *) mem_70758)[i_72595];
                    defunc_0_f_res_72594 = defunc_0_add_arg_72596;
                }
                
                double x_72597 = a11_72568 * tmp4_72592;
                double y_72598 = b11_72570 * defunc_1_f_res_72593;
                double x_72599 = x_72597 + y_72598;
                double defunc_9_fit_fun_res_72600 = defunc_0_f_res_72594 *
                       x_72599;
                double x_72601 = b11_72570 * tmp4_72592;
                double y_72602 = c11_72571 * defunc_1_f_res_72593;
                double x_72603 = x_72601 + y_72602;
                double defunc_9_slope_fun_res_72604 = defunc_0_f_res_72594 *
                       x_72603;
                double defunc_1_op_res_72605 = defunc_9_fit_fun_res_72600 +
                       redout_72575;
                double defunc_1_op_res_72606 = defunc_9_slope_fun_res_72604 +
                       redout_72576;
                double redout_tmp_72631 = defunc_1_op_res_72605;
                double redout_tmp_72632 = defunc_1_op_res_72606;
                
                redout_72575 = redout_tmp_72631;
                redout_72576 = redout_tmp_72632;
            }
            defunc_2_reduce_res_72572 = redout_72575;
            defunc_2_reduce_res_72573 = redout_72576;
            ((double *) mem_70818)[i_72447] = defunc_2_reduce_res_72572;
            ((double *) mem_70821)[i_72447] = defunc_2_reduce_res_72573;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70849.mem + gtid_67212 * n_m_65386 * (int64_t) 8,
                    mem_70818 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70853.mem + gtid_67212 * n_m_65386 * (int64_t) 8,
                    mem_70821 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70743);
    free(mem_70758);
    free(mem_70761);
    free(mem_70788);
    free(mem_70803);
    free(mem_70818);
    free(mem_70821);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77115_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77115_end -
                 futhark_mc_segmap_parloop_77115_start;
        
        ctx->futhark_mc_segmap_parloop_77115_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77115_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77115_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77113(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_67211 = tid;
    int num_tasks_72414 = info.nsubtasks;
    struct futhark_mc_task_77112 *futhark_mc_task_77112 =
                                 (struct futhark_mc_task_77112 *) args;
    struct futhark_context *ctx = futhark_mc_task_77112->ctx;
    uint64_t futhark_mc_segmap_task_77113_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77113_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77112->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77112->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77112->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77112->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77112->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77112->free_i_65392;
    bool x_65393 = futhark_mc_task_77112->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77112->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77112->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77112->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77112->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70721 = futhark_mc_task_77112->free_bytes_70721;
    int64_t bytes_70733 = futhark_mc_task_77112->free_bytes_70733;
    int64_t bytes_70736 = futhark_mc_task_77112->free_bytes_70736;
    struct memblock mem_70849 = {.desc ="mem_70849", .mem =
                                 futhark_mc_task_77112->free_mem_70849, .size =
                                 0, .references =NULL};
    struct memblock mem_70853 = {.desc ="mem_70853", .mem =
                                 futhark_mc_task_77112->free_mem_70853, .size =
                                 0, .references =NULL};
    int64_t iter_72415;
    struct futhark_mc_segmap_parloop_struct_77114
    futhark_mc_segmap_parloop_struct_77114;
    
    futhark_mc_segmap_parloop_struct_77114.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77114.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77114.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77114.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77114.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77114.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77114.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77114.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77114.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77114.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77114.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77114.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77114.free_bytes_70721 = bytes_70721;
    futhark_mc_segmap_parloop_struct_77114.free_bytes_70733 = bytes_70733;
    futhark_mc_segmap_parloop_struct_77114.free_bytes_70736 = bytes_70736;
    futhark_mc_segmap_parloop_struct_77114.free_mem_70849 = mem_70849.mem;
    futhark_mc_segmap_parloop_struct_77114.free_mem_70853 = mem_70853.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77115_task;
    
    futhark_mc_segmap_parloop_77115_task.name =
        "futhark_mc_segmap_parloop_77115";
    futhark_mc_segmap_parloop_77115_task.fn = futhark_mc_segmap_parloop_77115;
    futhark_mc_segmap_parloop_77115_task.args =
        &futhark_mc_segmap_parloop_struct_77114;
    futhark_mc_segmap_parloop_77115_task.iterations = iterations;
    futhark_mc_segmap_parloop_77115_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77115_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77115_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77115_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77115_task);
    
    if (futhark_mc_segmap_parloop_77115_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77115_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77115_total_end -
                 futhark_mc_segmap_parloop_77115_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77115_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77115_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77115_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77113_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77113_end -
                 futhark_mc_segmap_task_77113_start;
        
        ctx->futhark_mc_segmap_task_77113_runs[tid]++;
        ctx->futhark_mc_segmap_task_77113_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77113_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77124 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70721;
    int64_t free_bytes_70733;
    int64_t free_bytes_70736;
    unsigned char *free_mem_70849;
    unsigned char *free_mem_70853;
};
struct futhark_mc_task_77133 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_67401;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70722;
};
struct futhark_mc_scan_stage_1_parloop_struct_77136 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_67401;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70722;
};
static int futhark_mc_scan_stage_1_parloop_77137(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_72634, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_1_parloop_struct_77136
    *futhark_mc_scan_stage_1_parloop_struct_77136 =
    (struct futhark_mc_scan_stage_1_parloop_struct_77136 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_1_parloop_struct_77136->ctx;
    uint64_t futhark_mc_scan_stage_1_parloop_77137_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77137_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_1_parloop_struct_77136->free_n_65378;
    int64_t gtid_67401 =
            futhark_mc_scan_stage_1_parloop_struct_77136->free_gtid_67401;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_1_parloop_struct_77136->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70722 = {.desc ="mem_70722", .mem =
                                 futhark_mc_scan_stage_1_parloop_struct_77136->free_mem_70722,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72987 = start;
    int64_t x_72636;
    int64_t x_72637;
    
    x_72636 = (int64_t) 0;
    for (; iter_72987 < end; iter_72987++) {
        int64_t gtid_72635 = iter_72987;
        
        // stage 1 scan body
        {
            double x_72639;
            
            x_72639 = ((double *) Y_mem_70603.mem)[gtid_67401 * n_65378 +
                                                   gtid_72635];
            
            bool isnan_res_72640;
            
            isnan_res_72640 = futrts_isnan64(x_72639);
            
            bool defunc_0_p_res_72641 = !isnan_res_72640;
            int64_t defunc_0_f_res_72642 = btoi_bool_i64(defunc_0_p_res_72641);
            
            // write mapped values results to memory
            { }
            x_72636 = x_72636;
            // Read next values
            {
                x_72637 = defunc_0_f_res_72642;
            }
            
            int64_t defunc_1_op_res_72638 = add64(x_72636, x_72637);
            
            ((int64_t *) mem_70722.mem)[gtid_72635] = defunc_1_op_res_72638;
            x_72636 = defunc_1_op_res_72638;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77137_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77137_end -
                 futhark_mc_scan_stage_1_parloop_77137_start;
        
        ctx->futhark_mc_scan_stage_1_parloop_77137_runs[tid]++;
        ctx->futhark_mc_scan_stage_1_parloop_77137_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_1_parloop_77137_iter[tid] += iterations;
    }
    return err;
}
struct futhark_mc_scan_stage_3_parloop_struct_77138 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_67401;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70722;
};
static int futhark_mc_scan_stage_3_parloop_77139(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_72634, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_3_parloop_struct_77138
    *futhark_mc_scan_stage_3_parloop_struct_77138 =
    (struct futhark_mc_scan_stage_3_parloop_struct_77138 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_3_parloop_struct_77138->ctx;
    uint64_t futhark_mc_scan_stage_3_parloop_77139_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_3_parloop_77139_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_3_parloop_struct_77138->free_n_65378;
    int64_t gtid_67401 =
            futhark_mc_scan_stage_3_parloop_struct_77138->free_gtid_67401;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_3_parloop_struct_77138->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70722 = {.desc ="mem_70722", .mem =
                                 futhark_mc_scan_stage_3_parloop_struct_77138->free_mem_70722,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_72999 = start;
    int64_t x_72996;
    int64_t x_72997;
    
    if (iter_72999 == (int64_t) 0) {
        x_72996 = (int64_t) 0;
    } else {
        x_72996 = ((int64_t *) mem_70722.mem)[iter_72999 - (int64_t) 1];
    }
    for (; iter_72999 < end; iter_72999++) {
        int64_t gtid_72635 = iter_72999;
        
        // stage 3 scan body
        {
            double x_72639;
            
            x_72639 = ((double *) Y_mem_70603.mem)[gtid_67401 * n_65378 +
                                                   gtid_72635];
            
            bool isnan_res_72640;
            
            isnan_res_72640 = futrts_isnan64(x_72639);
            
            bool defunc_0_p_res_72641 = !isnan_res_72640;
            int64_t defunc_0_f_res_72642 = btoi_bool_i64(defunc_0_p_res_72641);
            
            x_72996 = x_72996;
            x_72997 = defunc_0_f_res_72642;
            
            int64_t defunc_1_op_res_72998 = add64(x_72996, x_72997);
            
            ((int64_t *) mem_70722.mem)[gtid_72635] = defunc_1_op_res_72998;
            x_72996 = defunc_1_op_res_72998;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_3_parloop_77139_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77139_end -
                 futhark_mc_scan_stage_3_parloop_77139_start;
        
        ctx->futhark_mc_scan_stage_3_parloop_77139_runs[tid]++;
        ctx->futhark_mc_scan_stage_3_parloop_77139_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_3_parloop_77139_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segscan_task_77134(void *args, int64_t iterations, int tid,
                                  struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72634 = tid;
    int num_tasks_72986 = info.nsubtasks;
    struct futhark_mc_task_77133 *futhark_mc_task_77133 =
                                 (struct futhark_mc_task_77133 *) args;
    struct futhark_context *ctx = futhark_mc_task_77133->ctx;
    uint64_t futhark_mc_segscan_task_77134_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segscan_task_77134_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77133->free_n_65378;
    int64_t gtid_67401 = futhark_mc_task_77133->free_gtid_67401;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77133->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70722 = {.desc ="mem_70722", .mem =
                                 futhark_mc_task_77133->free_mem_70722, .size =
                                 0, .references =NULL};
    size_t scan_stage_2_accum_mem_72993_cached_sizze_77135 = 0;
    unsigned char *scan_stage_2_accum_mem_72993 = NULL;
    int64_t iter_72987;
    struct futhark_mc_scan_stage_1_parloop_struct_77136
    futhark_mc_scan_stage_1_parloop_struct_77136;
    
    futhark_mc_scan_stage_1_parloop_struct_77136.ctx = ctx;
    futhark_mc_scan_stage_1_parloop_struct_77136.free_n_65378 = n_65378;
    futhark_mc_scan_stage_1_parloop_struct_77136.free_gtid_67401 = gtid_67401;
    futhark_mc_scan_stage_1_parloop_struct_77136.free_Y_mem_70603 =
        Y_mem_70603.mem;
    futhark_mc_scan_stage_1_parloop_struct_77136.free_mem_70722 = mem_70722.mem;
    
    struct scheduler_parloop futhark_mc_scan_stage_1_parloop_77137_task;
    
    futhark_mc_scan_stage_1_parloop_77137_task.name =
        "futhark_mc_scan_stage_1_parloop_77137";
    futhark_mc_scan_stage_1_parloop_77137_task.fn =
        futhark_mc_scan_stage_1_parloop_77137;
    futhark_mc_scan_stage_1_parloop_77137_task.args =
        &futhark_mc_scan_stage_1_parloop_struct_77136;
    futhark_mc_scan_stage_1_parloop_77137_task.iterations = iterations;
    futhark_mc_scan_stage_1_parloop_77137_task.info = info;
    
    uint64_t futhark_mc_scan_stage_1_parloop_77137_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77137_total_start = get_wall_time();
    
    int futhark_mc_scan_stage_1_parloop_77137_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_scan_stage_1_parloop_77137_task);
    
    if (futhark_mc_scan_stage_1_parloop_77137_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77137_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77137_total_end -
                 futhark_mc_scan_stage_1_parloop_77137_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77137_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77137_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77137_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    if (slt32(1, num_tasks_72986)) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmentedScan stage 2");
        
        int64_t x_72988;
        int64_t x_72989;
        int64_t offset_72991 = (int64_t) 0;
        int64_t offset_index_72992 = (int64_t) 0;
        
        if (scan_stage_2_accum_mem_72993_cached_sizze_77135 <
            (size_t) (int64_t) 8) {
            scan_stage_2_accum_mem_72993 = realloc(scan_stage_2_accum_mem_72993,
                                                   (int64_t) 8);
            scan_stage_2_accum_mem_72993_cached_sizze_77135 = (int64_t) 8;
        }
        ((int64_t *) scan_stage_2_accum_mem_72993)[(int64_t) 0] = (int64_t) 0;
        for (int32_t i_72995 = 0; i_72995 < num_tasks_72986 - 1; i_72995++) {
            offset_72991 = squot64(n_65378, sext_i32_i64(num_tasks_72986));
            if (slt64(sext_i32_i64(i_72995), srem64(n_65378,
                                                    sext_i32_i64(num_tasks_72986)))) {
                offset_72991 += (int64_t) 1;
            }
            offset_index_72992 += offset_72991;
            
            int64_t gtid_72635 = offset_index_72992;
            double x_72639;
            
            x_72639 = ((double *) Y_mem_70603.mem)[gtid_67401 * n_65378 +
                                                   gtid_72635];
            
            bool isnan_res_72640;
            
            isnan_res_72640 = futrts_isnan64(x_72639);
            
            bool defunc_0_p_res_72641 = !isnan_res_72640;
            int64_t defunc_0_f_res_72642 = btoi_bool_i64(defunc_0_p_res_72641);
            
            // Read carry in
            {
                x_72988 =
                    ((int64_t *) scan_stage_2_accum_mem_72993)[(int64_t) 0];
            }
            // Read next values
            {
                x_72989 = ((int64_t *) mem_70722.mem)[offset_index_72992 -
                                                      (int64_t) 1];
            }
            
            int64_t defunc_1_op_res_72990 = add64(x_72988, x_72989);
            
            ((int64_t *) mem_70722.mem)[offset_index_72992 - (int64_t) 1] =
                defunc_1_op_res_72990;
            ((int64_t *) scan_stage_2_accum_mem_72993)[(int64_t) 0] =
                defunc_1_op_res_72990;
        }
        
        int64_t iter_72999 = (int64_t) 0;
        struct futhark_mc_scan_stage_3_parloop_struct_77138
        futhark_mc_scan_stage_3_parloop_struct_77138;
        
        futhark_mc_scan_stage_3_parloop_struct_77138.ctx = ctx;
        futhark_mc_scan_stage_3_parloop_struct_77138.free_n_65378 = n_65378;
        futhark_mc_scan_stage_3_parloop_struct_77138.free_gtid_67401 =
            gtid_67401;
        futhark_mc_scan_stage_3_parloop_struct_77138.free_Y_mem_70603 =
            Y_mem_70603.mem;
        futhark_mc_scan_stage_3_parloop_struct_77138.free_mem_70722 =
            mem_70722.mem;
        
        struct scheduler_parloop futhark_mc_scan_stage_3_parloop_77139_task;
        
        futhark_mc_scan_stage_3_parloop_77139_task.name =
            "futhark_mc_scan_stage_3_parloop_77139";
        futhark_mc_scan_stage_3_parloop_77139_task.fn =
            futhark_mc_scan_stage_3_parloop_77139;
        futhark_mc_scan_stage_3_parloop_77139_task.args =
            &futhark_mc_scan_stage_3_parloop_struct_77138;
        futhark_mc_scan_stage_3_parloop_77139_task.iterations = iterations;
        futhark_mc_scan_stage_3_parloop_77139_task.info = info;
        
        uint64_t futhark_mc_scan_stage_3_parloop_77139_total_start = 0;
        
        if (ctx->profiling && !ctx->profiling_paused)
            futhark_mc_scan_stage_3_parloop_77139_total_start = get_wall_time();
        
        int futhark_mc_scan_stage_3_parloop_77139_err =
            scheduler_execute_task(&ctx->scheduler,
                                   &futhark_mc_scan_stage_3_parloop_77139_task);
        
        if (futhark_mc_scan_stage_3_parloop_77139_err != 0) {
            err = 1;
            goto cleanup;
        }
        if (ctx->profiling && !ctx->profiling_paused) {
            uint64_t futhark_mc_scan_stage_3_parloop_77139_total_end =
                     get_wall_time();
            uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77139_total_end -
                     futhark_mc_scan_stage_3_parloop_77139_total_start;
            
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77139_total_runs,
                               1, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77139_total_total_runtime,
                               elapsed, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77139_total_iter,
                               iterations, __ATOMIC_RELAXED);
        }
    }
    
  cleanup:
    {
        free(scan_stage_2_accum_mem_72993);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segscan_task_77134_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segscan_task_77134_end -
                 futhark_mc_segscan_task_77134_start;
        
        ctx->futhark_mc_segscan_task_77134_runs[tid]++;
        ctx->futhark_mc_segscan_task_77134_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segscan_task_77134_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77140 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_67401;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70722;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
};
struct futhark_mc_segmap_parloop_struct_77142 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_67401;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70722;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
};
static int futhark_mc_segmap_parloop_77143(void *args, int64_t start,
                                           int64_t end, int flat_tid_72643,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77142
    *futhark_mc_segmap_parloop_struct_77142 =
    (struct futhark_mc_segmap_parloop_struct_77142 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77142->ctx;
    uint64_t futhark_mc_segmap_parloop_77143_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77143_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77142->free_n_65378;
    int64_t gtid_67401 =
            futhark_mc_segmap_parloop_struct_77142->free_gtid_67401;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77142->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70722 = {.desc ="mem_70722", .mem =
                                 futhark_mc_segmap_parloop_struct_77142->free_mem_70722,
                                 .size =0, .references =NULL};
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_segmap_parloop_struct_77142->free_mem_70725,
                                 .size =0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_segmap_parloop_struct_77142->free_mem_70728,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73003 = start;
    
    for (; iter_73003 < end; iter_73003++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73006 = n_65378;
        int64_t gtid_72644 = iter_73003;
        int64_t remnant_73007 = iter_73003 - gtid_72644;
        double x_72645;
        
        x_72645 = ((double *) Y_mem_70603.mem)[gtid_67401 * n_65378 +
                                               gtid_72644];
        
        bool isnan_res_72646;
        
        isnan_res_72646 = futrts_isnan64(x_72645);
        
        bool defunc_0_p_res_72647 = !isnan_res_72646;
        int64_t defunc_1_f_res_72648;
        
        if (defunc_0_p_res_72647) {
            int64_t x_73004;
            
            x_73004 = ((int64_t *) mem_70722.mem)[gtid_72644];
            
            int64_t defunc_1_f_res_t_res_73005 = sub64(x_73004, (int64_t) 1);
            
            defunc_1_f_res_72648 = defunc_1_f_res_t_res_73005;
        } else {
            defunc_1_f_res_72648 = (int64_t) -1;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_72648) &&
            slt64(defunc_1_f_res_72648, n_65378)) {
            ((int64_t *) mem_70728.mem)[defunc_1_f_res_72648] = gtid_72644;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_72648) &&
            slt64(defunc_1_f_res_72648, n_65378)) {
            ((double *) mem_70725.mem)[defunc_1_f_res_72648] = x_72645;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77143_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77143_end -
                 futhark_mc_segmap_parloop_77143_start;
        
        ctx->futhark_mc_segmap_parloop_77143_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77143_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77143_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77141(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72643 = tid;
    int num_tasks_73002 = info.nsubtasks;
    struct futhark_mc_task_77140 *futhark_mc_task_77140 =
                                 (struct futhark_mc_task_77140 *) args;
    struct futhark_context *ctx = futhark_mc_task_77140->ctx;
    uint64_t futhark_mc_segmap_task_77141_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77141_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77140->free_n_65378;
    int64_t gtid_67401 = futhark_mc_task_77140->free_gtid_67401;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77140->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70722 = {.desc ="mem_70722", .mem =
                                 futhark_mc_task_77140->free_mem_70722, .size =
                                 0, .references =NULL};
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_task_77140->free_mem_70725, .size =
                                 0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_task_77140->free_mem_70728, .size =
                                 0, .references =NULL};
    int64_t iter_73003;
    struct futhark_mc_segmap_parloop_struct_77142
    futhark_mc_segmap_parloop_struct_77142;
    
    futhark_mc_segmap_parloop_struct_77142.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77142.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77142.free_gtid_67401 = gtid_67401;
    futhark_mc_segmap_parloop_struct_77142.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77142.free_mem_70722 = mem_70722.mem;
    futhark_mc_segmap_parloop_struct_77142.free_mem_70725 = mem_70725.mem;
    futhark_mc_segmap_parloop_struct_77142.free_mem_70728 = mem_70728.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77143_task;
    
    futhark_mc_segmap_parloop_77143_task.name =
        "futhark_mc_segmap_parloop_77143";
    futhark_mc_segmap_parloop_77143_task.fn = futhark_mc_segmap_parloop_77143;
    futhark_mc_segmap_parloop_77143_task.args =
        &futhark_mc_segmap_parloop_struct_77142;
    futhark_mc_segmap_parloop_77143_task.iterations = iterations;
    futhark_mc_segmap_parloop_77143_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77143_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77143_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77143_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77143_task);
    
    if (futhark_mc_segmap_parloop_77143_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77143_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77143_total_end -
                 futhark_mc_segmap_parloop_77143_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77143_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77143_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77143_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77141_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77141_end -
                 futhark_mc_segmap_task_77141_start;
        
        ctx->futhark_mc_segmap_task_77141_runs[tid]++;
        ctx->futhark_mc_segmap_task_77141_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77141_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77144 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70731;
};
struct futhark_mc_segmap_parloop_struct_77146 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70731;
};
static int futhark_mc_segmap_parloop_77147(void *args, int64_t start,
                                           int64_t end, int flat_tid_72651,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77146
    *futhark_mc_segmap_parloop_struct_77146 =
    (struct futhark_mc_segmap_parloop_struct_77146 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77146->ctx;
    uint64_t futhark_mc_segmap_parloop_77147_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77147_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77146->free_n_65378;
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_segmap_parloop_struct_77146->free_mem_70728,
                                 .size =0, .references =NULL};
    struct memblock mem_70731 = {.desc ="mem_70731", .mem =
                                 futhark_mc_segmap_parloop_struct_77146->free_mem_70731,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73009 = start;
    
    for (; iter_73009 < end; iter_73009++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73010 = n_65378;
        int64_t gtid_72652 = iter_73009;
        int64_t remnant_73011 = iter_73009 - gtid_72652;
        int64_t x_72653;
        
        x_72653 = ((int64_t *) mem_70728.mem)[gtid_72652];
        
        int64_t defunc_0_f_res_72654 = add64((int64_t) 1, x_72653);
        
        ((int64_t *) mem_70731.mem)[gtid_72652] = defunc_0_f_res_72654;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77147_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77147_end -
                 futhark_mc_segmap_parloop_77147_start;
        
        ctx->futhark_mc_segmap_parloop_77147_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77147_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77147_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77145(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72651 = tid;
    int num_tasks_73008 = info.nsubtasks;
    struct futhark_mc_task_77144 *futhark_mc_task_77144 =
                                 (struct futhark_mc_task_77144 *) args;
    struct futhark_context *ctx = futhark_mc_task_77144->ctx;
    uint64_t futhark_mc_segmap_task_77145_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77145_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77144->free_n_65378;
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_task_77144->free_mem_70728, .size =
                                 0, .references =NULL};
    struct memblock mem_70731 = {.desc ="mem_70731", .mem =
                                 futhark_mc_task_77144->free_mem_70731, .size =
                                 0, .references =NULL};
    int64_t iter_73009;
    struct futhark_mc_segmap_parloop_struct_77146
    futhark_mc_segmap_parloop_struct_77146;
    
    futhark_mc_segmap_parloop_struct_77146.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77146.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77146.free_mem_70728 = mem_70728.mem;
    futhark_mc_segmap_parloop_struct_77146.free_mem_70731 = mem_70731.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77147_task;
    
    futhark_mc_segmap_parloop_77147_task.name =
        "futhark_mc_segmap_parloop_77147";
    futhark_mc_segmap_parloop_77147_task.fn = futhark_mc_segmap_parloop_77147;
    futhark_mc_segmap_parloop_77147_task.args =
        &futhark_mc_segmap_parloop_struct_77146;
    futhark_mc_segmap_parloop_77147_task.iterations = iterations;
    futhark_mc_segmap_parloop_77147_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77147_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77147_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77147_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77147_task);
    
    if (futhark_mc_segmap_parloop_77147_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77147_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77147_total_end -
                 futhark_mc_segmap_parloop_77147_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77147_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77147_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77147_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77145_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77145_end -
                 futhark_mc_segmap_task_77145_start;
        
        ctx->futhark_mc_segmap_task_77145_runs[tid]++;
        ctx->futhark_mc_segmap_task_77145_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77145_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77148 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_67413;
    unsigned char *free_mem_70734;
};
struct futhark_mc_segmap_parloop_struct_77150 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_67413;
    unsigned char *free_mem_70734;
};
static int futhark_mc_segmap_parloop_77151(void *args, int64_t start,
                                           int64_t end, int flat_tid_72655,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77150
    *futhark_mc_segmap_parloop_struct_77150 =
    (struct futhark_mc_segmap_parloop_struct_77150 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77150->ctx;
    uint64_t futhark_mc_segmap_parloop_77151_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77151_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77150->free_q_65380;
    int64_t last_res_67413 =
            futhark_mc_segmap_parloop_struct_77150->free_last_res_67413;
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_segmap_parloop_struct_77150->free_mem_70734,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73013 = start;
    
    for (; iter_73013 < end; iter_73013++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73014 = q_65380;
        int64_t gtid_72656 = iter_73013;
        int64_t remnant_73015 = iter_73013 - gtid_72656;
        bool cond_72657 = sle64(last_res_67413, gtid_72656);
        double defunc_0_f_res_72658;
        
        if (cond_72657) {
            defunc_0_f_res_72658 = 0.0;
        } else {
            defunc_0_f_res_72658 = 1.0;
        }
        ((double *) mem_70734.mem)[gtid_72656] = defunc_0_f_res_72658;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77151_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77151_end -
                 futhark_mc_segmap_parloop_77151_start;
        
        ctx->futhark_mc_segmap_parloop_77151_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77151_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77151_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77149(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72655 = tid;
    int num_tasks_73012 = info.nsubtasks;
    struct futhark_mc_task_77148 *futhark_mc_task_77148 =
                                 (struct futhark_mc_task_77148 *) args;
    struct futhark_context *ctx = futhark_mc_task_77148->ctx;
    uint64_t futhark_mc_segmap_task_77149_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77149_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77148->free_q_65380;
    int64_t last_res_67413 = futhark_mc_task_77148->free_last_res_67413;
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_task_77148->free_mem_70734, .size =
                                 0, .references =NULL};
    int64_t iter_73013;
    struct futhark_mc_segmap_parloop_struct_77150
    futhark_mc_segmap_parloop_struct_77150;
    
    futhark_mc_segmap_parloop_struct_77150.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77150.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77150.free_last_res_67413 = last_res_67413;
    futhark_mc_segmap_parloop_struct_77150.free_mem_70734 = mem_70734.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77151_task;
    
    futhark_mc_segmap_parloop_77151_task.name =
        "futhark_mc_segmap_parloop_77151";
    futhark_mc_segmap_parloop_77151_task.fn = futhark_mc_segmap_parloop_77151;
    futhark_mc_segmap_parloop_77151_task.args =
        &futhark_mc_segmap_parloop_struct_77150;
    futhark_mc_segmap_parloop_77151_task.iterations = iterations;
    futhark_mc_segmap_parloop_77151_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77151_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77151_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77151_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77151_task);
    
    if (futhark_mc_segmap_parloop_77151_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77151_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77151_total_end -
                 futhark_mc_segmap_parloop_77151_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77151_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77151_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77151_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77149_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77149_end -
                 futhark_mc_segmap_task_77149_start;
        
        ctx->futhark_mc_segmap_task_77149_runs[tid]++;
        ctx->futhark_mc_segmap_task_77149_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77149_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77152 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_67413;
    int64_t free_min_arg_67432;
    int64_t free_min_arg_67433;
    int64_t free_min_res_67434;
    double free_max_res_67438;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70731;
    unsigned char *free_mem_70734;
    unsigned char *free_mem_70737;
    unsigned char *free_mem_70740;
};
struct futhark_mc_segmap_parloop_struct_77154 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_67413;
    int64_t free_min_arg_67432;
    int64_t free_min_arg_67433;
    int64_t free_min_res_67434;
    double free_max_res_67438;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70731;
    unsigned char *free_mem_70734;
    unsigned char *free_mem_70737;
    unsigned char *free_mem_70740;
};
static int futhark_mc_segmap_parloop_77155(void *args, int64_t start,
                                           int64_t end, int flat_tid_72825,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77154
    *futhark_mc_segmap_parloop_struct_77154 =
    (struct futhark_mc_segmap_parloop_struct_77154 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77154->ctx;
    uint64_t futhark_mc_segmap_parloop_77155_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77155_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77154->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77154->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77154->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77154->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77154->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77154->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77154->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77154->free_loop_cond_65403;
    int64_t last_res_67413 =
            futhark_mc_segmap_parloop_struct_77154->free_last_res_67413;
    int64_t min_arg_67432 =
            futhark_mc_segmap_parloop_struct_77154->free_min_arg_67432;
    int64_t min_arg_67433 =
            futhark_mc_segmap_parloop_struct_77154->free_min_arg_67433;
    int64_t min_res_67434 =
            futhark_mc_segmap_parloop_struct_77154->free_min_res_67434;
    double max_res_67438 =
           futhark_mc_segmap_parloop_struct_77154->free_max_res_67438;
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_segmap_parloop_struct_77154->free_mem_70725,
                                 .size =0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_segmap_parloop_struct_77154->free_mem_70728,
                                 .size =0, .references =NULL};
    struct memblock mem_70731 = {.desc ="mem_70731", .mem =
                                 futhark_mc_segmap_parloop_struct_77154->free_mem_70731,
                                 .size =0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_segmap_parloop_struct_77154->free_mem_70734,
                                 .size =0, .references =NULL};
    struct memblock mem_70737 = {.desc ="mem_70737", .mem =
                                 futhark_mc_segmap_parloop_struct_77154->free_mem_70737,
                                 .size =0, .references =NULL};
    struct memblock mem_70740 = {.desc ="mem_70740", .mem =
                                 futhark_mc_segmap_parloop_struct_77154->free_mem_70740,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73017 = start;
    
    for (; iter_73017 < end; iter_73017++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73131 = n_m_65386;
        int64_t gtid_72826 = iter_73017;
        int64_t remnant_73132 = iter_73017 - gtid_72826;
        int64_t min_arg_72827 = mul64(jump_65382, gtid_72826);
        int64_t min_res_72828 = smin64(i_65392, min_arg_72827);
        int64_t defunc_0_g_res_72829 = add64((int64_t) 1, min_res_72828);
        bool init_idx_72830;
        int64_t init_idx_72831;
        int64_t init_idx_72832;
        bool loop_while_73018;
        int64_t low_73019;
        int64_t high_73020;
        
        loop_while_73018 = x_65393;
        low_73019 = (int64_t) 0;
        high_73020 = i_65392;
        while (loop_while_73018) {
            int64_t x_73021 = add64(low_73019, high_73020);
            int64_t mid_73022 = sdiv64(x_73021, (int64_t) 2);
            bool x_73023 = sle64((int64_t) 0, mid_73022);
            bool y_73024 = slt64(mid_73022, n_65378);
            bool bounds_check_73025 = x_73023 && y_73024;
            bool index_certs_73026;
            
            if (!bounds_check_73025) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_73022,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_73027;
            
            mid_id_73027 = ((int64_t *) mem_70731.mem)[mid_73022];
            
            bool cond_73028 = slt64(mid_id_73027, (int64_t) 0);
            int64_t mid_idx_73029;
            
            if (cond_73028) {
                mid_idx_73029 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_73029 = mid_id_73027;
            }
            
            bool cond_73030 = sle64(defunc_0_g_res_72829, mid_idx_73029);
            int64_t loopres_73031;
            int64_t loopres_73032;
            
            if (cond_73030) {
                int64_t loopres_t_res_73033 = sub64(mid_73022, (int64_t) 1);
                
                loopres_73031 = low_73019;
                loopres_73032 = loopres_t_res_73033;
            } else {
                int64_t loopres_f_res_73034 = add64((int64_t) 1, mid_73022);
                
                loopres_73031 = loopres_f_res_73034;
                loopres_73032 = high_73020;
            }
            
            bool loop_cond_73035 = sle64(loopres_73031, loopres_73032);
            bool loop_while_tmp_73133 = loop_cond_73035;
            int64_t low_tmp_73134 = loopres_73031;
            int64_t high_tmp_73135 = loopres_73032;
            
            loop_while_73018 = loop_while_tmp_73133;
            low_73019 = low_tmp_73134;
            high_73020 = high_tmp_73135;
        }
        init_idx_72830 = loop_while_73018;
        init_idx_72831 = low_73019;
        init_idx_72832 = high_73020;
        
        bool idx_72851;
        int64_t idx_72852;
        int64_t idx_72853;
        int64_t idx_72854;
        bool loop_while_73036;
        int64_t l_idx_73037;
        int64_t r_idx_73038;
        int64_t span_73039;
        
        loop_while_73036 = loop_cond_65403;
        l_idx_73037 = init_idx_72831;
        r_idx_73038 = init_idx_72831;
        span_73039 = (int64_t) 1;
        while (loop_while_73036) {
            int64_t max_arg_73040 = sub64(l_idx_73037, (int64_t) 1);
            int64_t max_res_73041 = smax64((int64_t) 0, max_arg_73040);
            int64_t min_arg_73042 = add64((int64_t) 1, r_idx_73038);
            int64_t min_res_73043 = smin64(min_arg_67432, min_arg_73042);
            bool x_73044 = sle64((int64_t) 0, max_res_73041);
            bool y_73045 = slt64(max_res_73041, n_65378);
            bool bounds_check_73046 = x_73044 && y_73045;
            bool index_certs_73047;
            
            if (!bounds_check_73046) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_73041,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_73048;
            
            x_73048 = ((int64_t *) mem_70731.mem)[max_res_73041];
            
            int64_t abs_arg_73049 = sub64(x_73048, defunc_0_g_res_72829);
            int64_t abs_res_73050 = abs64(abs_arg_73049);
            bool x_73051 = sle64((int64_t) 0, min_res_73043);
            bool y_73052 = slt64(min_res_73043, n_65378);
            bool bounds_check_73053 = x_73051 && y_73052;
            bool index_certs_73054;
            
            if (!bounds_check_73053) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_73043,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_73055;
            
            x_73055 = ((int64_t *) mem_70731.mem)[min_res_73043];
            
            int64_t abs_arg_73056 = sub64(x_73055, defunc_0_g_res_72829);
            int64_t abs_res_73057 = abs64(abs_arg_73056);
            bool cond_73058 = max_res_73041 == l_idx_73037;
            int64_t loopres_73059;
            int64_t loopres_73060;
            int64_t loopres_73061;
            
            if (cond_73058) {
                loopres_73059 = l_idx_73037;
                loopres_73060 = r_idx_73038;
                loopres_73061 = min_res_65398;
            } else {
                bool cond_73062 = slt64(abs_res_73050, abs_res_73057);
                bool cond_f_res_73063 = min_res_73043 == r_idx_73038;
                bool x_73064 = !cond_73062;
                bool y_73065 = cond_f_res_73063 && x_73064;
                bool cond_73066 = cond_73062 || y_73065;
                int64_t loopres_f_res_73067;
                
                if (cond_73066) {
                    loopres_f_res_73067 = max_res_73041;
                } else {
                    loopres_f_res_73067 = l_idx_73037;
                }
                
                int64_t loopres_f_res_73068;
                
                if (cond_73066) {
                    loopres_f_res_73068 = r_idx_73038;
                } else {
                    loopres_f_res_73068 = min_res_73043;
                }
                
                int64_t loopres_f_res_73069;
                
                if (cond_73066) {
                    int64_t loopres_f_res_t_res_73070 = add64((int64_t) 1,
                                                              span_73039);
                    
                    loopres_f_res_73069 = loopres_f_res_t_res_73070;
                } else {
                    int64_t loopres_f_res_f_res_73071 = add64((int64_t) 1,
                                                              span_73039);
                    
                    loopres_f_res_73069 = loopres_f_res_f_res_73071;
                }
                loopres_73059 = loopres_f_res_73067;
                loopres_73060 = loopres_f_res_73068;
                loopres_73061 = loopres_f_res_73069;
            }
            
            bool loop_cond_73072 = slt64(loopres_73061, min_res_65398);
            bool loop_while_tmp_73136 = loop_cond_73072;
            int64_t l_idx_tmp_73137 = loopres_73059;
            int64_t r_idx_tmp_73138 = loopres_73060;
            int64_t span_tmp_73139 = loopres_73061;
            
            loop_while_73036 = loop_while_tmp_73136;
            l_idx_73037 = l_idx_tmp_73137;
            r_idx_73038 = r_idx_tmp_73138;
            span_73039 = span_tmp_73139;
        }
        idx_72851 = loop_while_73036;
        idx_72852 = l_idx_73037;
        idx_72853 = r_idx_73038;
        idx_72854 = span_73039;
        
        int64_t min_res_72892 = smin64(min_arg_67433, idx_72852);
        int64_t max_res_72893 = smax64((int64_t) 0, min_res_72892);
        int64_t x_72894 = add64(min_res_67434, max_res_72893);
        int64_t r_72895 = sub64(x_72894, (int64_t) 1);
        bool x_72896 = sle64((int64_t) 0, r_72895);
        bool y_72897 = slt64(r_72895, n_65378);
        bool bounds_check_72898 = x_72896 && y_72897;
        bool index_certs_72899;
        
        if (!bounds_check_72898) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_72895,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_72900;
        
        x_72900 = ((int64_t *) mem_70728.mem)[r_72895];
        
        int64_t abs_arg_72901 = sub64(x_72900, min_res_72828);
        int64_t abs_res_72902 = abs64(abs_arg_72901);
        bool x_72903 = sle64((int64_t) 0, max_res_72893);
        bool y_72904 = slt64(max_res_72893, n_65378);
        bool bounds_check_72905 = x_72903 && y_72904;
        bool index_certs_72906;
        
        if (!bounds_check_72905) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_72893,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_72907;
        
        x_72907 = ((int64_t *) mem_70728.mem)[max_res_72893];
        
        int64_t abs_arg_72908 = sub64(x_72907, min_res_72828);
        int64_t abs_res_72909 = abs64(abs_arg_72908);
        int64_t max_res_72910 = smax64(abs_res_72902, abs_res_72909);
        double defunc_0_f_res_72911 = sitofp_i64_f64(max_res_72910);
        double defunc_1_f_res_72912 = max_res_67438 + defunc_0_f_res_72911;
        double defunc_2_reduce_res_72913;
        double defunc_2_reduce_res_72914;
        double defunc_2_reduce_res_72915;
        double redout_73074;
        double redout_73075;
        double redout_73076;
        
        redout_73074 = 0.0;
        redout_73075 = 0.0;
        redout_73076 = 0.0;
        for (int64_t i_73073 = 0; i_73073 < q_65380; i_73073++) {
            double x_73077;
            
            x_73077 = ((double *) mem_70734.mem)[i_73073];
            
            bool cond_73078 = sle64(last_res_67413, i_73073);
            int64_t defunc_0_f_res_73079;
            
            if (cond_73078) {
                defunc_0_f_res_73079 = (int64_t) 0;
            } else {
                int64_t i_73080 = add64(max_res_72893, i_73073);
                int64_t defunc_0_add_arg_73081;
                
                defunc_0_add_arg_73081 = ((int64_t *) mem_70728.mem)[i_73080];
                
                int64_t defunc_1_add_res_73082 = add64((int64_t) 1,
                                                       defunc_0_add_arg_73081);
                
                defunc_0_f_res_73079 = defunc_1_add_res_73082;
            }
            
            int64_t binop_p_73083 = sub64(defunc_0_f_res_73079, min_res_72828);
            double defunc_0_f_res_73084 = sitofp_i64_f64(binop_p_73083);
            double abs_res_73085 = fabs(defunc_0_f_res_73084);
            double tmp1_73086 = abs_res_73085 / defunc_1_f_res_72912;
            double x_73087 = tmp1_73086 * tmp1_73086;
            double y_73088 = tmp1_73086 * x_73087;
            double tmp2_73089 = 1.0 - y_73088;
            double x_73090 = tmp2_73089 * tmp2_73089;
            double tmp3_73091 = tmp2_73089 * x_73090;
            double w_j_73092 = x_73077 * tmp3_73091;
            double xw_j_73093 = defunc_0_f_res_73084 * w_j_73092;
            double x2w_j_73094 = defunc_0_f_res_73084 * xw_j_73093;
            double defunc_1_op_res_73095 = w_j_73092 + redout_73074;
            double defunc_1_op_res_73096 = xw_j_73093 + redout_73075;
            double defunc_1_op_res_73097 = x2w_j_73094 + redout_73076;
            double redout_tmp_73140 = defunc_1_op_res_73095;
            double redout_tmp_73141 = defunc_1_op_res_73096;
            double redout_tmp_73142 = defunc_1_op_res_73097;
            
            redout_73074 = redout_tmp_73140;
            redout_73075 = redout_tmp_73141;
            redout_73076 = redout_tmp_73142;
        }
        defunc_2_reduce_res_72913 = redout_73074;
        defunc_2_reduce_res_72914 = redout_73075;
        defunc_2_reduce_res_72915 = redout_73076;
        
        double x_72941 = defunc_2_reduce_res_72913 * defunc_2_reduce_res_72915;
        double y_72942 = defunc_2_reduce_res_72914 * defunc_2_reduce_res_72914;
        double y_72943 = x_72941 - y_72942;
        double det1_72944 = 1.0 / y_72943;
        double a11_72945 = defunc_2_reduce_res_72915 * det1_72944;
        double x_72946 = 0.0 - defunc_2_reduce_res_72914;
        double b11_72947 = det1_72944 * x_72946;
        double c11_72948 = defunc_2_reduce_res_72913 * det1_72944;
        double defunc_2_reduce_res_72949;
        double defunc_2_reduce_res_72950;
        double redout_73099;
        double redout_73100;
        
        redout_73099 = 0.0;
        redout_73100 = 0.0;
        for (int64_t i_73098 = 0; i_73098 < q_65380; i_73098++) {
            double x_73101;
            
            x_73101 = ((double *) mem_70734.mem)[i_73098];
            
            bool cond_73102 = sle64(last_res_67413, i_73098);
            int64_t defunc_0_f_res_73103;
            
            if (cond_73102) {
                defunc_0_f_res_73103 = (int64_t) 0;
            } else {
                int64_t i_73104 = add64(max_res_72893, i_73098);
                int64_t defunc_0_add_arg_73105;
                
                defunc_0_add_arg_73105 = ((int64_t *) mem_70728.mem)[i_73104];
                
                int64_t defunc_1_add_res_73106 = add64((int64_t) 1,
                                                       defunc_0_add_arg_73105);
                
                defunc_0_f_res_73103 = defunc_1_add_res_73106;
            }
            
            int64_t binop_p_73107 = sub64(defunc_0_f_res_73103, min_res_72828);
            double defunc_0_f_res_73108 = sitofp_i64_f64(binop_p_73107);
            double abs_res_73109 = fabs(defunc_0_f_res_73108);
            double tmp1_73110 = abs_res_73109 / defunc_1_f_res_72912;
            double x_73111 = tmp1_73110 * tmp1_73110;
            double y_73112 = tmp1_73110 * x_73111;
            double tmp2_73113 = 1.0 - y_73112;
            double x_73114 = tmp2_73113 * tmp2_73113;
            double tmp3_73115 = tmp2_73113 * x_73114;
            double tmp4_73116 = x_73101 * tmp3_73115;
            double defunc_1_f_res_73117 = defunc_0_f_res_73108 * tmp4_73116;
            double defunc_0_f_res_73118;
            
            if (cond_73102) {
                defunc_0_f_res_73118 = 0.0;
            } else {
                int64_t i_73119 = add64(max_res_72893, i_73098);
                double defunc_0_add_arg_73120;
                
                defunc_0_add_arg_73120 = ((double *) mem_70725.mem)[i_73119];
                defunc_0_f_res_73118 = defunc_0_add_arg_73120;
            }
            
            double x_73121 = a11_72945 * tmp4_73116;
            double y_73122 = b11_72947 * defunc_1_f_res_73117;
            double x_73123 = x_73121 + y_73122;
            double defunc_9_fit_fun_res_73124 = defunc_0_f_res_73118 * x_73123;
            double x_73125 = b11_72947 * tmp4_73116;
            double y_73126 = c11_72948 * defunc_1_f_res_73117;
            double x_73127 = x_73125 + y_73126;
            double defunc_9_slope_fun_res_73128 = defunc_0_f_res_73118 *
                   x_73127;
            double defunc_1_op_res_73129 = defunc_9_fit_fun_res_73124 +
                   redout_73099;
            double defunc_1_op_res_73130 = defunc_9_slope_fun_res_73128 +
                   redout_73100;
            double redout_tmp_73143 = defunc_1_op_res_73129;
            double redout_tmp_73144 = defunc_1_op_res_73130;
            
            redout_73099 = redout_tmp_73143;
            redout_73100 = redout_tmp_73144;
        }
        defunc_2_reduce_res_72949 = redout_73099;
        defunc_2_reduce_res_72950 = redout_73100;
        ((double *) mem_70737.mem)[gtid_72826] = defunc_2_reduce_res_72949;
        ((double *) mem_70740.mem)[gtid_72826] = defunc_2_reduce_res_72950;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77155_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77155_end -
                 futhark_mc_segmap_parloop_77155_start;
        
        ctx->futhark_mc_segmap_parloop_77155_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77155_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77155_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77153(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72825 = tid;
    int num_tasks_73016 = info.nsubtasks;
    struct futhark_mc_task_77152 *futhark_mc_task_77152 =
                                 (struct futhark_mc_task_77152 *) args;
    struct futhark_context *ctx = futhark_mc_task_77152->ctx;
    uint64_t futhark_mc_segmap_task_77153_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77153_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77152->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77152->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77152->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77152->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77152->free_i_65392;
    bool x_65393 = futhark_mc_task_77152->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77152->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77152->free_loop_cond_65403;
    int64_t last_res_67413 = futhark_mc_task_77152->free_last_res_67413;
    int64_t min_arg_67432 = futhark_mc_task_77152->free_min_arg_67432;
    int64_t min_arg_67433 = futhark_mc_task_77152->free_min_arg_67433;
    int64_t min_res_67434 = futhark_mc_task_77152->free_min_res_67434;
    double max_res_67438 = futhark_mc_task_77152->free_max_res_67438;
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_task_77152->free_mem_70725, .size =
                                 0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_task_77152->free_mem_70728, .size =
                                 0, .references =NULL};
    struct memblock mem_70731 = {.desc ="mem_70731", .mem =
                                 futhark_mc_task_77152->free_mem_70731, .size =
                                 0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_task_77152->free_mem_70734, .size =
                                 0, .references =NULL};
    struct memblock mem_70737 = {.desc ="mem_70737", .mem =
                                 futhark_mc_task_77152->free_mem_70737, .size =
                                 0, .references =NULL};
    struct memblock mem_70740 = {.desc ="mem_70740", .mem =
                                 futhark_mc_task_77152->free_mem_70740, .size =
                                 0, .references =NULL};
    int64_t iter_73017;
    struct futhark_mc_segmap_parloop_struct_77154
    futhark_mc_segmap_parloop_struct_77154;
    
    futhark_mc_segmap_parloop_struct_77154.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77154.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77154.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77154.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77154.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77154.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77154.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77154.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77154.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77154.free_last_res_67413 = last_res_67413;
    futhark_mc_segmap_parloop_struct_77154.free_min_arg_67432 = min_arg_67432;
    futhark_mc_segmap_parloop_struct_77154.free_min_arg_67433 = min_arg_67433;
    futhark_mc_segmap_parloop_struct_77154.free_min_res_67434 = min_res_67434;
    futhark_mc_segmap_parloop_struct_77154.free_max_res_67438 = max_res_67438;
    futhark_mc_segmap_parloop_struct_77154.free_mem_70725 = mem_70725.mem;
    futhark_mc_segmap_parloop_struct_77154.free_mem_70728 = mem_70728.mem;
    futhark_mc_segmap_parloop_struct_77154.free_mem_70731 = mem_70731.mem;
    futhark_mc_segmap_parloop_struct_77154.free_mem_70734 = mem_70734.mem;
    futhark_mc_segmap_parloop_struct_77154.free_mem_70737 = mem_70737.mem;
    futhark_mc_segmap_parloop_struct_77154.free_mem_70740 = mem_70740.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77155_task;
    
    futhark_mc_segmap_parloop_77155_task.name =
        "futhark_mc_segmap_parloop_77155";
    futhark_mc_segmap_parloop_77155_task.fn = futhark_mc_segmap_parloop_77155;
    futhark_mc_segmap_parloop_77155_task.args =
        &futhark_mc_segmap_parloop_struct_77154;
    futhark_mc_segmap_parloop_77155_task.iterations = iterations;
    futhark_mc_segmap_parloop_77155_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77155_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77155_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77155_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77155_task);
    
    if (futhark_mc_segmap_parloop_77155_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77155_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77155_total_end -
                 futhark_mc_segmap_parloop_77155_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77155_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77155_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77155_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77153_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77153_end -
                 futhark_mc_segmap_task_77153_start;
        
        ctx->futhark_mc_segmap_task_77153_runs[tid]++;
        ctx->futhark_mc_segmap_task_77153_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77153_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77157 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_67413;
    int64_t free_min_arg_67432;
    int64_t free_min_arg_67433;
    int64_t free_min_res_67434;
    double free_max_res_67438;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70731;
    unsigned char *free_mem_70734;
    unsigned char *free_mem_70737;
    unsigned char *free_mem_70740;
};
struct futhark_mc_task_77159 {
    struct futhark_context *ctx;
    int64_t free_last_res_67413;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70734;
    int64_t free_min_res_72662;
    int64_t free_max_res_72727;
    double free_defunc_1_f_res_72746;
    double *retval_defunc_2_reduce_res_72747;
    double *retval_defunc_2_reduce_res_72748;
    double *retval_defunc_2_reduce_res_72749;
};
struct futhark_mc_segred_stage_1_parloop_struct_77164 {
    struct futhark_context *ctx;
    int64_t free_last_res_67413;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70734;
    int64_t free_min_res_72662;
    int64_t free_max_res_72727;
    double free_defunc_1_f_res_72746;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_73276;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_73278;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_73280;
};
static int futhark_mc_segred_stage_1_parloop_77165(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_73201, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77164
    *futhark_mc_segred_stage_1_parloop_struct_77164 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77164 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77164->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77165_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77165_start = get_wall_time();
    
    int64_t last_res_67413 =
            futhark_mc_segred_stage_1_parloop_struct_77164->free_last_res_67413;
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77164->free_mem_70728,
                                 .size =0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77164->free_mem_70734,
                                 .size =0, .references =NULL};
    int64_t min_res_72662 =
            futhark_mc_segred_stage_1_parloop_struct_77164->free_min_res_72662;
    int64_t max_res_72727 =
            futhark_mc_segred_stage_1_parloop_struct_77164->free_max_res_72727;
    double defunc_1_f_res_72746 =
           futhark_mc_segred_stage_1_parloop_struct_77164->free_defunc_1_f_res_72746;
    struct memblock reduce_stage_1_tid_res_arr_mem_73276 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_73276",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77164->free_reduce_stage_1_tid_res_arr_mem_73276,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_73278 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_73278",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77164->free_reduce_stage_1_tid_res_arr_mem_73278,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_73280 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_73280",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77164->free_reduce_stage_1_tid_res_arr_mem_73280,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73282 = start;
    double x_73203;
    double x_73204;
    double x_73206;
    double x_73207;
    double x_73209;
    double x_73210;
    double local_acc_73283 = 0.0;
    double local_acc_73284 = 0.0;
    double local_acc_73285 = 0.0;
    
    for (; iter_73282 < end; iter_73282++) {
        int64_t gtid_73202 = iter_73282;
        double x_73212;
        
        x_73212 = ((double *) mem_70734.mem)[gtid_73202];
        
        bool cond_73213 = sle64(last_res_67413, gtid_73202);
        int64_t defunc_0_f_res_73214;
        
        if (cond_73213) {
            defunc_0_f_res_73214 = (int64_t) 0;
        } else {
            int64_t i_73215 = add64(max_res_72727, gtid_73202);
            int64_t defunc_0_add_arg_73216;
            
            defunc_0_add_arg_73216 = ((int64_t *) mem_70728.mem)[i_73215];
            
            int64_t defunc_1_add_res_73217 = add64((int64_t) 1,
                                                   defunc_0_add_arg_73216);
            
            defunc_0_f_res_73214 = defunc_1_add_res_73217;
        }
        
        int64_t binop_p_73218 = sub64(defunc_0_f_res_73214, min_res_72662);
        double defunc_0_f_res_73219 = sitofp_i64_f64(binop_p_73218);
        double abs_res_73220 = fabs(defunc_0_f_res_73219);
        double tmp1_73221 = abs_res_73220 / defunc_1_f_res_72746;
        double x_73222 = tmp1_73221 * tmp1_73221;
        double y_73223 = tmp1_73221 * x_73222;
        double tmp2_73224 = 1.0 - y_73223;
        double x_73225 = tmp2_73224 * tmp2_73224;
        double tmp3_73226 = tmp2_73224 * x_73225;
        double w_j_73227 = x_73212 * tmp3_73226;
        double xw_j_73228 = defunc_0_f_res_73219 * w_j_73227;
        double x2w_j_73229 = defunc_0_f_res_73219 * xw_j_73228;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_73203 = local_acc_73283;
        }
        // Load next params
        {
            x_73204 = w_j_73227;
        }
        // Red body
        {
            double defunc_1_op_res_73205 = x_73203 + x_73204;
            
            local_acc_73283 = defunc_1_op_res_73205;
        }
        // Load accum params
        {
            x_73206 = local_acc_73284;
        }
        // Load next params
        {
            x_73207 = xw_j_73228;
        }
        // Red body
        {
            double defunc_1_op_res_73208 = x_73206 + x_73207;
            
            local_acc_73284 = defunc_1_op_res_73208;
        }
        // Load accum params
        {
            x_73209 = local_acc_73285;
        }
        // Load next params
        {
            x_73210 = x2w_j_73229;
        }
        // Red body
        {
            double defunc_1_op_res_73211 = x_73209 + x_73210;
            
            local_acc_73285 = defunc_1_op_res_73211;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_73276.mem)[flat_tid_73201] =
        local_acc_73283;
    ((double *) reduce_stage_1_tid_res_arr_mem_73278.mem)[flat_tid_73201] =
        local_acc_73284;
    ((double *) reduce_stage_1_tid_res_arr_mem_73280.mem)[flat_tid_73201] =
        local_acc_73285;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77165_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77165_end -
                 futhark_mc_segred_stage_1_parloop_77165_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77165_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77165_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77165_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77160(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73201 = tid;
    int num_tasks_73275 = info.nsubtasks;
    struct futhark_mc_task_77159 *futhark_mc_task_77159 =
                                 (struct futhark_mc_task_77159 *) args;
    struct futhark_context *ctx = futhark_mc_task_77159->ctx;
    uint64_t futhark_mc_segred_task_77160_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77160_start = get_wall_time();
    
    int64_t last_res_67413 = futhark_mc_task_77159->free_last_res_67413;
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_task_77159->free_mem_70728, .size =
                                 0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_task_77159->free_mem_70734, .size =
                                 0, .references =NULL};
    int64_t min_res_72662 = futhark_mc_task_77159->free_min_res_72662;
    int64_t max_res_72727 = futhark_mc_task_77159->free_max_res_72727;
    double defunc_1_f_res_72746 =
           futhark_mc_task_77159->free_defunc_1_f_res_72746;
    double defunc_2_reduce_res_72747 =
           *futhark_mc_task_77159->retval_defunc_2_reduce_res_72747;
    double defunc_2_reduce_res_72748 =
           *futhark_mc_task_77159->retval_defunc_2_reduce_res_72748;
    double defunc_2_reduce_res_72749 =
           *futhark_mc_task_77159->retval_defunc_2_reduce_res_72749;
    size_t reduce_stage_1_tid_res_arr_mem_73276_cached_sizze_77161 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_73276 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_73278_cached_sizze_77162 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_73278 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_73280_cached_sizze_77163 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_73280 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_73276_cached_sizze_77161 <
        (size_t) ((int64_t) 8 * num_tasks_73275)) {
        reduce_stage_1_tid_res_arr_mem_73276 =
            realloc(reduce_stage_1_tid_res_arr_mem_73276, (int64_t) 8 *
                    num_tasks_73275);
        reduce_stage_1_tid_res_arr_mem_73276_cached_sizze_77161 = (int64_t) 8 *
            num_tasks_73275;
    }
    if (reduce_stage_1_tid_res_arr_mem_73278_cached_sizze_77162 <
        (size_t) ((int64_t) 8 * num_tasks_73275)) {
        reduce_stage_1_tid_res_arr_mem_73278 =
            realloc(reduce_stage_1_tid_res_arr_mem_73278, (int64_t) 8 *
                    num_tasks_73275);
        reduce_stage_1_tid_res_arr_mem_73278_cached_sizze_77162 = (int64_t) 8 *
            num_tasks_73275;
    }
    if (reduce_stage_1_tid_res_arr_mem_73280_cached_sizze_77163 <
        (size_t) ((int64_t) 8 * num_tasks_73275)) {
        reduce_stage_1_tid_res_arr_mem_73280 =
            realloc(reduce_stage_1_tid_res_arr_mem_73280, (int64_t) 8 *
                    num_tasks_73275);
        reduce_stage_1_tid_res_arr_mem_73280_cached_sizze_77163 = (int64_t) 8 *
            num_tasks_73275;
    }
    
    int64_t iter_73282;
    struct futhark_mc_segred_stage_1_parloop_struct_77164
    futhark_mc_segred_stage_1_parloop_struct_77164;
    
    futhark_mc_segred_stage_1_parloop_struct_77164.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_last_res_67413 =
        last_res_67413;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_mem_70728 =
        mem_70728.mem;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_mem_70734 =
        mem_70734.mem;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_min_res_72662 =
        min_res_72662;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_max_res_72727 =
        max_res_72727;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_defunc_1_f_res_72746 =
        defunc_1_f_res_72746;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_reduce_stage_1_tid_res_arr_mem_73276 =
        reduce_stage_1_tid_res_arr_mem_73276;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_reduce_stage_1_tid_res_arr_mem_73278 =
        reduce_stage_1_tid_res_arr_mem_73278;
    futhark_mc_segred_stage_1_parloop_struct_77164.free_reduce_stage_1_tid_res_arr_mem_73280 =
        reduce_stage_1_tid_res_arr_mem_73280;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77165_task;
    
    futhark_mc_segred_stage_1_parloop_77165_task.name =
        "futhark_mc_segred_stage_1_parloop_77165";
    futhark_mc_segred_stage_1_parloop_77165_task.fn =
        futhark_mc_segred_stage_1_parloop_77165;
    futhark_mc_segred_stage_1_parloop_77165_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77164;
    futhark_mc_segred_stage_1_parloop_77165_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77165_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77165_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77165_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77165_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77165_task);
    
    if (futhark_mc_segred_stage_1_parloop_77165_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77165_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77165_total_end -
                 futhark_mc_segred_stage_1_parloop_77165_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77165_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77165_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77165_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_72747 = 0.0;
        defunc_2_reduce_res_72748 = 0.0;
        defunc_2_reduce_res_72749 = 0.0;
    }
    
    double x_73286;
    double x_73287;
    double x_73289;
    double x_73290;
    double x_73292;
    double x_73293;
    
    for (int32_t i_73295 = 0; i_73295 < num_tasks_73275; i_73295++) {
        flat_tid_73201 = i_73295;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_73286 = defunc_2_reduce_res_72747;
            }
            // load next params
            {
                x_73287 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_73276)[flat_tid_73201];
            }
            // red body
            {
                double defunc_1_op_res_73288 = x_73286 + x_73287;
                
                defunc_2_reduce_res_72747 = defunc_1_op_res_73288;
            }
            // load acc params
            {
                x_73289 = defunc_2_reduce_res_72748;
            }
            // load next params
            {
                x_73290 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_73278)[flat_tid_73201];
            }
            // red body
            {
                double defunc_1_op_res_73291 = x_73289 + x_73290;
                
                defunc_2_reduce_res_72748 = defunc_1_op_res_73291;
            }
            // load acc params
            {
                x_73292 = defunc_2_reduce_res_72749;
            }
            // load next params
            {
                x_73293 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_73280)[flat_tid_73201];
            }
            // red body
            {
                double defunc_1_op_res_73294 = x_73292 + x_73293;
                
                defunc_2_reduce_res_72749 = defunc_1_op_res_73294;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_73276);
        free(reduce_stage_1_tid_res_arr_mem_73278);
        free(reduce_stage_1_tid_res_arr_mem_73280);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77160_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77160_end -
                 futhark_mc_segred_task_77160_start;
        
        ctx->futhark_mc_segred_task_77160_runs[tid]++;
        ctx->futhark_mc_segred_task_77160_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77160_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77159->retval_defunc_2_reduce_res_72747 =
            defunc_2_reduce_res_72747;
        *futhark_mc_task_77159->retval_defunc_2_reduce_res_72748 =
            defunc_2_reduce_res_72748;
        *futhark_mc_task_77159->retval_defunc_2_reduce_res_72749 =
            defunc_2_reduce_res_72749;
    }
    return err;
}
struct futhark_mc_task_77166 {
    struct futhark_context *ctx;
    int64_t free_last_res_67413;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70734;
    int64_t free_min_res_72662;
    int64_t free_max_res_72727;
    double free_defunc_1_f_res_72746;
    double free_a11_72783;
    double free_b11_72785;
    double free_c11_72786;
    double *retval_defunc_2_reduce_res_72787;
    double *retval_defunc_2_reduce_res_72788;
};
struct futhark_mc_segred_stage_1_parloop_struct_77170 {
    struct futhark_context *ctx;
    int64_t free_last_res_67413;
    unsigned char *free_mem_70725;
    unsigned char *free_mem_70728;
    unsigned char *free_mem_70734;
    int64_t free_min_res_72662;
    int64_t free_max_res_72727;
    double free_defunc_1_f_res_72746;
    double free_a11_72783;
    double free_b11_72785;
    double free_c11_72786;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_73297;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_73299;
};
static int futhark_mc_segred_stage_1_parloop_77171(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_73230, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77170
    *futhark_mc_segred_stage_1_parloop_struct_77170 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77170 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77170->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77171_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77171_start = get_wall_time();
    
    int64_t last_res_67413 =
            futhark_mc_segred_stage_1_parloop_struct_77170->free_last_res_67413;
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77170->free_mem_70725,
                                 .size =0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77170->free_mem_70728,
                                 .size =0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77170->free_mem_70734,
                                 .size =0, .references =NULL};
    int64_t min_res_72662 =
            futhark_mc_segred_stage_1_parloop_struct_77170->free_min_res_72662;
    int64_t max_res_72727 =
            futhark_mc_segred_stage_1_parloop_struct_77170->free_max_res_72727;
    double defunc_1_f_res_72746 =
           futhark_mc_segred_stage_1_parloop_struct_77170->free_defunc_1_f_res_72746;
    double a11_72783 =
           futhark_mc_segred_stage_1_parloop_struct_77170->free_a11_72783;
    double b11_72785 =
           futhark_mc_segred_stage_1_parloop_struct_77170->free_b11_72785;
    double c11_72786 =
           futhark_mc_segred_stage_1_parloop_struct_77170->free_c11_72786;
    struct memblock reduce_stage_1_tid_res_arr_mem_73297 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_73297",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77170->free_reduce_stage_1_tid_res_arr_mem_73297,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_73299 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_73299",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77170->free_reduce_stage_1_tid_res_arr_mem_73299,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73301 = start;
    double x_73232;
    double x_73233;
    double x_73235;
    double x_73236;
    double local_acc_73302 = 0.0;
    double local_acc_73303 = 0.0;
    
    for (; iter_73301 < end; iter_73301++) {
        int64_t gtid_73231 = iter_73301;
        double x_73238;
        
        x_73238 = ((double *) mem_70734.mem)[gtid_73231];
        
        bool cond_73239 = sle64(last_res_67413, gtid_73231);
        int64_t defunc_0_f_res_73240;
        
        if (cond_73239) {
            defunc_0_f_res_73240 = (int64_t) 0;
        } else {
            int64_t i_73241 = add64(max_res_72727, gtid_73231);
            int64_t defunc_0_add_arg_73242;
            
            defunc_0_add_arg_73242 = ((int64_t *) mem_70728.mem)[i_73241];
            
            int64_t defunc_1_add_res_73243 = add64((int64_t) 1,
                                                   defunc_0_add_arg_73242);
            
            defunc_0_f_res_73240 = defunc_1_add_res_73243;
        }
        
        int64_t binop_p_73244 = sub64(defunc_0_f_res_73240, min_res_72662);
        double defunc_0_f_res_73245 = sitofp_i64_f64(binop_p_73244);
        double abs_res_73246 = fabs(defunc_0_f_res_73245);
        double tmp1_73247 = abs_res_73246 / defunc_1_f_res_72746;
        double x_73248 = tmp1_73247 * tmp1_73247;
        double y_73249 = tmp1_73247 * x_73248;
        double tmp2_73250 = 1.0 - y_73249;
        double x_73251 = tmp2_73250 * tmp2_73250;
        double tmp3_73252 = tmp2_73250 * x_73251;
        double tmp4_73253 = x_73238 * tmp3_73252;
        double defunc_1_f_res_73254 = defunc_0_f_res_73245 * tmp4_73253;
        double defunc_0_f_res_73255;
        
        if (cond_73239) {
            defunc_0_f_res_73255 = 0.0;
        } else {
            int64_t i_73256 = add64(max_res_72727, gtid_73231);
            double defunc_0_add_arg_73257;
            
            defunc_0_add_arg_73257 = ((double *) mem_70725.mem)[i_73256];
            defunc_0_f_res_73255 = defunc_0_add_arg_73257;
        }
        
        double x_73258 = a11_72783 * tmp4_73253;
        double y_73259 = b11_72785 * defunc_1_f_res_73254;
        double x_73260 = x_73258 + y_73259;
        double defunc_9_fit_fun_res_73261 = defunc_0_f_res_73255 * x_73260;
        double x_73262 = b11_72785 * tmp4_73253;
        double y_73263 = c11_72786 * defunc_1_f_res_73254;
        double x_73264 = x_73262 + y_73263;
        double defunc_9_slope_fun_res_73265 = defunc_0_f_res_73255 * x_73264;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_73232 = local_acc_73302;
        }
        // Load next params
        {
            x_73233 = defunc_9_fit_fun_res_73261;
        }
        // Red body
        {
            double defunc_1_op_res_73234 = x_73232 + x_73233;
            
            local_acc_73302 = defunc_1_op_res_73234;
        }
        // Load accum params
        {
            x_73235 = local_acc_73303;
        }
        // Load next params
        {
            x_73236 = defunc_9_slope_fun_res_73265;
        }
        // Red body
        {
            double defunc_1_op_res_73237 = x_73235 + x_73236;
            
            local_acc_73303 = defunc_1_op_res_73237;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_73297.mem)[flat_tid_73230] =
        local_acc_73302;
    ((double *) reduce_stage_1_tid_res_arr_mem_73299.mem)[flat_tid_73230] =
        local_acc_73303;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77171_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77171_end -
                 futhark_mc_segred_stage_1_parloop_77171_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77171_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77171_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77171_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77167(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73230 = tid;
    int num_tasks_73296 = info.nsubtasks;
    struct futhark_mc_task_77166 *futhark_mc_task_77166 =
                                 (struct futhark_mc_task_77166 *) args;
    struct futhark_context *ctx = futhark_mc_task_77166->ctx;
    uint64_t futhark_mc_segred_task_77167_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77167_start = get_wall_time();
    
    int64_t last_res_67413 = futhark_mc_task_77166->free_last_res_67413;
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_task_77166->free_mem_70725, .size =
                                 0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_task_77166->free_mem_70728, .size =
                                 0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_task_77166->free_mem_70734, .size =
                                 0, .references =NULL};
    int64_t min_res_72662 = futhark_mc_task_77166->free_min_res_72662;
    int64_t max_res_72727 = futhark_mc_task_77166->free_max_res_72727;
    double defunc_1_f_res_72746 =
           futhark_mc_task_77166->free_defunc_1_f_res_72746;
    double a11_72783 = futhark_mc_task_77166->free_a11_72783;
    double b11_72785 = futhark_mc_task_77166->free_b11_72785;
    double c11_72786 = futhark_mc_task_77166->free_c11_72786;
    double defunc_2_reduce_res_72787 =
           *futhark_mc_task_77166->retval_defunc_2_reduce_res_72787;
    double defunc_2_reduce_res_72788 =
           *futhark_mc_task_77166->retval_defunc_2_reduce_res_72788;
    size_t reduce_stage_1_tid_res_arr_mem_73297_cached_sizze_77168 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_73297 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_73299_cached_sizze_77169 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_73299 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_73297_cached_sizze_77168 <
        (size_t) ((int64_t) 8 * num_tasks_73296)) {
        reduce_stage_1_tid_res_arr_mem_73297 =
            realloc(reduce_stage_1_tid_res_arr_mem_73297, (int64_t) 8 *
                    num_tasks_73296);
        reduce_stage_1_tid_res_arr_mem_73297_cached_sizze_77168 = (int64_t) 8 *
            num_tasks_73296;
    }
    if (reduce_stage_1_tid_res_arr_mem_73299_cached_sizze_77169 <
        (size_t) ((int64_t) 8 * num_tasks_73296)) {
        reduce_stage_1_tid_res_arr_mem_73299 =
            realloc(reduce_stage_1_tid_res_arr_mem_73299, (int64_t) 8 *
                    num_tasks_73296);
        reduce_stage_1_tid_res_arr_mem_73299_cached_sizze_77169 = (int64_t) 8 *
            num_tasks_73296;
    }
    
    int64_t iter_73301;
    struct futhark_mc_segred_stage_1_parloop_struct_77170
    futhark_mc_segred_stage_1_parloop_struct_77170;
    
    futhark_mc_segred_stage_1_parloop_struct_77170.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_last_res_67413 =
        last_res_67413;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_mem_70725 =
        mem_70725.mem;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_mem_70728 =
        mem_70728.mem;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_mem_70734 =
        mem_70734.mem;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_min_res_72662 =
        min_res_72662;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_max_res_72727 =
        max_res_72727;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_defunc_1_f_res_72746 =
        defunc_1_f_res_72746;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_a11_72783 = a11_72783;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_b11_72785 = b11_72785;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_c11_72786 = c11_72786;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_reduce_stage_1_tid_res_arr_mem_73297 =
        reduce_stage_1_tid_res_arr_mem_73297;
    futhark_mc_segred_stage_1_parloop_struct_77170.free_reduce_stage_1_tid_res_arr_mem_73299 =
        reduce_stage_1_tid_res_arr_mem_73299;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77171_task;
    
    futhark_mc_segred_stage_1_parloop_77171_task.name =
        "futhark_mc_segred_stage_1_parloop_77171";
    futhark_mc_segred_stage_1_parloop_77171_task.fn =
        futhark_mc_segred_stage_1_parloop_77171;
    futhark_mc_segred_stage_1_parloop_77171_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77170;
    futhark_mc_segred_stage_1_parloop_77171_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77171_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77171_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77171_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77171_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77171_task);
    
    if (futhark_mc_segred_stage_1_parloop_77171_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77171_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77171_total_end -
                 futhark_mc_segred_stage_1_parloop_77171_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77171_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77171_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77171_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_72787 = 0.0;
        defunc_2_reduce_res_72788 = 0.0;
    }
    
    double x_73304;
    double x_73305;
    double x_73307;
    double x_73308;
    
    for (int32_t i_73310 = 0; i_73310 < num_tasks_73296; i_73310++) {
        flat_tid_73230 = i_73310;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_73304 = defunc_2_reduce_res_72787;
            }
            // load next params
            {
                x_73305 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_73297)[flat_tid_73230];
            }
            // red body
            {
                double defunc_1_op_res_73306 = x_73304 + x_73305;
                
                defunc_2_reduce_res_72787 = defunc_1_op_res_73306;
            }
            // load acc params
            {
                x_73307 = defunc_2_reduce_res_72788;
            }
            // load next params
            {
                x_73308 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_73299)[flat_tid_73230];
            }
            // red body
            {
                double defunc_1_op_res_73309 = x_73307 + x_73308;
                
                defunc_2_reduce_res_72788 = defunc_1_op_res_73309;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_73297);
        free(reduce_stage_1_tid_res_arr_mem_73299);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77167_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77167_end -
                 futhark_mc_segred_task_77167_start;
        
        ctx->futhark_mc_segred_task_77167_runs[tid]++;
        ctx->futhark_mc_segred_task_77167_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77167_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77166->retval_defunc_2_reduce_res_72787 =
            defunc_2_reduce_res_72787;
        *futhark_mc_task_77166->retval_defunc_2_reduce_res_72788 =
            defunc_2_reduce_res_72788;
    }
    return err;
}
static int futhark_mc_segmap_parloop_77158(void *args, int64_t start,
                                           int64_t end, int flat_tid_72659,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77157
    *futhark_mc_segmap_parloop_struct_77157 =
    (struct futhark_mc_segmap_parloop_struct_77157 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77157->ctx;
    uint64_t futhark_mc_segmap_parloop_77158_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77158_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77157->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77157->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77157->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77157->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77157->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77157->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77157->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77157->free_loop_cond_65403;
    int64_t last_res_67413 =
            futhark_mc_segmap_parloop_struct_77157->free_last_res_67413;
    int64_t min_arg_67432 =
            futhark_mc_segmap_parloop_struct_77157->free_min_arg_67432;
    int64_t min_arg_67433 =
            futhark_mc_segmap_parloop_struct_77157->free_min_arg_67433;
    int64_t min_res_67434 =
            futhark_mc_segmap_parloop_struct_77157->free_min_res_67434;
    double max_res_67438 =
           futhark_mc_segmap_parloop_struct_77157->free_max_res_67438;
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_segmap_parloop_struct_77157->free_mem_70725,
                                 .size =0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_segmap_parloop_struct_77157->free_mem_70728,
                                 .size =0, .references =NULL};
    struct memblock mem_70731 = {.desc ="mem_70731", .mem =
                                 futhark_mc_segmap_parloop_struct_77157->free_mem_70731,
                                 .size =0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_segmap_parloop_struct_77157->free_mem_70734,
                                 .size =0, .references =NULL};
    struct memblock mem_70737 = {.desc ="mem_70737", .mem =
                                 futhark_mc_segmap_parloop_struct_77157->free_mem_70737,
                                 .size =0, .references =NULL};
    struct memblock mem_70740 = {.desc ="mem_70740", .mem =
                                 futhark_mc_segmap_parloop_struct_77157->free_mem_70740,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73145 = start;
    
    for (; iter_73145 < end; iter_73145++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73266 = n_m_65386;
        int64_t gtid_72660 = iter_73145;
        int64_t remnant_73267 = iter_73145 - gtid_72660;
        int64_t min_arg_72661 = mul64(jump_65382, gtid_72660);
        int64_t min_res_72662 = smin64(i_65392, min_arg_72661);
        int64_t defunc_0_g_res_72663 = add64((int64_t) 1, min_res_72662);
        bool init_idx_72664;
        int64_t init_idx_72665;
        int64_t init_idx_72666;
        bool loop_while_73146;
        int64_t low_73147;
        int64_t high_73148;
        
        loop_while_73146 = x_65393;
        low_73147 = (int64_t) 0;
        high_73148 = i_65392;
        while (loop_while_73146) {
            int64_t x_73149 = add64(low_73147, high_73148);
            int64_t mid_73150 = sdiv64(x_73149, (int64_t) 2);
            bool x_73151 = sle64((int64_t) 0, mid_73150);
            bool y_73152 = slt64(mid_73150, n_65378);
            bool bounds_check_73153 = x_73151 && y_73152;
            bool index_certs_73154;
            
            if (!bounds_check_73153) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_73150,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_73155;
            
            mid_id_73155 = ((int64_t *) mem_70731.mem)[mid_73150];
            
            bool cond_73156 = slt64(mid_id_73155, (int64_t) 0);
            int64_t mid_idx_73157;
            
            if (cond_73156) {
                mid_idx_73157 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_73157 = mid_id_73155;
            }
            
            bool cond_73158 = sle64(defunc_0_g_res_72663, mid_idx_73157);
            int64_t loopres_73159;
            int64_t loopres_73160;
            
            if (cond_73158) {
                int64_t loopres_t_res_73161 = sub64(mid_73150, (int64_t) 1);
                
                loopres_73159 = low_73147;
                loopres_73160 = loopres_t_res_73161;
            } else {
                int64_t loopres_f_res_73162 = add64((int64_t) 1, mid_73150);
                
                loopres_73159 = loopres_f_res_73162;
                loopres_73160 = high_73148;
            }
            
            bool loop_cond_73163 = sle64(loopres_73159, loopres_73160);
            bool loop_while_tmp_73268 = loop_cond_73163;
            int64_t low_tmp_73269 = loopres_73159;
            int64_t high_tmp_73270 = loopres_73160;
            
            loop_while_73146 = loop_while_tmp_73268;
            low_73147 = low_tmp_73269;
            high_73148 = high_tmp_73270;
        }
        init_idx_72664 = loop_while_73146;
        init_idx_72665 = low_73147;
        init_idx_72666 = high_73148;
        
        bool idx_72685;
        int64_t idx_72686;
        int64_t idx_72687;
        int64_t idx_72688;
        bool loop_while_73164;
        int64_t l_idx_73165;
        int64_t r_idx_73166;
        int64_t span_73167;
        
        loop_while_73164 = loop_cond_65403;
        l_idx_73165 = init_idx_72665;
        r_idx_73166 = init_idx_72665;
        span_73167 = (int64_t) 1;
        while (loop_while_73164) {
            int64_t max_arg_73168 = sub64(l_idx_73165, (int64_t) 1);
            int64_t max_res_73169 = smax64((int64_t) 0, max_arg_73168);
            int64_t min_arg_73170 = add64((int64_t) 1, r_idx_73166);
            int64_t min_res_73171 = smin64(min_arg_67432, min_arg_73170);
            bool x_73172 = sle64((int64_t) 0, max_res_73169);
            bool y_73173 = slt64(max_res_73169, n_65378);
            bool bounds_check_73174 = x_73172 && y_73173;
            bool index_certs_73175;
            
            if (!bounds_check_73174) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_73169,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_73176;
            
            x_73176 = ((int64_t *) mem_70731.mem)[max_res_73169];
            
            int64_t abs_arg_73177 = sub64(x_73176, defunc_0_g_res_72663);
            int64_t abs_res_73178 = abs64(abs_arg_73177);
            bool x_73179 = sle64((int64_t) 0, min_res_73171);
            bool y_73180 = slt64(min_res_73171, n_65378);
            bool bounds_check_73181 = x_73179 && y_73180;
            bool index_certs_73182;
            
            if (!bounds_check_73181) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_73171,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_73183;
            
            x_73183 = ((int64_t *) mem_70731.mem)[min_res_73171];
            
            int64_t abs_arg_73184 = sub64(x_73183, defunc_0_g_res_72663);
            int64_t abs_res_73185 = abs64(abs_arg_73184);
            bool cond_73186 = max_res_73169 == l_idx_73165;
            int64_t loopres_73187;
            int64_t loopres_73188;
            int64_t loopres_73189;
            
            if (cond_73186) {
                loopres_73187 = l_idx_73165;
                loopres_73188 = r_idx_73166;
                loopres_73189 = min_res_65398;
            } else {
                bool cond_73190 = slt64(abs_res_73178, abs_res_73185);
                bool cond_f_res_73191 = min_res_73171 == r_idx_73166;
                bool x_73192 = !cond_73190;
                bool y_73193 = cond_f_res_73191 && x_73192;
                bool cond_73194 = cond_73190 || y_73193;
                int64_t loopres_f_res_73195;
                
                if (cond_73194) {
                    loopres_f_res_73195 = max_res_73169;
                } else {
                    loopres_f_res_73195 = l_idx_73165;
                }
                
                int64_t loopres_f_res_73196;
                
                if (cond_73194) {
                    loopres_f_res_73196 = r_idx_73166;
                } else {
                    loopres_f_res_73196 = min_res_73171;
                }
                
                int64_t loopres_f_res_73197;
                
                if (cond_73194) {
                    int64_t loopres_f_res_t_res_73198 = add64((int64_t) 1,
                                                              span_73167);
                    
                    loopres_f_res_73197 = loopres_f_res_t_res_73198;
                } else {
                    int64_t loopres_f_res_f_res_73199 = add64((int64_t) 1,
                                                              span_73167);
                    
                    loopres_f_res_73197 = loopres_f_res_f_res_73199;
                }
                loopres_73187 = loopres_f_res_73195;
                loopres_73188 = loopres_f_res_73196;
                loopres_73189 = loopres_f_res_73197;
            }
            
            bool loop_cond_73200 = slt64(loopres_73189, min_res_65398);
            bool loop_while_tmp_73271 = loop_cond_73200;
            int64_t l_idx_tmp_73272 = loopres_73187;
            int64_t r_idx_tmp_73273 = loopres_73188;
            int64_t span_tmp_73274 = loopres_73189;
            
            loop_while_73164 = loop_while_tmp_73271;
            l_idx_73165 = l_idx_tmp_73272;
            r_idx_73166 = r_idx_tmp_73273;
            span_73167 = span_tmp_73274;
        }
        idx_72685 = loop_while_73164;
        idx_72686 = l_idx_73165;
        idx_72687 = r_idx_73166;
        idx_72688 = span_73167;
        
        int64_t min_res_72726 = smin64(min_arg_67433, idx_72686);
        int64_t max_res_72727 = smax64((int64_t) 0, min_res_72726);
        int64_t x_72728 = add64(min_res_67434, max_res_72727);
        int64_t r_72729 = sub64(x_72728, (int64_t) 1);
        bool x_72730 = sle64((int64_t) 0, r_72729);
        bool y_72731 = slt64(r_72729, n_65378);
        bool bounds_check_72732 = x_72730 && y_72731;
        bool index_certs_72733;
        
        if (!bounds_check_72732) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_72729,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_72734;
        
        x_72734 = ((int64_t *) mem_70728.mem)[r_72729];
        
        int64_t abs_arg_72735 = sub64(x_72734, min_res_72662);
        int64_t abs_res_72736 = abs64(abs_arg_72735);
        bool x_72737 = sle64((int64_t) 0, max_res_72727);
        bool y_72738 = slt64(max_res_72727, n_65378);
        bool bounds_check_72739 = x_72737 && y_72738;
        bool index_certs_72740;
        
        if (!bounds_check_72739) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_72727,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_72741;
        
        x_72741 = ((int64_t *) mem_70728.mem)[max_res_72727];
        
        int64_t abs_arg_72742 = sub64(x_72741, min_res_72662);
        int64_t abs_res_72743 = abs64(abs_arg_72742);
        int64_t max_res_72744 = smax64(abs_res_72736, abs_res_72743);
        double defunc_0_f_res_72745 = sitofp_i64_f64(max_res_72744);
        double defunc_1_f_res_72746 = max_res_67438 + defunc_0_f_res_72745;
        double defunc_2_reduce_res_72747;
        double defunc_2_reduce_res_72748;
        double defunc_2_reduce_res_72749;
        int64_t flat_tid_73201 = (int64_t) 0;
        int32_t num_tasks_73275;
        
        defunc_2_reduce_res_72747 = 0.0;
        defunc_2_reduce_res_72748 = 0.0;
        defunc_2_reduce_res_72749 = 0.0;
        
        struct futhark_mc_task_77159 futhark_mc_task_77159;
        
        futhark_mc_task_77159.ctx = ctx;
        futhark_mc_task_77159.free_last_res_67413 = last_res_67413;
        futhark_mc_task_77159.free_mem_70728 = mem_70728.mem;
        futhark_mc_task_77159.free_mem_70734 = mem_70734.mem;
        futhark_mc_task_77159.free_min_res_72662 = min_res_72662;
        futhark_mc_task_77159.free_max_res_72727 = max_res_72727;
        futhark_mc_task_77159.free_defunc_1_f_res_72746 = defunc_1_f_res_72746;
        futhark_mc_task_77159.retval_defunc_2_reduce_res_72747 =
            &defunc_2_reduce_res_72747;
        futhark_mc_task_77159.retval_defunc_2_reduce_res_72748 =
            &defunc_2_reduce_res_72748;
        futhark_mc_task_77159.retval_defunc_2_reduce_res_72749 =
            &defunc_2_reduce_res_72749;
        
        struct scheduler_segop futhark_mc_task_77159_task;
        
        futhark_mc_task_77159_task.args = &futhark_mc_task_77159;
        futhark_mc_task_77159_task.top_level_fn = futhark_mc_segred_task_77160;
        futhark_mc_task_77159_task.name = "futhark_mc_segred_task_77160";
        futhark_mc_task_77159_task.iterations = q_65380;
        futhark_mc_task_77159_task.task_time =
            &ctx->futhark_mc_segred_task_77160_total_time;
        futhark_mc_task_77159_task.task_iter =
            &ctx->futhark_mc_segred_task_77160_total_iter;
        futhark_mc_task_77159_task.sched = STATIC;
        futhark_mc_task_77159_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77160_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77159_task);
        
        if (futhark_mc_segred_task_77160_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double x_72779 = defunc_2_reduce_res_72747 * defunc_2_reduce_res_72749;
        double y_72780 = defunc_2_reduce_res_72748 * defunc_2_reduce_res_72748;
        double y_72781 = x_72779 - y_72780;
        double det1_72782 = 1.0 / y_72781;
        double a11_72783 = defunc_2_reduce_res_72749 * det1_72782;
        double x_72784 = 0.0 - defunc_2_reduce_res_72748;
        double b11_72785 = det1_72782 * x_72784;
        double c11_72786 = defunc_2_reduce_res_72747 * det1_72782;
        double defunc_2_reduce_res_72787;
        double defunc_2_reduce_res_72788;
        int64_t flat_tid_73230 = (int64_t) 0;
        int32_t num_tasks_73296;
        
        defunc_2_reduce_res_72787 = 0.0;
        defunc_2_reduce_res_72788 = 0.0;
        
        struct futhark_mc_task_77166 futhark_mc_task_77166;
        
        futhark_mc_task_77166.ctx = ctx;
        futhark_mc_task_77166.free_last_res_67413 = last_res_67413;
        futhark_mc_task_77166.free_mem_70725 = mem_70725.mem;
        futhark_mc_task_77166.free_mem_70728 = mem_70728.mem;
        futhark_mc_task_77166.free_mem_70734 = mem_70734.mem;
        futhark_mc_task_77166.free_min_res_72662 = min_res_72662;
        futhark_mc_task_77166.free_max_res_72727 = max_res_72727;
        futhark_mc_task_77166.free_defunc_1_f_res_72746 = defunc_1_f_res_72746;
        futhark_mc_task_77166.free_a11_72783 = a11_72783;
        futhark_mc_task_77166.free_b11_72785 = b11_72785;
        futhark_mc_task_77166.free_c11_72786 = c11_72786;
        futhark_mc_task_77166.retval_defunc_2_reduce_res_72787 =
            &defunc_2_reduce_res_72787;
        futhark_mc_task_77166.retval_defunc_2_reduce_res_72788 =
            &defunc_2_reduce_res_72788;
        
        struct scheduler_segop futhark_mc_task_77166_task;
        
        futhark_mc_task_77166_task.args = &futhark_mc_task_77166;
        futhark_mc_task_77166_task.top_level_fn = futhark_mc_segred_task_77167;
        futhark_mc_task_77166_task.name = "futhark_mc_segred_task_77167";
        futhark_mc_task_77166_task.iterations = q_65380;
        futhark_mc_task_77166_task.task_time =
            &ctx->futhark_mc_segred_task_77167_total_time;
        futhark_mc_task_77166_task.task_iter =
            &ctx->futhark_mc_segred_task_77167_total_iter;
        futhark_mc_task_77166_task.sched = STATIC;
        futhark_mc_task_77166_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77167_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77166_task);
        
        if (futhark_mc_segred_task_77167_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        ((double *) mem_70737.mem)[gtid_72660] = defunc_2_reduce_res_72787;
        ((double *) mem_70740.mem)[gtid_72660] = defunc_2_reduce_res_72788;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77158_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77158_end -
                 futhark_mc_segmap_parloop_77158_start;
        
        ctx->futhark_mc_segmap_parloop_77158_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77158_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77158_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77156(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_72659 = tid;
    int num_tasks_73016 = info.nsubtasks;
    struct futhark_mc_task_77152 *futhark_mc_task_77152 =
                                 (struct futhark_mc_task_77152 *) args;
    struct futhark_context *ctx = futhark_mc_task_77152->ctx;
    uint64_t futhark_mc_segmap_nested_task_77156_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77156_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77152->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77152->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77152->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77152->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77152->free_i_65392;
    bool x_65393 = futhark_mc_task_77152->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77152->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77152->free_loop_cond_65403;
    int64_t last_res_67413 = futhark_mc_task_77152->free_last_res_67413;
    int64_t min_arg_67432 = futhark_mc_task_77152->free_min_arg_67432;
    int64_t min_arg_67433 = futhark_mc_task_77152->free_min_arg_67433;
    int64_t min_res_67434 = futhark_mc_task_77152->free_min_res_67434;
    double max_res_67438 = futhark_mc_task_77152->free_max_res_67438;
    struct memblock mem_70725 = {.desc ="mem_70725", .mem =
                                 futhark_mc_task_77152->free_mem_70725, .size =
                                 0, .references =NULL};
    struct memblock mem_70728 = {.desc ="mem_70728", .mem =
                                 futhark_mc_task_77152->free_mem_70728, .size =
                                 0, .references =NULL};
    struct memblock mem_70731 = {.desc ="mem_70731", .mem =
                                 futhark_mc_task_77152->free_mem_70731, .size =
                                 0, .references =NULL};
    struct memblock mem_70734 = {.desc ="mem_70734", .mem =
                                 futhark_mc_task_77152->free_mem_70734, .size =
                                 0, .references =NULL};
    struct memblock mem_70737 = {.desc ="mem_70737", .mem =
                                 futhark_mc_task_77152->free_mem_70737, .size =
                                 0, .references =NULL};
    struct memblock mem_70740 = {.desc ="mem_70740", .mem =
                                 futhark_mc_task_77152->free_mem_70740, .size =
                                 0, .references =NULL};
    int64_t iter_73145;
    struct futhark_mc_segmap_parloop_struct_77157
    futhark_mc_segmap_parloop_struct_77157;
    
    futhark_mc_segmap_parloop_struct_77157.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77157.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77157.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77157.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77157.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77157.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77157.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77157.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77157.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77157.free_last_res_67413 = last_res_67413;
    futhark_mc_segmap_parloop_struct_77157.free_min_arg_67432 = min_arg_67432;
    futhark_mc_segmap_parloop_struct_77157.free_min_arg_67433 = min_arg_67433;
    futhark_mc_segmap_parloop_struct_77157.free_min_res_67434 = min_res_67434;
    futhark_mc_segmap_parloop_struct_77157.free_max_res_67438 = max_res_67438;
    futhark_mc_segmap_parloop_struct_77157.free_mem_70725 = mem_70725.mem;
    futhark_mc_segmap_parloop_struct_77157.free_mem_70728 = mem_70728.mem;
    futhark_mc_segmap_parloop_struct_77157.free_mem_70731 = mem_70731.mem;
    futhark_mc_segmap_parloop_struct_77157.free_mem_70734 = mem_70734.mem;
    futhark_mc_segmap_parloop_struct_77157.free_mem_70737 = mem_70737.mem;
    futhark_mc_segmap_parloop_struct_77157.free_mem_70740 = mem_70740.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77158_task;
    
    futhark_mc_segmap_parloop_77158_task.name =
        "futhark_mc_segmap_parloop_77158";
    futhark_mc_segmap_parloop_77158_task.fn = futhark_mc_segmap_parloop_77158;
    futhark_mc_segmap_parloop_77158_task.args =
        &futhark_mc_segmap_parloop_struct_77157;
    futhark_mc_segmap_parloop_77158_task.iterations = iterations;
    futhark_mc_segmap_parloop_77158_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77158_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77158_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77158_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77158_task);
    
    if (futhark_mc_segmap_parloop_77158_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77158_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77158_total_end -
                 futhark_mc_segmap_parloop_77158_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77158_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77158_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77158_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77156_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77156_end -
                 futhark_mc_segmap_nested_task_77156_start;
        
        ctx->futhark_mc_segmap_nested_task_77156_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77156_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77156_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77125(void *args, int64_t start,
                                           int64_t end, int flat_tid_67400,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77124
    *futhark_mc_segmap_parloop_struct_77124 =
    (struct futhark_mc_segmap_parloop_struct_77124 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77124->ctx;
    uint64_t futhark_mc_segmap_parloop_77125_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77125_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77124->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77124->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77124->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77124->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77124->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77124->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77124->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77124->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77124->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77124->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77124->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70721 =
            futhark_mc_segmap_parloop_struct_77124->free_bytes_70721;
    int64_t bytes_70733 =
            futhark_mc_segmap_parloop_struct_77124->free_bytes_70733;
    int64_t bytes_70736 =
            futhark_mc_segmap_parloop_struct_77124->free_bytes_70736;
    struct memblock mem_70849 = {.desc ="mem_70849", .mem =
                                 futhark_mc_segmap_parloop_struct_77124->free_mem_70849,
                                 .size =0, .references =NULL};
    struct memblock mem_70853 = {.desc ="mem_70853", .mem =
                                 futhark_mc_segmap_parloop_struct_77124->free_mem_70853,
                                 .size =0, .references =NULL};
    size_t mem_70722_cached_sizze_77126 = 0;
    unsigned char *mem_70722 = NULL;
    size_t mem_70725_cached_sizze_77127 = 0;
    unsigned char *mem_70725 = NULL;
    size_t mem_70728_cached_sizze_77128 = 0;
    unsigned char *mem_70728 = NULL;
    size_t mem_70731_cached_sizze_77129 = 0;
    unsigned char *mem_70731 = NULL;
    size_t mem_70734_cached_sizze_77130 = 0;
    unsigned char *mem_70734 = NULL;
    size_t mem_70737_cached_sizze_77131 = 0;
    unsigned char *mem_70737 = NULL;
    size_t mem_70740_cached_sizze_77132 = 0;
    unsigned char *mem_70740 = NULL;
    int64_t iterations = end - start;
    int64_t iter_72633 = start;
    
    if (mem_70722_cached_sizze_77126 < (size_t) bytes_70721) {
        mem_70722 = realloc(mem_70722, bytes_70721);
        mem_70722_cached_sizze_77126 = bytes_70721;
    }
    if (mem_70725_cached_sizze_77127 < (size_t) bytes_70721) {
        mem_70725 = realloc(mem_70725, bytes_70721);
        mem_70725_cached_sizze_77127 = bytes_70721;
    }
    if (mem_70728_cached_sizze_77128 < (size_t) bytes_70721) {
        mem_70728 = realloc(mem_70728, bytes_70721);
        mem_70728_cached_sizze_77128 = bytes_70721;
    }
    if (mem_70731_cached_sizze_77129 < (size_t) bytes_70721) {
        mem_70731 = realloc(mem_70731, bytes_70721);
        mem_70731_cached_sizze_77129 = bytes_70721;
    }
    if (mem_70734_cached_sizze_77130 < (size_t) bytes_70733) {
        mem_70734 = realloc(mem_70734, bytes_70733);
        mem_70734_cached_sizze_77130 = bytes_70733;
    }
    if (mem_70737_cached_sizze_77131 < (size_t) bytes_70736) {
        mem_70737 = realloc(mem_70737, bytes_70736);
        mem_70737_cached_sizze_77131 = bytes_70736;
    }
    if (mem_70740_cached_sizze_77132 < (size_t) bytes_70736) {
        mem_70740 = realloc(mem_70740, bytes_70736);
        mem_70740_cached_sizze_77132 = bytes_70736;
    }
    for (; iter_72633 < end; iter_72633++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_72984 = m_65377;
        int64_t gtid_67401 = iter_72633;
        int64_t remnant_72985 = iter_72633 - gtid_67401;
        int64_t flat_tid_72634 = (int64_t) 0;
        int32_t num_tasks_72986;
        
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmented segScan");
        
        struct futhark_mc_task_77133 futhark_mc_task_77133;
        
        futhark_mc_task_77133.ctx = ctx;
        futhark_mc_task_77133.free_n_65378 = n_65378;
        futhark_mc_task_77133.free_gtid_67401 = gtid_67401;
        futhark_mc_task_77133.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77133.free_mem_70722 = mem_70722;
        
        struct scheduler_segop futhark_mc_task_77133_task;
        
        futhark_mc_task_77133_task.args = &futhark_mc_task_77133;
        futhark_mc_task_77133_task.top_level_fn = futhark_mc_segscan_task_77134;
        futhark_mc_task_77133_task.name = "futhark_mc_segscan_task_77134";
        futhark_mc_task_77133_task.iterations = n_65378;
        futhark_mc_task_77133_task.task_time =
            &ctx->futhark_mc_segscan_task_77134_total_time;
        futhark_mc_task_77133_task.task_iter =
            &ctx->futhark_mc_segscan_task_77134_total_iter;
        futhark_mc_task_77133_task.sched = STATIC;
        futhark_mc_task_77133_task.nested_fn = NULL;
        
        int futhark_mc_segscan_task_77134_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77133_task);
        
        if (futhark_mc_segscan_task_77134_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t last_res_67413;
        
        last_res_67413 = ((int64_t *) mem_70722)[i_65392];
        for (int64_t i_73000 = 0; i_73000 < n_65378; i_73000++) {
            ((double *) mem_70725)[i_73000] = 0.0;
        }
        for (int64_t i_73001 = 0; i_73001 < n_65378; i_73001++) {
            ((int64_t *) mem_70728)[i_73001] = (int64_t) -1;
        }
        
        int64_t flat_tid_72643 = (int64_t) 0;
        int32_t num_tasks_73002;
        struct futhark_mc_task_77140 futhark_mc_task_77140;
        
        futhark_mc_task_77140.ctx = ctx;
        futhark_mc_task_77140.free_n_65378 = n_65378;
        futhark_mc_task_77140.free_gtid_67401 = gtid_67401;
        futhark_mc_task_77140.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77140.free_mem_70722 = mem_70722;
        futhark_mc_task_77140.free_mem_70725 = mem_70725;
        futhark_mc_task_77140.free_mem_70728 = mem_70728;
        
        struct scheduler_segop futhark_mc_task_77140_task;
        
        futhark_mc_task_77140_task.args = &futhark_mc_task_77140;
        futhark_mc_task_77140_task.top_level_fn = futhark_mc_segmap_task_77141;
        futhark_mc_task_77140_task.name = "futhark_mc_segmap_task_77141";
        futhark_mc_task_77140_task.iterations = n_65378;
        futhark_mc_task_77140_task.task_time =
            &ctx->futhark_mc_segmap_task_77141_total_time;
        futhark_mc_task_77140_task.task_iter =
            &ctx->futhark_mc_segmap_task_77141_total_iter;
        futhark_mc_task_77140_task.sched = STATIC;
        futhark_mc_task_77140_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77141_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77140_task);
        
        if (futhark_mc_segmap_task_77141_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_72651 = (int64_t) 0;
        int32_t num_tasks_73008;
        struct futhark_mc_task_77144 futhark_mc_task_77144;
        
        futhark_mc_task_77144.ctx = ctx;
        futhark_mc_task_77144.free_n_65378 = n_65378;
        futhark_mc_task_77144.free_mem_70728 = mem_70728;
        futhark_mc_task_77144.free_mem_70731 = mem_70731;
        
        struct scheduler_segop futhark_mc_task_77144_task;
        
        futhark_mc_task_77144_task.args = &futhark_mc_task_77144;
        futhark_mc_task_77144_task.top_level_fn = futhark_mc_segmap_task_77145;
        futhark_mc_task_77144_task.name = "futhark_mc_segmap_task_77145";
        futhark_mc_task_77144_task.iterations = n_65378;
        futhark_mc_task_77144_task.task_time =
            &ctx->futhark_mc_segmap_task_77145_total_time;
        futhark_mc_task_77144_task.task_iter =
            &ctx->futhark_mc_segmap_task_77145_total_iter;
        futhark_mc_task_77144_task.sched = STATIC;
        futhark_mc_task_77144_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77145_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77144_task);
        
        if (futhark_mc_segmap_task_77145_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t min_arg_67432 = sub64(last_res_67413, (int64_t) 1);
        int64_t min_arg_67433 = sub64(last_res_67413, min_res_65398);
        int64_t min_res_67434 = smin64(q_65380, last_res_67413);
        double i64_res_67435 = sitofp_i64_f64(last_res_67413);
        double x_67436 = i64_res_65404 - i64_res_67435;
        double max_arg_67437 = x_67436 / 2.0;
        double max_res_67438 = fmax64(0.0, max_arg_67437);
        int64_t flat_tid_72655 = (int64_t) 0;
        int32_t num_tasks_73012;
        struct futhark_mc_task_77148 futhark_mc_task_77148;
        
        futhark_mc_task_77148.ctx = ctx;
        futhark_mc_task_77148.free_q_65380 = q_65380;
        futhark_mc_task_77148.free_last_res_67413 = last_res_67413;
        futhark_mc_task_77148.free_mem_70734 = mem_70734;
        
        struct scheduler_segop futhark_mc_task_77148_task;
        
        futhark_mc_task_77148_task.args = &futhark_mc_task_77148;
        futhark_mc_task_77148_task.top_level_fn = futhark_mc_segmap_task_77149;
        futhark_mc_task_77148_task.name = "futhark_mc_segmap_task_77149";
        futhark_mc_task_77148_task.iterations = q_65380;
        futhark_mc_task_77148_task.task_time =
            &ctx->futhark_mc_segmap_task_77149_total_time;
        futhark_mc_task_77148_task.task_iter =
            &ctx->futhark_mc_segmap_task_77149_total_iter;
        futhark_mc_task_77148_task.sched = STATIC;
        futhark_mc_task_77148_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77149_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77148_task);
        
        if (futhark_mc_segmap_task_77149_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_72825 = (int64_t) 0;
        int32_t num_tasks_73016;
        int64_t flat_tid_72659 = (int64_t) 0;
        struct futhark_mc_task_77152 futhark_mc_task_77152;
        
        futhark_mc_task_77152.ctx = ctx;
        futhark_mc_task_77152.free_n_65378 = n_65378;
        futhark_mc_task_77152.free_q_65380 = q_65380;
        futhark_mc_task_77152.free_jump_65382 = jump_65382;
        futhark_mc_task_77152.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77152.free_i_65392 = i_65392;
        futhark_mc_task_77152.free_x_65393 = x_65393;
        futhark_mc_task_77152.free_min_res_65398 = min_res_65398;
        futhark_mc_task_77152.free_loop_cond_65403 = loop_cond_65403;
        futhark_mc_task_77152.free_last_res_67413 = last_res_67413;
        futhark_mc_task_77152.free_min_arg_67432 = min_arg_67432;
        futhark_mc_task_77152.free_min_arg_67433 = min_arg_67433;
        futhark_mc_task_77152.free_min_res_67434 = min_res_67434;
        futhark_mc_task_77152.free_max_res_67438 = max_res_67438;
        futhark_mc_task_77152.free_mem_70725 = mem_70725;
        futhark_mc_task_77152.free_mem_70728 = mem_70728;
        futhark_mc_task_77152.free_mem_70731 = mem_70731;
        futhark_mc_task_77152.free_mem_70734 = mem_70734;
        futhark_mc_task_77152.free_mem_70737 = mem_70737;
        futhark_mc_task_77152.free_mem_70740 = mem_70740;
        
        struct scheduler_segop futhark_mc_task_77152_task;
        
        futhark_mc_task_77152_task.args = &futhark_mc_task_77152;
        futhark_mc_task_77152_task.top_level_fn = futhark_mc_segmap_task_77153;
        futhark_mc_task_77152_task.name = "futhark_mc_segmap_task_77153";
        futhark_mc_task_77152_task.iterations = n_m_65386;
        futhark_mc_task_77152_task.task_time =
            &ctx->futhark_mc_segmap_task_77153_total_time;
        futhark_mc_task_77152_task.task_iter =
            &ctx->futhark_mc_segmap_task_77153_total_iter;
        futhark_mc_task_77152_task.sched = DYNAMIC;
        futhark_mc_task_77152_task.nested_fn =
            futhark_mc_segmap_nested_task_77156;
        
        int futhark_mc_segmap_task_77153_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77152_task);
        
        if (futhark_mc_segmap_task_77153_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70849.mem + gtid_67401 * n_m_65386 * (int64_t) 8,
                    mem_70737 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70853.mem + gtid_67401 * n_m_65386 * (int64_t) 8,
                    mem_70740 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70722);
    free(mem_70725);
    free(mem_70728);
    free(mem_70731);
    free(mem_70734);
    free(mem_70737);
    free(mem_70740);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77125_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77125_end -
                 futhark_mc_segmap_parloop_77125_start;
        
        ctx->futhark_mc_segmap_parloop_77125_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77125_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77125_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77123(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_67400 = tid;
    int num_tasks_72414 = info.nsubtasks;
    struct futhark_mc_task_77112 *futhark_mc_task_77112 =
                                 (struct futhark_mc_task_77112 *) args;
    struct futhark_context *ctx = futhark_mc_task_77112->ctx;
    uint64_t futhark_mc_segmap_nested_task_77123_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77123_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77112->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77112->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77112->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77112->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77112->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77112->free_i_65392;
    bool x_65393 = futhark_mc_task_77112->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77112->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77112->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77112->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77112->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70721 = futhark_mc_task_77112->free_bytes_70721;
    int64_t bytes_70733 = futhark_mc_task_77112->free_bytes_70733;
    int64_t bytes_70736 = futhark_mc_task_77112->free_bytes_70736;
    struct memblock mem_70849 = {.desc ="mem_70849", .mem =
                                 futhark_mc_task_77112->free_mem_70849, .size =
                                 0, .references =NULL};
    struct memblock mem_70853 = {.desc ="mem_70853", .mem =
                                 futhark_mc_task_77112->free_mem_70853, .size =
                                 0, .references =NULL};
    int64_t iter_72633;
    struct futhark_mc_segmap_parloop_struct_77124
    futhark_mc_segmap_parloop_struct_77124;
    
    futhark_mc_segmap_parloop_struct_77124.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77124.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77124.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77124.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77124.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77124.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77124.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77124.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77124.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77124.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77124.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77124.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77124.free_bytes_70721 = bytes_70721;
    futhark_mc_segmap_parloop_struct_77124.free_bytes_70733 = bytes_70733;
    futhark_mc_segmap_parloop_struct_77124.free_bytes_70736 = bytes_70736;
    futhark_mc_segmap_parloop_struct_77124.free_mem_70849 = mem_70849.mem;
    futhark_mc_segmap_parloop_struct_77124.free_mem_70853 = mem_70853.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77125_task;
    
    futhark_mc_segmap_parloop_77125_task.name =
        "futhark_mc_segmap_parloop_77125";
    futhark_mc_segmap_parloop_77125_task.fn = futhark_mc_segmap_parloop_77125;
    futhark_mc_segmap_parloop_77125_task.args =
        &futhark_mc_segmap_parloop_struct_77124;
    futhark_mc_segmap_parloop_77125_task.iterations = iterations;
    futhark_mc_segmap_parloop_77125_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77125_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77125_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77125_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77125_task);
    
    if (futhark_mc_segmap_parloop_77125_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77125_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77125_total_end -
                 futhark_mc_segmap_parloop_77125_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77125_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77125_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77125_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77123_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77123_end -
                 futhark_mc_segmap_nested_task_77123_start;
        
        ctx->futhark_mc_segmap_nested_task_77123_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77123_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77123_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77172 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70855;
    int64_t free_bytes_70867;
    int64_t free_bytes_70870;
    unsigned char *free_mem_70983;
    unsigned char *free_mem_70987;
};
struct futhark_mc_segmap_parloop_struct_77174 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70855;
    int64_t free_bytes_70867;
    int64_t free_bytes_70870;
    unsigned char *free_mem_70983;
    unsigned char *free_mem_70987;
};
static int futhark_mc_segmap_parloop_77175(void *args, int64_t start,
                                           int64_t end, int flat_tid_67781,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77174
    *futhark_mc_segmap_parloop_struct_77174 =
    (struct futhark_mc_segmap_parloop_struct_77174 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77174->ctx;
    uint64_t futhark_mc_segmap_parloop_77175_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77175_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77174->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77174->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77174->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77174->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77174->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77174->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77174->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77174->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77174->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77174->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77174->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70855 =
            futhark_mc_segmap_parloop_struct_77174->free_bytes_70855;
    int64_t bytes_70867 =
            futhark_mc_segmap_parloop_struct_77174->free_bytes_70867;
    int64_t bytes_70870 =
            futhark_mc_segmap_parloop_struct_77174->free_bytes_70870;
    struct memblock mem_70983 = {.desc ="mem_70983", .mem =
                                 futhark_mc_segmap_parloop_struct_77174->free_mem_70983,
                                 .size =0, .references =NULL};
    struct memblock mem_70987 = {.desc ="mem_70987", .mem =
                                 futhark_mc_segmap_parloop_struct_77174->free_mem_70987,
                                 .size =0, .references =NULL};
    size_t mem_70877_cached_sizze_77176 = 0;
    unsigned char *mem_70877 = NULL;
    size_t mem_70892_cached_sizze_77177 = 0;
    unsigned char *mem_70892 = NULL;
    size_t mem_70895_cached_sizze_77178 = 0;
    unsigned char *mem_70895 = NULL;
    size_t mem_70922_cached_sizze_77179 = 0;
    unsigned char *mem_70922 = NULL;
    size_t mem_70937_cached_sizze_77180 = 0;
    unsigned char *mem_70937 = NULL;
    size_t mem_70952_cached_sizze_77181 = 0;
    unsigned char *mem_70952 = NULL;
    size_t mem_70955_cached_sizze_77182 = 0;
    unsigned char *mem_70955 = NULL;
    int64_t iterations = end - start;
    int64_t iter_73312 = start;
    
    if (mem_70877_cached_sizze_77176 < (size_t) bytes_70855) {
        mem_70877 = realloc(mem_70877, bytes_70855);
        mem_70877_cached_sizze_77176 = bytes_70855;
    }
    if (mem_70892_cached_sizze_77177 < (size_t) bytes_70855) {
        mem_70892 = realloc(mem_70892, bytes_70855);
        mem_70892_cached_sizze_77177 = bytes_70855;
    }
    if (mem_70895_cached_sizze_77178 < (size_t) bytes_70855) {
        mem_70895 = realloc(mem_70895, bytes_70855);
        mem_70895_cached_sizze_77178 = bytes_70855;
    }
    if (mem_70922_cached_sizze_77179 < (size_t) bytes_70855) {
        mem_70922 = realloc(mem_70922, bytes_70855);
        mem_70922_cached_sizze_77179 = bytes_70855;
    }
    if (mem_70937_cached_sizze_77180 < (size_t) bytes_70867) {
        mem_70937 = realloc(mem_70937, bytes_70867);
        mem_70937_cached_sizze_77180 = bytes_70867;
    }
    if (mem_70952_cached_sizze_77181 < (size_t) bytes_70870) {
        mem_70952 = realloc(mem_70952, bytes_70870);
        mem_70952_cached_sizze_77181 = bytes_70870;
    }
    if (mem_70955_cached_sizze_77182 < (size_t) bytes_70870) {
        mem_70955 = realloc(mem_70955, bytes_70870);
        mem_70955_cached_sizze_77182 = bytes_70870;
    }
    for (; iter_73312 < end; iter_73312++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73536 = m_65377;
        int64_t gtid_67782 = iter_73312;
        int64_t remnant_73537 = iter_73312 - gtid_67782;
        int64_t discard_70300;
        int64_t scanacc_73314 = (int64_t) 0;
        
        for (int64_t i_73313 = 0; i_73313 < n_65378; i_73313++) {
            double x_73316;
            
            x_73316 = ((double *) Y_mem_70603.mem)[gtid_67782 * n_65378 +
                                                   i_73313];
            
            bool isnan_res_73317;
            
            isnan_res_73317 = futrts_isnan64(x_73316);
            
            bool defunc_0_p_res_73318 = !isnan_res_73317;
            int64_t defunc_0_f_res_73319 = btoi_bool_i64(defunc_0_p_res_73318);
            int64_t defunc_1_op_res_73320 = add64(defunc_0_f_res_73319,
                                                  scanacc_73314);
            
            ((int64_t *) mem_70877)[i_73313] = defunc_1_op_res_73320;
            
            int64_t scanacc_tmp_73538 = defunc_1_op_res_73320;
            
            scanacc_73314 = scanacc_tmp_73538;
        }
        discard_70300 = scanacc_73314;
        
        int64_t last_res_65811;
        
        last_res_65811 = ((int64_t *) mem_70877)[i_65392];
        for (int64_t i_73540 = 0; i_73540 < n_65378; i_73540++) {
            ((double *) mem_70892)[i_73540] = 0.0;
        }
        for (int64_t i_73541 = 0; i_73541 < n_65378; i_73541++) {
            ((int64_t *) mem_70895)[i_73541] = (int64_t) -1;
        }
        for (int64_t write_iter_73322 = 0; write_iter_73322 < n_65378;
             write_iter_73322++) {
            double write_iv_73325;
            
            write_iv_73325 = ((double *) Y_mem_70603.mem)[gtid_67782 * n_65378 +
                                                          write_iter_73322];
            
            bool isnan_res_73326;
            
            isnan_res_73326 = futrts_isnan64(write_iv_73325);
            
            bool defunc_0_p_res_73327 = !isnan_res_73326;
            int64_t defunc_1_f_res_73328;
            
            if (defunc_0_p_res_73327) {
                int64_t write_iv_73329;
                
                write_iv_73329 = ((int64_t *) mem_70877)[write_iter_73322];
                
                int64_t defunc_1_f_res_t_res_73330 = sub64(write_iv_73329,
                                                           (int64_t) 1);
                
                defunc_1_f_res_73328 = defunc_1_f_res_t_res_73330;
            } else {
                defunc_1_f_res_73328 = (int64_t) -1;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_73328) &&
                slt64(defunc_1_f_res_73328, n_65378)) {
                ((int64_t *) mem_70895)[defunc_1_f_res_73328] =
                    write_iter_73322;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_73328) &&
                slt64(defunc_1_f_res_73328, n_65378)) {
                if ((int64_t) 8 > 0)
                    memmove(mem_70892 + defunc_1_f_res_73328 * (int64_t) 8,
                            Y_mem_70603.mem + (gtid_67782 * n_65378 +
                                               write_iter_73322) * (int64_t) 8,
                            (int64_t) 8);
            }
        }
        for (int64_t i_73334 = 0; i_73334 < n_65378; i_73334++) {
            int64_t x_73336;
            
            x_73336 = ((int64_t *) mem_70895)[i_73334];
            
            int64_t defunc_0_f_res_73337 = add64((int64_t) 1, x_73336);
            
            ((int64_t *) mem_70922)[i_73334] = defunc_0_f_res_73337;
        }
        
        int64_t min_arg_65826 = sub64(last_res_65811, (int64_t) 1);
        int64_t min_arg_65827 = sub64(last_res_65811, min_res_65398);
        int64_t min_res_65828 = smin64(q_65380, last_res_65811);
        double i64_res_65829 = sitofp_i64_f64(last_res_65811);
        double x_65830 = i64_res_65404 - i64_res_65829;
        double max_arg_65831 = x_65830 / 2.0;
        double max_res_65832 = fmax64(0.0, max_arg_65831);
        
        for (int64_t i_73339 = 0; i_73339 < q_65380; i_73339++) {
            bool cond_73341 = sle64(last_res_65811, i_73339);
            double defunc_0_f_res_73342;
            
            if (cond_73341) {
                defunc_0_f_res_73342 = 0.0;
            } else {
                defunc_0_f_res_73342 = 1.0;
            }
            ((double *) mem_70937)[i_73339] = defunc_0_f_res_73342;
        }
        for (int64_t i_73344 = 0; i_73344 < n_m_65386; i_73344++) {
            int64_t min_arg_73347 = mul64(jump_65382, i_73344);
            int64_t min_res_73348 = smin64(i_65392, min_arg_73347);
            int64_t defunc_0_g_res_73349 = add64((int64_t) 1, min_res_73348);
            bool init_idx_73350;
            int64_t init_idx_73351;
            int64_t init_idx_73352;
            bool loop_while_73353;
            int64_t low_73354;
            int64_t high_73355;
            
            loop_while_73353 = x_65393;
            low_73354 = (int64_t) 0;
            high_73355 = i_65392;
            while (loop_while_73353) {
                int64_t x_73356 = add64(low_73354, high_73355);
                int64_t mid_73357 = sdiv64(x_73356, (int64_t) 2);
                bool x_73358 = sle64((int64_t) 0, mid_73357);
                bool y_73359 = slt64(mid_73357, n_65378);
                bool bounds_check_73360 = x_73358 && y_73359;
                bool index_certs_73361;
                
                if (!bounds_check_73360) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) mid_73357,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t mid_id_73362;
                
                mid_id_73362 = ((int64_t *) mem_70922)[mid_73357];
                
                bool cond_73363 = slt64(mid_id_73362, (int64_t) 0);
                int64_t mid_idx_73364;
                
                if (cond_73363) {
                    mid_idx_73364 = (int64_t) 9223372036854775807;
                } else {
                    mid_idx_73364 = mid_id_73362;
                }
                
                bool cond_73365 = sle64(defunc_0_g_res_73349, mid_idx_73364);
                int64_t loopres_73366;
                int64_t loopres_73367;
                
                if (cond_73365) {
                    int64_t loopres_t_res_73368 = sub64(mid_73357, (int64_t) 1);
                    
                    loopres_73366 = low_73354;
                    loopres_73367 = loopres_t_res_73368;
                } else {
                    int64_t loopres_f_res_73369 = add64((int64_t) 1, mid_73357);
                    
                    loopres_73366 = loopres_f_res_73369;
                    loopres_73367 = high_73355;
                }
                
                bool loop_cond_73370 = sle64(loopres_73366, loopres_73367);
                bool loop_while_tmp_73548 = loop_cond_73370;
                int64_t low_tmp_73549 = loopres_73366;
                int64_t high_tmp_73550 = loopres_73367;
                
                loop_while_73353 = loop_while_tmp_73548;
                low_73354 = low_tmp_73549;
                high_73355 = high_tmp_73550;
            }
            init_idx_73350 = loop_while_73353;
            init_idx_73351 = low_73354;
            init_idx_73352 = high_73355;
            
            bool idx_73371;
            int64_t idx_73372;
            int64_t idx_73373;
            int64_t idx_73374;
            bool loop_while_73375;
            int64_t l_idx_73376;
            int64_t r_idx_73377;
            int64_t span_73378;
            
            loop_while_73375 = loop_cond_65403;
            l_idx_73376 = init_idx_73351;
            r_idx_73377 = init_idx_73351;
            span_73378 = (int64_t) 1;
            while (loop_while_73375) {
                int64_t max_arg_73379 = sub64(l_idx_73376, (int64_t) 1);
                int64_t max_res_73380 = smax64((int64_t) 0, max_arg_73379);
                int64_t min_arg_73381 = add64((int64_t) 1, r_idx_73377);
                int64_t min_res_73382 = smin64(min_arg_65826, min_arg_73381);
                bool x_73383 = sle64((int64_t) 0, max_res_73380);
                bool y_73384 = slt64(max_res_73380, n_65378);
                bool bounds_check_73385 = x_73383 && y_73384;
                bool index_certs_73386;
                
                if (!bounds_check_73385) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) max_res_73380,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_73387;
                
                x_73387 = ((int64_t *) mem_70922)[max_res_73380];
                
                int64_t abs_arg_73388 = sub64(x_73387, defunc_0_g_res_73349);
                int64_t abs_res_73389 = abs64(abs_arg_73388);
                bool x_73390 = sle64((int64_t) 0, min_res_73382);
                bool y_73391 = slt64(min_res_73382, n_65378);
                bool bounds_check_73392 = x_73390 && y_73391;
                bool index_certs_73393;
                
                if (!bounds_check_73392) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) min_res_73382,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_73394;
                
                x_73394 = ((int64_t *) mem_70922)[min_res_73382];
                
                int64_t abs_arg_73395 = sub64(x_73394, defunc_0_g_res_73349);
                int64_t abs_res_73396 = abs64(abs_arg_73395);
                bool cond_73397 = max_res_73380 == l_idx_73376;
                int64_t loopres_73398;
                int64_t loopres_73399;
                int64_t loopres_73400;
                
                if (cond_73397) {
                    loopres_73398 = l_idx_73376;
                    loopres_73399 = r_idx_73377;
                    loopres_73400 = min_res_65398;
                } else {
                    bool cond_73401 = slt64(abs_res_73389, abs_res_73396);
                    bool cond_f_res_73402 = min_res_73382 == r_idx_73377;
                    bool x_73403 = !cond_73401;
                    bool y_73404 = cond_f_res_73402 && x_73403;
                    bool cond_73405 = cond_73401 || y_73404;
                    int64_t loopres_f_res_73406;
                    
                    if (cond_73405) {
                        loopres_f_res_73406 = max_res_73380;
                    } else {
                        loopres_f_res_73406 = l_idx_73376;
                    }
                    
                    int64_t loopres_f_res_73407;
                    
                    if (cond_73405) {
                        loopres_f_res_73407 = r_idx_73377;
                    } else {
                        loopres_f_res_73407 = min_res_73382;
                    }
                    
                    int64_t loopres_f_res_73408;
                    
                    if (cond_73405) {
                        int64_t loopres_f_res_t_res_73409 = add64((int64_t) 1,
                                                                  span_73378);
                        
                        loopres_f_res_73408 = loopres_f_res_t_res_73409;
                    } else {
                        int64_t loopres_f_res_f_res_73410 = add64((int64_t) 1,
                                                                  span_73378);
                        
                        loopres_f_res_73408 = loopres_f_res_f_res_73410;
                    }
                    loopres_73398 = loopres_f_res_73406;
                    loopres_73399 = loopres_f_res_73407;
                    loopres_73400 = loopres_f_res_73408;
                }
                
                bool loop_cond_73411 = slt64(loopres_73400, min_res_65398);
                bool loop_while_tmp_73551 = loop_cond_73411;
                int64_t l_idx_tmp_73552 = loopres_73398;
                int64_t r_idx_tmp_73553 = loopres_73399;
                int64_t span_tmp_73554 = loopres_73400;
                
                loop_while_73375 = loop_while_tmp_73551;
                l_idx_73376 = l_idx_tmp_73552;
                r_idx_73377 = r_idx_tmp_73553;
                span_73378 = span_tmp_73554;
            }
            idx_73371 = loop_while_73375;
            idx_73372 = l_idx_73376;
            idx_73373 = r_idx_73377;
            idx_73374 = span_73378;
            
            int64_t min_res_73412 = smin64(min_arg_65827, idx_73372);
            int64_t max_res_73413 = smax64((int64_t) 0, min_res_73412);
            int64_t x_73414 = add64(min_res_65828, max_res_73413);
            int64_t r_73415 = sub64(x_73414, (int64_t) 1);
            bool x_73416 = sle64((int64_t) 0, r_73415);
            bool y_73417 = slt64(r_73415, n_65378);
            bool bounds_check_73418 = x_73416 && y_73417;
            bool index_certs_73419;
            
            if (!bounds_check_73418) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) r_73415,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_73420;
            
            x_73420 = ((int64_t *) mem_70895)[r_73415];
            
            int64_t abs_arg_73421 = sub64(x_73420, min_res_73348);
            int64_t abs_res_73422 = abs64(abs_arg_73421);
            bool x_73423 = sle64((int64_t) 0, max_res_73413);
            bool y_73424 = slt64(max_res_73413, n_65378);
            bool bounds_check_73425 = x_73423 && y_73424;
            bool index_certs_73426;
            
            if (!bounds_check_73425) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_73413,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_73427;
            
            x_73427 = ((int64_t *) mem_70895)[max_res_73413];
            
            int64_t abs_arg_73428 = sub64(x_73427, min_res_73348);
            int64_t abs_res_73429 = abs64(abs_arg_73428);
            int64_t max_res_73430 = smax64(abs_res_73422, abs_res_73429);
            double defunc_0_f_res_73431 = sitofp_i64_f64(max_res_73430);
            double defunc_1_f_res_73432 = max_res_65832 + defunc_0_f_res_73431;
            double defunc_2_reduce_res_73433;
            double defunc_2_reduce_res_73434;
            double defunc_2_reduce_res_73435;
            double defunc_2_reduce_res_73436;
            double defunc_2_reduce_res_73437;
            double redout_73439;
            double redout_73440;
            double redout_73441;
            double redout_73442;
            double redout_73443;
            
            redout_73439 = 0.0;
            redout_73440 = 0.0;
            redout_73441 = 0.0;
            redout_73442 = 0.0;
            redout_73443 = 0.0;
            for (int64_t i_73438 = 0; i_73438 < q_65380; i_73438++) {
                double x_73444;
                
                x_73444 = ((double *) mem_70937)[i_73438];
                
                bool cond_73445 = sle64(last_res_65811, i_73438);
                int64_t defunc_0_f_res_73446;
                
                if (cond_73445) {
                    defunc_0_f_res_73446 = (int64_t) 0;
                } else {
                    int64_t i_73447 = add64(max_res_73413, i_73438);
                    int64_t defunc_0_add_arg_73448;
                    
                    defunc_0_add_arg_73448 = ((int64_t *) mem_70895)[i_73447];
                    
                    int64_t defunc_1_add_res_73449 = add64((int64_t) 1,
                                                           defunc_0_add_arg_73448);
                    
                    defunc_0_f_res_73446 = defunc_1_add_res_73449;
                }
                
                int64_t binop_p_73450 = sub64(defunc_0_f_res_73446,
                                              min_res_73348);
                double defunc_0_f_res_73451 = sitofp_i64_f64(binop_p_73450);
                double abs_res_73452 = fabs(defunc_0_f_res_73451);
                double tmp1_73453 = abs_res_73452 / defunc_1_f_res_73432;
                double x_73454 = tmp1_73453 * tmp1_73453;
                double y_73455 = tmp1_73453 * x_73454;
                double tmp2_73456 = 1.0 - y_73455;
                double x_73457 = tmp2_73456 * tmp2_73456;
                double tmp3_73458 = tmp2_73456 * x_73457;
                double w_j_73459 = x_73444 * tmp3_73458;
                double xw_j_73460 = defunc_0_f_res_73451 * w_j_73459;
                double x2w_j_73461 = defunc_0_f_res_73451 * xw_j_73460;
                double x3w_j_73462 = defunc_0_f_res_73451 * x2w_j_73461;
                double x4w_j_73463 = defunc_0_f_res_73451 * x3w_j_73462;
                double defunc_1_op_res_73464 = w_j_73459 + redout_73439;
                double defunc_1_op_res_73465 = xw_j_73460 + redout_73440;
                double defunc_1_op_res_73466 = x2w_j_73461 + redout_73441;
                double defunc_1_op_res_73467 = x3w_j_73462 + redout_73442;
                double defunc_1_op_res_73468 = x4w_j_73463 + redout_73443;
                double redout_tmp_73555 = defunc_1_op_res_73464;
                double redout_tmp_73556 = defunc_1_op_res_73465;
                double redout_tmp_73557 = defunc_1_op_res_73466;
                double redout_tmp_73558 = defunc_1_op_res_73467;
                double redout_tmp_73559 = defunc_1_op_res_73468;
                
                redout_73439 = redout_tmp_73555;
                redout_73440 = redout_tmp_73556;
                redout_73441 = redout_tmp_73557;
                redout_73442 = redout_tmp_73558;
                redout_73443 = redout_tmp_73559;
            }
            defunc_2_reduce_res_73433 = redout_73439;
            defunc_2_reduce_res_73434 = redout_73440;
            defunc_2_reduce_res_73435 = redout_73441;
            defunc_2_reduce_res_73436 = redout_73442;
            defunc_2_reduce_res_73437 = redout_73443;
            
            double x_73469 = defunc_2_reduce_res_73435 *
                   defunc_2_reduce_res_73437;
            double y_73470 = defunc_2_reduce_res_73436 *
                   defunc_2_reduce_res_73436;
            double a12_73471 = x_73469 - y_73470;
            double x_73472 = defunc_2_reduce_res_73435 *
                   defunc_2_reduce_res_73436;
            double y_73473 = defunc_2_reduce_res_73434 *
                   defunc_2_reduce_res_73437;
            double b12_73474 = x_73472 - y_73473;
            double x_73475 = defunc_2_reduce_res_73434 *
                   defunc_2_reduce_res_73436;
            double y_73476 = defunc_2_reduce_res_73435 *
                   defunc_2_reduce_res_73435;
            double c12_73477 = x_73475 - y_73476;
            double x_73478 = defunc_2_reduce_res_73433 *
                   defunc_2_reduce_res_73437;
            double b2_73479 = x_73478 - y_73476;
            double x_73480 = defunc_2_reduce_res_73434 *
                   defunc_2_reduce_res_73435;
            double y_73481 = defunc_2_reduce_res_73433 *
                   defunc_2_reduce_res_73436;
            double c2_73482 = x_73480 - y_73481;
            double x_73483 = defunc_2_reduce_res_73433 * a12_73471;
            double y_73484 = defunc_2_reduce_res_73434 * b12_73474;
            double x_73485 = x_73483 + y_73484;
            double y_73486 = defunc_2_reduce_res_73435 * c12_73477;
            double y_73487 = x_73485 + y_73486;
            double det_73488 = 1.0 / y_73487;
            double a12_73489 = a12_73471 * det_73488;
            double b12_73490 = b12_73474 * det_73488;
            double c12_73491 = c12_73477 * det_73488;
            double b2_73492 = b2_73479 * det_73488;
            double c2_73493 = c2_73482 * det_73488;
            double defunc_2_reduce_res_73494;
            double defunc_2_reduce_res_73495;
            double redout_73497;
            double redout_73498;
            
            redout_73497 = 0.0;
            redout_73498 = 0.0;
            for (int64_t i_73496 = 0; i_73496 < q_65380; i_73496++) {
                double x_73499;
                
                x_73499 = ((double *) mem_70937)[i_73496];
                
                bool cond_73500 = sle64(last_res_65811, i_73496);
                int64_t defunc_0_f_res_73501;
                
                if (cond_73500) {
                    defunc_0_f_res_73501 = (int64_t) 0;
                } else {
                    int64_t i_73502 = add64(max_res_73413, i_73496);
                    int64_t defunc_0_add_arg_73503;
                    
                    defunc_0_add_arg_73503 = ((int64_t *) mem_70895)[i_73502];
                    
                    int64_t defunc_1_add_res_73504 = add64((int64_t) 1,
                                                           defunc_0_add_arg_73503);
                    
                    defunc_0_f_res_73501 = defunc_1_add_res_73504;
                }
                
                int64_t binop_p_73505 = sub64(defunc_0_f_res_73501,
                                              min_res_73348);
                double defunc_0_f_res_73506 = sitofp_i64_f64(binop_p_73505);
                double abs_res_73507 = fabs(defunc_0_f_res_73506);
                double tmp1_73508 = abs_res_73507 / defunc_1_f_res_73432;
                double x_73509 = tmp1_73508 * tmp1_73508;
                double y_73510 = tmp1_73508 * x_73509;
                double tmp2_73511 = 1.0 - y_73510;
                double x_73512 = tmp2_73511 * tmp2_73511;
                double tmp3_73513 = tmp2_73511 * x_73512;
                double tmp4_73514 = x_73499 * tmp3_73513;
                double defunc_1_f_res_73515 = defunc_0_f_res_73506 * tmp4_73514;
                double defunc_1_f_res_73516 = defunc_0_f_res_73506 *
                       defunc_1_f_res_73515;
                double defunc_0_f_res_73517;
                
                if (cond_73500) {
                    defunc_0_f_res_73517 = 0.0;
                } else {
                    int64_t i_73518 = add64(max_res_73413, i_73496);
                    double defunc_0_add_arg_73519;
                    
                    defunc_0_add_arg_73519 = ((double *) mem_70892)[i_73518];
                    defunc_0_f_res_73517 = defunc_0_add_arg_73519;
                }
                
                double x_73520 = a12_73489 * tmp4_73514;
                double y_73521 = b12_73490 * defunc_1_f_res_73515;
                double x_73522 = x_73520 + y_73521;
                double y_73523 = c12_73491 * defunc_1_f_res_73516;
                double x_73524 = x_73522 + y_73523;
                double defunc_9_fit_fun_res_73525 = defunc_0_f_res_73517 *
                       x_73524;
                double x_73526 = b12_73490 * tmp4_73514;
                double y_73527 = b2_73492 * defunc_1_f_res_73515;
                double x_73528 = x_73526 + y_73527;
                double y_73529 = c2_73493 * defunc_1_f_res_73516;
                double x_73530 = x_73528 + y_73529;
                double defunc_9_slope_fun_res_73531 = defunc_0_f_res_73517 *
                       x_73530;
                double defunc_1_op_res_73532 = defunc_9_fit_fun_res_73525 +
                       redout_73497;
                double defunc_1_op_res_73533 = defunc_9_slope_fun_res_73531 +
                       redout_73498;
                double redout_tmp_73560 = defunc_1_op_res_73532;
                double redout_tmp_73561 = defunc_1_op_res_73533;
                
                redout_73497 = redout_tmp_73560;
                redout_73498 = redout_tmp_73561;
            }
            defunc_2_reduce_res_73494 = redout_73497;
            defunc_2_reduce_res_73495 = redout_73498;
            ((double *) mem_70952)[i_73344] = defunc_2_reduce_res_73494;
            ((double *) mem_70955)[i_73344] = defunc_2_reduce_res_73495;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70983.mem + gtid_67782 * n_m_65386 * (int64_t) 8,
                    mem_70952 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70987.mem + gtid_67782 * n_m_65386 * (int64_t) 8,
                    mem_70955 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70877);
    free(mem_70892);
    free(mem_70895);
    free(mem_70922);
    free(mem_70937);
    free(mem_70952);
    free(mem_70955);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77175_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77175_end -
                 futhark_mc_segmap_parloop_77175_start;
        
        ctx->futhark_mc_segmap_parloop_77175_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77175_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77175_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77173(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_67781 = tid;
    int num_tasks_73311 = info.nsubtasks;
    struct futhark_mc_task_77172 *futhark_mc_task_77172 =
                                 (struct futhark_mc_task_77172 *) args;
    struct futhark_context *ctx = futhark_mc_task_77172->ctx;
    uint64_t futhark_mc_segmap_task_77173_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77173_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77172->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77172->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77172->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77172->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77172->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77172->free_i_65392;
    bool x_65393 = futhark_mc_task_77172->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77172->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77172->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77172->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77172->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70855 = futhark_mc_task_77172->free_bytes_70855;
    int64_t bytes_70867 = futhark_mc_task_77172->free_bytes_70867;
    int64_t bytes_70870 = futhark_mc_task_77172->free_bytes_70870;
    struct memblock mem_70983 = {.desc ="mem_70983", .mem =
                                 futhark_mc_task_77172->free_mem_70983, .size =
                                 0, .references =NULL};
    struct memblock mem_70987 = {.desc ="mem_70987", .mem =
                                 futhark_mc_task_77172->free_mem_70987, .size =
                                 0, .references =NULL};
    int64_t iter_73312;
    struct futhark_mc_segmap_parloop_struct_77174
    futhark_mc_segmap_parloop_struct_77174;
    
    futhark_mc_segmap_parloop_struct_77174.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77174.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77174.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77174.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77174.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77174.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77174.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77174.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77174.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77174.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77174.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77174.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77174.free_bytes_70855 = bytes_70855;
    futhark_mc_segmap_parloop_struct_77174.free_bytes_70867 = bytes_70867;
    futhark_mc_segmap_parloop_struct_77174.free_bytes_70870 = bytes_70870;
    futhark_mc_segmap_parloop_struct_77174.free_mem_70983 = mem_70983.mem;
    futhark_mc_segmap_parloop_struct_77174.free_mem_70987 = mem_70987.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77175_task;
    
    futhark_mc_segmap_parloop_77175_task.name =
        "futhark_mc_segmap_parloop_77175";
    futhark_mc_segmap_parloop_77175_task.fn = futhark_mc_segmap_parloop_77175;
    futhark_mc_segmap_parloop_77175_task.args =
        &futhark_mc_segmap_parloop_struct_77174;
    futhark_mc_segmap_parloop_77175_task.iterations = iterations;
    futhark_mc_segmap_parloop_77175_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77175_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77175_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77175_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77175_task);
    
    if (futhark_mc_segmap_parloop_77175_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77175_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77175_total_end -
                 futhark_mc_segmap_parloop_77175_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77175_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77175_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77175_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77173_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77173_end -
                 futhark_mc_segmap_task_77173_start;
        
        ctx->futhark_mc_segmap_task_77173_runs[tid]++;
        ctx->futhark_mc_segmap_task_77173_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77173_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77184 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70855;
    int64_t free_bytes_70867;
    int64_t free_bytes_70870;
    unsigned char *free_mem_70983;
    unsigned char *free_mem_70987;
};
struct futhark_mc_task_77193 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68003;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70856;
};
struct futhark_mc_scan_stage_1_parloop_struct_77196 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68003;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70856;
};
static int futhark_mc_scan_stage_1_parloop_77197(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_73563, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_1_parloop_struct_77196
    *futhark_mc_scan_stage_1_parloop_struct_77196 =
    (struct futhark_mc_scan_stage_1_parloop_struct_77196 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_1_parloop_struct_77196->ctx;
    uint64_t futhark_mc_scan_stage_1_parloop_77197_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77197_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_1_parloop_struct_77196->free_n_65378;
    int64_t gtid_68003 =
            futhark_mc_scan_stage_1_parloop_struct_77196->free_gtid_68003;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_1_parloop_struct_77196->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70856 = {.desc ="mem_70856", .mem =
                                 futhark_mc_scan_stage_1_parloop_struct_77196->free_mem_70856,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73978 = start;
    int64_t x_73565;
    int64_t x_73566;
    
    x_73565 = (int64_t) 0;
    for (; iter_73978 < end; iter_73978++) {
        int64_t gtid_73564 = iter_73978;
        
        // stage 1 scan body
        {
            double x_73568;
            
            x_73568 = ((double *) Y_mem_70603.mem)[gtid_68003 * n_65378 +
                                                   gtid_73564];
            
            bool isnan_res_73569;
            
            isnan_res_73569 = futrts_isnan64(x_73568);
            
            bool defunc_0_p_res_73570 = !isnan_res_73569;
            int64_t defunc_0_f_res_73571 = btoi_bool_i64(defunc_0_p_res_73570);
            
            // write mapped values results to memory
            { }
            x_73565 = x_73565;
            // Read next values
            {
                x_73566 = defunc_0_f_res_73571;
            }
            
            int64_t defunc_1_op_res_73567 = add64(x_73565, x_73566);
            
            ((int64_t *) mem_70856.mem)[gtid_73564] = defunc_1_op_res_73567;
            x_73565 = defunc_1_op_res_73567;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77197_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77197_end -
                 futhark_mc_scan_stage_1_parloop_77197_start;
        
        ctx->futhark_mc_scan_stage_1_parloop_77197_runs[tid]++;
        ctx->futhark_mc_scan_stage_1_parloop_77197_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_1_parloop_77197_iter[tid] += iterations;
    }
    return err;
}
struct futhark_mc_scan_stage_3_parloop_struct_77198 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68003;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70856;
};
static int futhark_mc_scan_stage_3_parloop_77199(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_73563, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_3_parloop_struct_77198
    *futhark_mc_scan_stage_3_parloop_struct_77198 =
    (struct futhark_mc_scan_stage_3_parloop_struct_77198 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_3_parloop_struct_77198->ctx;
    uint64_t futhark_mc_scan_stage_3_parloop_77199_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_3_parloop_77199_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_3_parloop_struct_77198->free_n_65378;
    int64_t gtid_68003 =
            futhark_mc_scan_stage_3_parloop_struct_77198->free_gtid_68003;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_3_parloop_struct_77198->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70856 = {.desc ="mem_70856", .mem =
                                 futhark_mc_scan_stage_3_parloop_struct_77198->free_mem_70856,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73990 = start;
    int64_t x_73987;
    int64_t x_73988;
    
    if (iter_73990 == (int64_t) 0) {
        x_73987 = (int64_t) 0;
    } else {
        x_73987 = ((int64_t *) mem_70856.mem)[iter_73990 - (int64_t) 1];
    }
    for (; iter_73990 < end; iter_73990++) {
        int64_t gtid_73564 = iter_73990;
        
        // stage 3 scan body
        {
            double x_73568;
            
            x_73568 = ((double *) Y_mem_70603.mem)[gtid_68003 * n_65378 +
                                                   gtid_73564];
            
            bool isnan_res_73569;
            
            isnan_res_73569 = futrts_isnan64(x_73568);
            
            bool defunc_0_p_res_73570 = !isnan_res_73569;
            int64_t defunc_0_f_res_73571 = btoi_bool_i64(defunc_0_p_res_73570);
            
            x_73987 = x_73987;
            x_73988 = defunc_0_f_res_73571;
            
            int64_t defunc_1_op_res_73989 = add64(x_73987, x_73988);
            
            ((int64_t *) mem_70856.mem)[gtid_73564] = defunc_1_op_res_73989;
            x_73987 = defunc_1_op_res_73989;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_3_parloop_77199_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77199_end -
                 futhark_mc_scan_stage_3_parloop_77199_start;
        
        ctx->futhark_mc_scan_stage_3_parloop_77199_runs[tid]++;
        ctx->futhark_mc_scan_stage_3_parloop_77199_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_3_parloop_77199_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segscan_task_77194(void *args, int64_t iterations, int tid,
                                  struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73563 = tid;
    int num_tasks_73977 = info.nsubtasks;
    struct futhark_mc_task_77193 *futhark_mc_task_77193 =
                                 (struct futhark_mc_task_77193 *) args;
    struct futhark_context *ctx = futhark_mc_task_77193->ctx;
    uint64_t futhark_mc_segscan_task_77194_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segscan_task_77194_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77193->free_n_65378;
    int64_t gtid_68003 = futhark_mc_task_77193->free_gtid_68003;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77193->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70856 = {.desc ="mem_70856", .mem =
                                 futhark_mc_task_77193->free_mem_70856, .size =
                                 0, .references =NULL};
    size_t scan_stage_2_accum_mem_73984_cached_sizze_77195 = 0;
    unsigned char *scan_stage_2_accum_mem_73984 = NULL;
    int64_t iter_73978;
    struct futhark_mc_scan_stage_1_parloop_struct_77196
    futhark_mc_scan_stage_1_parloop_struct_77196;
    
    futhark_mc_scan_stage_1_parloop_struct_77196.ctx = ctx;
    futhark_mc_scan_stage_1_parloop_struct_77196.free_n_65378 = n_65378;
    futhark_mc_scan_stage_1_parloop_struct_77196.free_gtid_68003 = gtid_68003;
    futhark_mc_scan_stage_1_parloop_struct_77196.free_Y_mem_70603 =
        Y_mem_70603.mem;
    futhark_mc_scan_stage_1_parloop_struct_77196.free_mem_70856 = mem_70856.mem;
    
    struct scheduler_parloop futhark_mc_scan_stage_1_parloop_77197_task;
    
    futhark_mc_scan_stage_1_parloop_77197_task.name =
        "futhark_mc_scan_stage_1_parloop_77197";
    futhark_mc_scan_stage_1_parloop_77197_task.fn =
        futhark_mc_scan_stage_1_parloop_77197;
    futhark_mc_scan_stage_1_parloop_77197_task.args =
        &futhark_mc_scan_stage_1_parloop_struct_77196;
    futhark_mc_scan_stage_1_parloop_77197_task.iterations = iterations;
    futhark_mc_scan_stage_1_parloop_77197_task.info = info;
    
    uint64_t futhark_mc_scan_stage_1_parloop_77197_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77197_total_start = get_wall_time();
    
    int futhark_mc_scan_stage_1_parloop_77197_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_scan_stage_1_parloop_77197_task);
    
    if (futhark_mc_scan_stage_1_parloop_77197_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77197_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77197_total_end -
                 futhark_mc_scan_stage_1_parloop_77197_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77197_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77197_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77197_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    if (slt32(1, num_tasks_73977)) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmentedScan stage 2");
        
        int64_t x_73979;
        int64_t x_73980;
        int64_t offset_73982 = (int64_t) 0;
        int64_t offset_index_73983 = (int64_t) 0;
        
        if (scan_stage_2_accum_mem_73984_cached_sizze_77195 <
            (size_t) (int64_t) 8) {
            scan_stage_2_accum_mem_73984 = realloc(scan_stage_2_accum_mem_73984,
                                                   (int64_t) 8);
            scan_stage_2_accum_mem_73984_cached_sizze_77195 = (int64_t) 8;
        }
        ((int64_t *) scan_stage_2_accum_mem_73984)[(int64_t) 0] = (int64_t) 0;
        for (int32_t i_73986 = 0; i_73986 < num_tasks_73977 - 1; i_73986++) {
            offset_73982 = squot64(n_65378, sext_i32_i64(num_tasks_73977));
            if (slt64(sext_i32_i64(i_73986), srem64(n_65378,
                                                    sext_i32_i64(num_tasks_73977)))) {
                offset_73982 += (int64_t) 1;
            }
            offset_index_73983 += offset_73982;
            
            int64_t gtid_73564 = offset_index_73983;
            double x_73568;
            
            x_73568 = ((double *) Y_mem_70603.mem)[gtid_68003 * n_65378 +
                                                   gtid_73564];
            
            bool isnan_res_73569;
            
            isnan_res_73569 = futrts_isnan64(x_73568);
            
            bool defunc_0_p_res_73570 = !isnan_res_73569;
            int64_t defunc_0_f_res_73571 = btoi_bool_i64(defunc_0_p_res_73570);
            
            // Read carry in
            {
                x_73979 =
                    ((int64_t *) scan_stage_2_accum_mem_73984)[(int64_t) 0];
            }
            // Read next values
            {
                x_73980 = ((int64_t *) mem_70856.mem)[offset_index_73983 -
                                                      (int64_t) 1];
            }
            
            int64_t defunc_1_op_res_73981 = add64(x_73979, x_73980);
            
            ((int64_t *) mem_70856.mem)[offset_index_73983 - (int64_t) 1] =
                defunc_1_op_res_73981;
            ((int64_t *) scan_stage_2_accum_mem_73984)[(int64_t) 0] =
                defunc_1_op_res_73981;
        }
        
        int64_t iter_73990 = (int64_t) 0;
        struct futhark_mc_scan_stage_3_parloop_struct_77198
        futhark_mc_scan_stage_3_parloop_struct_77198;
        
        futhark_mc_scan_stage_3_parloop_struct_77198.ctx = ctx;
        futhark_mc_scan_stage_3_parloop_struct_77198.free_n_65378 = n_65378;
        futhark_mc_scan_stage_3_parloop_struct_77198.free_gtid_68003 =
            gtid_68003;
        futhark_mc_scan_stage_3_parloop_struct_77198.free_Y_mem_70603 =
            Y_mem_70603.mem;
        futhark_mc_scan_stage_3_parloop_struct_77198.free_mem_70856 =
            mem_70856.mem;
        
        struct scheduler_parloop futhark_mc_scan_stage_3_parloop_77199_task;
        
        futhark_mc_scan_stage_3_parloop_77199_task.name =
            "futhark_mc_scan_stage_3_parloop_77199";
        futhark_mc_scan_stage_3_parloop_77199_task.fn =
            futhark_mc_scan_stage_3_parloop_77199;
        futhark_mc_scan_stage_3_parloop_77199_task.args =
            &futhark_mc_scan_stage_3_parloop_struct_77198;
        futhark_mc_scan_stage_3_parloop_77199_task.iterations = iterations;
        futhark_mc_scan_stage_3_parloop_77199_task.info = info;
        
        uint64_t futhark_mc_scan_stage_3_parloop_77199_total_start = 0;
        
        if (ctx->profiling && !ctx->profiling_paused)
            futhark_mc_scan_stage_3_parloop_77199_total_start = get_wall_time();
        
        int futhark_mc_scan_stage_3_parloop_77199_err =
            scheduler_execute_task(&ctx->scheduler,
                                   &futhark_mc_scan_stage_3_parloop_77199_task);
        
        if (futhark_mc_scan_stage_3_parloop_77199_err != 0) {
            err = 1;
            goto cleanup;
        }
        if (ctx->profiling && !ctx->profiling_paused) {
            uint64_t futhark_mc_scan_stage_3_parloop_77199_total_end =
                     get_wall_time();
            uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77199_total_end -
                     futhark_mc_scan_stage_3_parloop_77199_total_start;
            
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77199_total_runs,
                               1, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77199_total_total_runtime,
                               elapsed, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77199_total_iter,
                               iterations, __ATOMIC_RELAXED);
        }
    }
    
  cleanup:
    {
        free(scan_stage_2_accum_mem_73984);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segscan_task_77194_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segscan_task_77194_end -
                 futhark_mc_segscan_task_77194_start;
        
        ctx->futhark_mc_segscan_task_77194_runs[tid]++;
        ctx->futhark_mc_segscan_task_77194_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segscan_task_77194_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77200 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68003;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70856;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
};
struct futhark_mc_segmap_parloop_struct_77202 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68003;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70856;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
};
static int futhark_mc_segmap_parloop_77203(void *args, int64_t start,
                                           int64_t end, int flat_tid_73572,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77202
    *futhark_mc_segmap_parloop_struct_77202 =
    (struct futhark_mc_segmap_parloop_struct_77202 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77202->ctx;
    uint64_t futhark_mc_segmap_parloop_77203_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77203_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77202->free_n_65378;
    int64_t gtid_68003 =
            futhark_mc_segmap_parloop_struct_77202->free_gtid_68003;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77202->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70856 = {.desc ="mem_70856", .mem =
                                 futhark_mc_segmap_parloop_struct_77202->free_mem_70856,
                                 .size =0, .references =NULL};
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_segmap_parloop_struct_77202->free_mem_70859,
                                 .size =0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_segmap_parloop_struct_77202->free_mem_70862,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_73994 = start;
    
    for (; iter_73994 < end; iter_73994++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73997 = n_65378;
        int64_t gtid_73573 = iter_73994;
        int64_t remnant_73998 = iter_73994 - gtid_73573;
        double x_73574;
        
        x_73574 = ((double *) Y_mem_70603.mem)[gtid_68003 * n_65378 +
                                               gtid_73573];
        
        bool isnan_res_73575;
        
        isnan_res_73575 = futrts_isnan64(x_73574);
        
        bool defunc_0_p_res_73576 = !isnan_res_73575;
        int64_t defunc_1_f_res_73577;
        
        if (defunc_0_p_res_73576) {
            int64_t x_73995;
            
            x_73995 = ((int64_t *) mem_70856.mem)[gtid_73573];
            
            int64_t defunc_1_f_res_t_res_73996 = sub64(x_73995, (int64_t) 1);
            
            defunc_1_f_res_73577 = defunc_1_f_res_t_res_73996;
        } else {
            defunc_1_f_res_73577 = (int64_t) -1;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_73577) &&
            slt64(defunc_1_f_res_73577, n_65378)) {
            ((int64_t *) mem_70862.mem)[defunc_1_f_res_73577] = gtid_73573;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_73577) &&
            slt64(defunc_1_f_res_73577, n_65378)) {
            ((double *) mem_70859.mem)[defunc_1_f_res_73577] = x_73574;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77203_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77203_end -
                 futhark_mc_segmap_parloop_77203_start;
        
        ctx->futhark_mc_segmap_parloop_77203_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77203_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77203_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77201(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73572 = tid;
    int num_tasks_73993 = info.nsubtasks;
    struct futhark_mc_task_77200 *futhark_mc_task_77200 =
                                 (struct futhark_mc_task_77200 *) args;
    struct futhark_context *ctx = futhark_mc_task_77200->ctx;
    uint64_t futhark_mc_segmap_task_77201_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77201_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77200->free_n_65378;
    int64_t gtid_68003 = futhark_mc_task_77200->free_gtid_68003;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77200->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70856 = {.desc ="mem_70856", .mem =
                                 futhark_mc_task_77200->free_mem_70856, .size =
                                 0, .references =NULL};
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_task_77200->free_mem_70859, .size =
                                 0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_task_77200->free_mem_70862, .size =
                                 0, .references =NULL};
    int64_t iter_73994;
    struct futhark_mc_segmap_parloop_struct_77202
    futhark_mc_segmap_parloop_struct_77202;
    
    futhark_mc_segmap_parloop_struct_77202.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77202.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77202.free_gtid_68003 = gtid_68003;
    futhark_mc_segmap_parloop_struct_77202.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77202.free_mem_70856 = mem_70856.mem;
    futhark_mc_segmap_parloop_struct_77202.free_mem_70859 = mem_70859.mem;
    futhark_mc_segmap_parloop_struct_77202.free_mem_70862 = mem_70862.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77203_task;
    
    futhark_mc_segmap_parloop_77203_task.name =
        "futhark_mc_segmap_parloop_77203";
    futhark_mc_segmap_parloop_77203_task.fn = futhark_mc_segmap_parloop_77203;
    futhark_mc_segmap_parloop_77203_task.args =
        &futhark_mc_segmap_parloop_struct_77202;
    futhark_mc_segmap_parloop_77203_task.iterations = iterations;
    futhark_mc_segmap_parloop_77203_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77203_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77203_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77203_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77203_task);
    
    if (futhark_mc_segmap_parloop_77203_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77203_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77203_total_end -
                 futhark_mc_segmap_parloop_77203_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77203_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77203_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77203_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77201_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77201_end -
                 futhark_mc_segmap_task_77201_start;
        
        ctx->futhark_mc_segmap_task_77201_runs[tid]++;
        ctx->futhark_mc_segmap_task_77201_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77201_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77204 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70865;
};
struct futhark_mc_segmap_parloop_struct_77206 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70865;
};
static int futhark_mc_segmap_parloop_77207(void *args, int64_t start,
                                           int64_t end, int flat_tid_73580,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77206
    *futhark_mc_segmap_parloop_struct_77206 =
    (struct futhark_mc_segmap_parloop_struct_77206 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77206->ctx;
    uint64_t futhark_mc_segmap_parloop_77207_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77207_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77206->free_n_65378;
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_segmap_parloop_struct_77206->free_mem_70862,
                                 .size =0, .references =NULL};
    struct memblock mem_70865 = {.desc ="mem_70865", .mem =
                                 futhark_mc_segmap_parloop_struct_77206->free_mem_70865,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74000 = start;
    
    for (; iter_74000 < end; iter_74000++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74001 = n_65378;
        int64_t gtid_73581 = iter_74000;
        int64_t remnant_74002 = iter_74000 - gtid_73581;
        int64_t x_73582;
        
        x_73582 = ((int64_t *) mem_70862.mem)[gtid_73581];
        
        int64_t defunc_0_f_res_73583 = add64((int64_t) 1, x_73582);
        
        ((int64_t *) mem_70865.mem)[gtid_73581] = defunc_0_f_res_73583;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77207_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77207_end -
                 futhark_mc_segmap_parloop_77207_start;
        
        ctx->futhark_mc_segmap_parloop_77207_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77207_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77207_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77205(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73580 = tid;
    int num_tasks_73999 = info.nsubtasks;
    struct futhark_mc_task_77204 *futhark_mc_task_77204 =
                                 (struct futhark_mc_task_77204 *) args;
    struct futhark_context *ctx = futhark_mc_task_77204->ctx;
    uint64_t futhark_mc_segmap_task_77205_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77205_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77204->free_n_65378;
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_task_77204->free_mem_70862, .size =
                                 0, .references =NULL};
    struct memblock mem_70865 = {.desc ="mem_70865", .mem =
                                 futhark_mc_task_77204->free_mem_70865, .size =
                                 0, .references =NULL};
    int64_t iter_74000;
    struct futhark_mc_segmap_parloop_struct_77206
    futhark_mc_segmap_parloop_struct_77206;
    
    futhark_mc_segmap_parloop_struct_77206.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77206.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77206.free_mem_70862 = mem_70862.mem;
    futhark_mc_segmap_parloop_struct_77206.free_mem_70865 = mem_70865.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77207_task;
    
    futhark_mc_segmap_parloop_77207_task.name =
        "futhark_mc_segmap_parloop_77207";
    futhark_mc_segmap_parloop_77207_task.fn = futhark_mc_segmap_parloop_77207;
    futhark_mc_segmap_parloop_77207_task.args =
        &futhark_mc_segmap_parloop_struct_77206;
    futhark_mc_segmap_parloop_77207_task.iterations = iterations;
    futhark_mc_segmap_parloop_77207_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77207_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77207_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77207_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77207_task);
    
    if (futhark_mc_segmap_parloop_77207_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77207_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77207_total_end -
                 futhark_mc_segmap_parloop_77207_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77207_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77207_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77207_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77205_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77205_end -
                 futhark_mc_segmap_task_77205_start;
        
        ctx->futhark_mc_segmap_task_77205_runs[tid]++;
        ctx->futhark_mc_segmap_task_77205_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77205_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77208 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_68015;
    unsigned char *free_mem_70868;
};
struct futhark_mc_segmap_parloop_struct_77210 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_68015;
    unsigned char *free_mem_70868;
};
static int futhark_mc_segmap_parloop_77211(void *args, int64_t start,
                                           int64_t end, int flat_tid_73584,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77210
    *futhark_mc_segmap_parloop_struct_77210 =
    (struct futhark_mc_segmap_parloop_struct_77210 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77210->ctx;
    uint64_t futhark_mc_segmap_parloop_77211_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77211_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77210->free_q_65380;
    int64_t last_res_68015 =
            futhark_mc_segmap_parloop_struct_77210->free_last_res_68015;
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_segmap_parloop_struct_77210->free_mem_70868,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74004 = start;
    
    for (; iter_74004 < end; iter_74004++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74005 = q_65380;
        int64_t gtid_73585 = iter_74004;
        int64_t remnant_74006 = iter_74004 - gtid_73585;
        bool cond_73586 = sle64(last_res_68015, gtid_73585);
        double defunc_0_f_res_73587;
        
        if (cond_73586) {
            defunc_0_f_res_73587 = 0.0;
        } else {
            defunc_0_f_res_73587 = 1.0;
        }
        ((double *) mem_70868.mem)[gtid_73585] = defunc_0_f_res_73587;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77211_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77211_end -
                 futhark_mc_segmap_parloop_77211_start;
        
        ctx->futhark_mc_segmap_parloop_77211_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77211_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77211_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77209(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73584 = tid;
    int num_tasks_74003 = info.nsubtasks;
    struct futhark_mc_task_77208 *futhark_mc_task_77208 =
                                 (struct futhark_mc_task_77208 *) args;
    struct futhark_context *ctx = futhark_mc_task_77208->ctx;
    uint64_t futhark_mc_segmap_task_77209_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77209_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77208->free_q_65380;
    int64_t last_res_68015 = futhark_mc_task_77208->free_last_res_68015;
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_task_77208->free_mem_70868, .size =
                                 0, .references =NULL};
    int64_t iter_74004;
    struct futhark_mc_segmap_parloop_struct_77210
    futhark_mc_segmap_parloop_struct_77210;
    
    futhark_mc_segmap_parloop_struct_77210.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77210.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77210.free_last_res_68015 = last_res_68015;
    futhark_mc_segmap_parloop_struct_77210.free_mem_70868 = mem_70868.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77211_task;
    
    futhark_mc_segmap_parloop_77211_task.name =
        "futhark_mc_segmap_parloop_77211";
    futhark_mc_segmap_parloop_77211_task.fn = futhark_mc_segmap_parloop_77211;
    futhark_mc_segmap_parloop_77211_task.args =
        &futhark_mc_segmap_parloop_struct_77210;
    futhark_mc_segmap_parloop_77211_task.iterations = iterations;
    futhark_mc_segmap_parloop_77211_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77211_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77211_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77211_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77211_task);
    
    if (futhark_mc_segmap_parloop_77211_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77211_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77211_total_end -
                 futhark_mc_segmap_parloop_77211_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77211_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77211_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77211_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77209_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77209_end -
                 futhark_mc_segmap_task_77209_start;
        
        ctx->futhark_mc_segmap_task_77209_runs[tid]++;
        ctx->futhark_mc_segmap_task_77209_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77209_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77212 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_68015;
    int64_t free_min_arg_68034;
    int64_t free_min_arg_68035;
    int64_t free_min_res_68036;
    double free_max_res_68040;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70865;
    unsigned char *free_mem_70868;
    unsigned char *free_mem_70871;
    unsigned char *free_mem_70874;
};
struct futhark_mc_segmap_parloop_struct_77214 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_68015;
    int64_t free_min_arg_68034;
    int64_t free_min_arg_68035;
    int64_t free_min_res_68036;
    double free_max_res_68040;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70865;
    unsigned char *free_mem_70868;
    unsigned char *free_mem_70871;
    unsigned char *free_mem_70874;
};
static int futhark_mc_segmap_parloop_77215(void *args, int64_t start,
                                           int64_t end, int flat_tid_73786,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77214
    *futhark_mc_segmap_parloop_struct_77214 =
    (struct futhark_mc_segmap_parloop_struct_77214 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77214->ctx;
    uint64_t futhark_mc_segmap_parloop_77215_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77215_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77214->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77214->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77214->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77214->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77214->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77214->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77214->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77214->free_loop_cond_65403;
    int64_t last_res_68015 =
            futhark_mc_segmap_parloop_struct_77214->free_last_res_68015;
    int64_t min_arg_68034 =
            futhark_mc_segmap_parloop_struct_77214->free_min_arg_68034;
    int64_t min_arg_68035 =
            futhark_mc_segmap_parloop_struct_77214->free_min_arg_68035;
    int64_t min_res_68036 =
            futhark_mc_segmap_parloop_struct_77214->free_min_res_68036;
    double max_res_68040 =
           futhark_mc_segmap_parloop_struct_77214->free_max_res_68040;
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_segmap_parloop_struct_77214->free_mem_70859,
                                 .size =0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_segmap_parloop_struct_77214->free_mem_70862,
                                 .size =0, .references =NULL};
    struct memblock mem_70865 = {.desc ="mem_70865", .mem =
                                 futhark_mc_segmap_parloop_struct_77214->free_mem_70865,
                                 .size =0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_segmap_parloop_struct_77214->free_mem_70868,
                                 .size =0, .references =NULL};
    struct memblock mem_70871 = {.desc ="mem_70871", .mem =
                                 futhark_mc_segmap_parloop_struct_77214->free_mem_70871,
                                 .size =0, .references =NULL};
    struct memblock mem_70874 = {.desc ="mem_70874", .mem =
                                 futhark_mc_segmap_parloop_struct_77214->free_mem_70874,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74008 = start;
    
    for (; iter_74008 < end; iter_74008++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74133 = n_m_65386;
        int64_t gtid_73787 = iter_74008;
        int64_t remnant_74134 = iter_74008 - gtid_73787;
        int64_t min_arg_73788 = mul64(jump_65382, gtid_73787);
        int64_t min_res_73789 = smin64(i_65392, min_arg_73788);
        int64_t defunc_0_g_res_73790 = add64((int64_t) 1, min_res_73789);
        bool init_idx_73791;
        int64_t init_idx_73792;
        int64_t init_idx_73793;
        bool loop_while_74009;
        int64_t low_74010;
        int64_t high_74011;
        
        loop_while_74009 = x_65393;
        low_74010 = (int64_t) 0;
        high_74011 = i_65392;
        while (loop_while_74009) {
            int64_t x_74012 = add64(low_74010, high_74011);
            int64_t mid_74013 = sdiv64(x_74012, (int64_t) 2);
            bool x_74014 = sle64((int64_t) 0, mid_74013);
            bool y_74015 = slt64(mid_74013, n_65378);
            bool bounds_check_74016 = x_74014 && y_74015;
            bool index_certs_74017;
            
            if (!bounds_check_74016) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_74013,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_74018;
            
            mid_id_74018 = ((int64_t *) mem_70865.mem)[mid_74013];
            
            bool cond_74019 = slt64(mid_id_74018, (int64_t) 0);
            int64_t mid_idx_74020;
            
            if (cond_74019) {
                mid_idx_74020 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_74020 = mid_id_74018;
            }
            
            bool cond_74021 = sle64(defunc_0_g_res_73790, mid_idx_74020);
            int64_t loopres_74022;
            int64_t loopres_74023;
            
            if (cond_74021) {
                int64_t loopres_t_res_74024 = sub64(mid_74013, (int64_t) 1);
                
                loopres_74022 = low_74010;
                loopres_74023 = loopres_t_res_74024;
            } else {
                int64_t loopres_f_res_74025 = add64((int64_t) 1, mid_74013);
                
                loopres_74022 = loopres_f_res_74025;
                loopres_74023 = high_74011;
            }
            
            bool loop_cond_74026 = sle64(loopres_74022, loopres_74023);
            bool loop_while_tmp_74135 = loop_cond_74026;
            int64_t low_tmp_74136 = loopres_74022;
            int64_t high_tmp_74137 = loopres_74023;
            
            loop_while_74009 = loop_while_tmp_74135;
            low_74010 = low_tmp_74136;
            high_74011 = high_tmp_74137;
        }
        init_idx_73791 = loop_while_74009;
        init_idx_73792 = low_74010;
        init_idx_73793 = high_74011;
        
        bool idx_73812;
        int64_t idx_73813;
        int64_t idx_73814;
        int64_t idx_73815;
        bool loop_while_74027;
        int64_t l_idx_74028;
        int64_t r_idx_74029;
        int64_t span_74030;
        
        loop_while_74027 = loop_cond_65403;
        l_idx_74028 = init_idx_73792;
        r_idx_74029 = init_idx_73792;
        span_74030 = (int64_t) 1;
        while (loop_while_74027) {
            int64_t max_arg_74031 = sub64(l_idx_74028, (int64_t) 1);
            int64_t max_res_74032 = smax64((int64_t) 0, max_arg_74031);
            int64_t min_arg_74033 = add64((int64_t) 1, r_idx_74029);
            int64_t min_res_74034 = smin64(min_arg_68034, min_arg_74033);
            bool x_74035 = sle64((int64_t) 0, max_res_74032);
            bool y_74036 = slt64(max_res_74032, n_65378);
            bool bounds_check_74037 = x_74035 && y_74036;
            bool index_certs_74038;
            
            if (!bounds_check_74037) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_74032,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74039;
            
            x_74039 = ((int64_t *) mem_70865.mem)[max_res_74032];
            
            int64_t abs_arg_74040 = sub64(x_74039, defunc_0_g_res_73790);
            int64_t abs_res_74041 = abs64(abs_arg_74040);
            bool x_74042 = sle64((int64_t) 0, min_res_74034);
            bool y_74043 = slt64(min_res_74034, n_65378);
            bool bounds_check_74044 = x_74042 && y_74043;
            bool index_certs_74045;
            
            if (!bounds_check_74044) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_74034,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74046;
            
            x_74046 = ((int64_t *) mem_70865.mem)[min_res_74034];
            
            int64_t abs_arg_74047 = sub64(x_74046, defunc_0_g_res_73790);
            int64_t abs_res_74048 = abs64(abs_arg_74047);
            bool cond_74049 = max_res_74032 == l_idx_74028;
            int64_t loopres_74050;
            int64_t loopres_74051;
            int64_t loopres_74052;
            
            if (cond_74049) {
                loopres_74050 = l_idx_74028;
                loopres_74051 = r_idx_74029;
                loopres_74052 = min_res_65398;
            } else {
                bool cond_74053 = slt64(abs_res_74041, abs_res_74048);
                bool cond_f_res_74054 = min_res_74034 == r_idx_74029;
                bool x_74055 = !cond_74053;
                bool y_74056 = cond_f_res_74054 && x_74055;
                bool cond_74057 = cond_74053 || y_74056;
                int64_t loopres_f_res_74058;
                
                if (cond_74057) {
                    loopres_f_res_74058 = max_res_74032;
                } else {
                    loopres_f_res_74058 = l_idx_74028;
                }
                
                int64_t loopres_f_res_74059;
                
                if (cond_74057) {
                    loopres_f_res_74059 = r_idx_74029;
                } else {
                    loopres_f_res_74059 = min_res_74034;
                }
                
                int64_t loopres_f_res_74060;
                
                if (cond_74057) {
                    int64_t loopres_f_res_t_res_74061 = add64((int64_t) 1,
                                                              span_74030);
                    
                    loopres_f_res_74060 = loopres_f_res_t_res_74061;
                } else {
                    int64_t loopres_f_res_f_res_74062 = add64((int64_t) 1,
                                                              span_74030);
                    
                    loopres_f_res_74060 = loopres_f_res_f_res_74062;
                }
                loopres_74050 = loopres_f_res_74058;
                loopres_74051 = loopres_f_res_74059;
                loopres_74052 = loopres_f_res_74060;
            }
            
            bool loop_cond_74063 = slt64(loopres_74052, min_res_65398);
            bool loop_while_tmp_74138 = loop_cond_74063;
            int64_t l_idx_tmp_74139 = loopres_74050;
            int64_t r_idx_tmp_74140 = loopres_74051;
            int64_t span_tmp_74141 = loopres_74052;
            
            loop_while_74027 = loop_while_tmp_74138;
            l_idx_74028 = l_idx_tmp_74139;
            r_idx_74029 = r_idx_tmp_74140;
            span_74030 = span_tmp_74141;
        }
        idx_73812 = loop_while_74027;
        idx_73813 = l_idx_74028;
        idx_73814 = r_idx_74029;
        idx_73815 = span_74030;
        
        int64_t min_res_73853 = smin64(min_arg_68035, idx_73813);
        int64_t max_res_73854 = smax64((int64_t) 0, min_res_73853);
        int64_t x_73855 = add64(min_res_68036, max_res_73854);
        int64_t r_73856 = sub64(x_73855, (int64_t) 1);
        bool x_73857 = sle64((int64_t) 0, r_73856);
        bool y_73858 = slt64(r_73856, n_65378);
        bool bounds_check_73859 = x_73857 && y_73858;
        bool index_certs_73860;
        
        if (!bounds_check_73859) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_73856,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_73861;
        
        x_73861 = ((int64_t *) mem_70862.mem)[r_73856];
        
        int64_t abs_arg_73862 = sub64(x_73861, min_res_73789);
        int64_t abs_res_73863 = abs64(abs_arg_73862);
        bool x_73864 = sle64((int64_t) 0, max_res_73854);
        bool y_73865 = slt64(max_res_73854, n_65378);
        bool bounds_check_73866 = x_73864 && y_73865;
        bool index_certs_73867;
        
        if (!bounds_check_73866) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_73854,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_73868;
        
        x_73868 = ((int64_t *) mem_70862.mem)[max_res_73854];
        
        int64_t abs_arg_73869 = sub64(x_73868, min_res_73789);
        int64_t abs_res_73870 = abs64(abs_arg_73869);
        int64_t max_res_73871 = smax64(abs_res_73863, abs_res_73870);
        double defunc_0_f_res_73872 = sitofp_i64_f64(max_res_73871);
        double defunc_1_f_res_73873 = max_res_68040 + defunc_0_f_res_73872;
        double defunc_2_reduce_res_73874;
        double defunc_2_reduce_res_73875;
        double defunc_2_reduce_res_73876;
        double defunc_2_reduce_res_73877;
        double defunc_2_reduce_res_73878;
        double redout_74065;
        double redout_74066;
        double redout_74067;
        double redout_74068;
        double redout_74069;
        
        redout_74065 = 0.0;
        redout_74066 = 0.0;
        redout_74067 = 0.0;
        redout_74068 = 0.0;
        redout_74069 = 0.0;
        for (int64_t i_74064 = 0; i_74064 < q_65380; i_74064++) {
            double x_74070;
            
            x_74070 = ((double *) mem_70868.mem)[i_74064];
            
            bool cond_74071 = sle64(last_res_68015, i_74064);
            int64_t defunc_0_f_res_74072;
            
            if (cond_74071) {
                defunc_0_f_res_74072 = (int64_t) 0;
            } else {
                int64_t i_74073 = add64(max_res_73854, i_74064);
                int64_t defunc_0_add_arg_74074;
                
                defunc_0_add_arg_74074 = ((int64_t *) mem_70862.mem)[i_74073];
                
                int64_t defunc_1_add_res_74075 = add64((int64_t) 1,
                                                       defunc_0_add_arg_74074);
                
                defunc_0_f_res_74072 = defunc_1_add_res_74075;
            }
            
            int64_t binop_p_74076 = sub64(defunc_0_f_res_74072, min_res_73789);
            double defunc_0_f_res_74077 = sitofp_i64_f64(binop_p_74076);
            double abs_res_74078 = fabs(defunc_0_f_res_74077);
            double tmp1_74079 = abs_res_74078 / defunc_1_f_res_73873;
            double x_74080 = tmp1_74079 * tmp1_74079;
            double y_74081 = tmp1_74079 * x_74080;
            double tmp2_74082 = 1.0 - y_74081;
            double x_74083 = tmp2_74082 * tmp2_74082;
            double tmp3_74084 = tmp2_74082 * x_74083;
            double w_j_74085 = x_74070 * tmp3_74084;
            double xw_j_74086 = defunc_0_f_res_74077 * w_j_74085;
            double x2w_j_74087 = defunc_0_f_res_74077 * xw_j_74086;
            double x3w_j_74088 = defunc_0_f_res_74077 * x2w_j_74087;
            double x4w_j_74089 = defunc_0_f_res_74077 * x3w_j_74088;
            double defunc_1_op_res_74090 = w_j_74085 + redout_74065;
            double defunc_1_op_res_74091 = xw_j_74086 + redout_74066;
            double defunc_1_op_res_74092 = x2w_j_74087 + redout_74067;
            double defunc_1_op_res_74093 = x3w_j_74088 + redout_74068;
            double defunc_1_op_res_74094 = x4w_j_74089 + redout_74069;
            double redout_tmp_74142 = defunc_1_op_res_74090;
            double redout_tmp_74143 = defunc_1_op_res_74091;
            double redout_tmp_74144 = defunc_1_op_res_74092;
            double redout_tmp_74145 = defunc_1_op_res_74093;
            double redout_tmp_74146 = defunc_1_op_res_74094;
            
            redout_74065 = redout_tmp_74142;
            redout_74066 = redout_tmp_74143;
            redout_74067 = redout_tmp_74144;
            redout_74068 = redout_tmp_74145;
            redout_74069 = redout_tmp_74146;
        }
        defunc_2_reduce_res_73874 = redout_74065;
        defunc_2_reduce_res_73875 = redout_74066;
        defunc_2_reduce_res_73876 = redout_74067;
        defunc_2_reduce_res_73877 = redout_74068;
        defunc_2_reduce_res_73878 = redout_74069;
        
        double x_73910 = defunc_2_reduce_res_73876 * defunc_2_reduce_res_73878;
        double y_73911 = defunc_2_reduce_res_73877 * defunc_2_reduce_res_73877;
        double a12_73912 = x_73910 - y_73911;
        double x_73913 = defunc_2_reduce_res_73876 * defunc_2_reduce_res_73877;
        double y_73914 = defunc_2_reduce_res_73875 * defunc_2_reduce_res_73878;
        double b12_73915 = x_73913 - y_73914;
        double x_73916 = defunc_2_reduce_res_73875 * defunc_2_reduce_res_73877;
        double y_73917 = defunc_2_reduce_res_73876 * defunc_2_reduce_res_73876;
        double c12_73918 = x_73916 - y_73917;
        double x_73919 = defunc_2_reduce_res_73874 * defunc_2_reduce_res_73878;
        double b2_73920 = x_73919 - y_73917;
        double x_73921 = defunc_2_reduce_res_73875 * defunc_2_reduce_res_73876;
        double y_73922 = defunc_2_reduce_res_73874 * defunc_2_reduce_res_73877;
        double c2_73923 = x_73921 - y_73922;
        double x_73924 = defunc_2_reduce_res_73874 * a12_73912;
        double y_73925 = defunc_2_reduce_res_73875 * b12_73915;
        double x_73926 = x_73924 + y_73925;
        double y_73927 = defunc_2_reduce_res_73876 * c12_73918;
        double y_73928 = x_73926 + y_73927;
        double det_73929 = 1.0 / y_73928;
        double a12_73930 = a12_73912 * det_73929;
        double b12_73931 = b12_73915 * det_73929;
        double c12_73932 = c12_73918 * det_73929;
        double b2_73933 = b2_73920 * det_73929;
        double c2_73934 = c2_73923 * det_73929;
        double defunc_2_reduce_res_73935;
        double defunc_2_reduce_res_73936;
        double redout_74096;
        double redout_74097;
        
        redout_74096 = 0.0;
        redout_74097 = 0.0;
        for (int64_t i_74095 = 0; i_74095 < q_65380; i_74095++) {
            double x_74098;
            
            x_74098 = ((double *) mem_70868.mem)[i_74095];
            
            bool cond_74099 = sle64(last_res_68015, i_74095);
            int64_t defunc_0_f_res_74100;
            
            if (cond_74099) {
                defunc_0_f_res_74100 = (int64_t) 0;
            } else {
                int64_t i_74101 = add64(max_res_73854, i_74095);
                int64_t defunc_0_add_arg_74102;
                
                defunc_0_add_arg_74102 = ((int64_t *) mem_70862.mem)[i_74101];
                
                int64_t defunc_1_add_res_74103 = add64((int64_t) 1,
                                                       defunc_0_add_arg_74102);
                
                defunc_0_f_res_74100 = defunc_1_add_res_74103;
            }
            
            int64_t binop_p_74104 = sub64(defunc_0_f_res_74100, min_res_73789);
            double defunc_0_f_res_74105 = sitofp_i64_f64(binop_p_74104);
            double abs_res_74106 = fabs(defunc_0_f_res_74105);
            double tmp1_74107 = abs_res_74106 / defunc_1_f_res_73873;
            double x_74108 = tmp1_74107 * tmp1_74107;
            double y_74109 = tmp1_74107 * x_74108;
            double tmp2_74110 = 1.0 - y_74109;
            double x_74111 = tmp2_74110 * tmp2_74110;
            double tmp3_74112 = tmp2_74110 * x_74111;
            double tmp4_74113 = x_74098 * tmp3_74112;
            double defunc_1_f_res_74114 = defunc_0_f_res_74105 * tmp4_74113;
            double defunc_1_f_res_74115 = defunc_0_f_res_74105 *
                   defunc_1_f_res_74114;
            double defunc_0_f_res_74116;
            
            if (cond_74099) {
                defunc_0_f_res_74116 = 0.0;
            } else {
                int64_t i_74117 = add64(max_res_73854, i_74095);
                double defunc_0_add_arg_74118;
                
                defunc_0_add_arg_74118 = ((double *) mem_70859.mem)[i_74117];
                defunc_0_f_res_74116 = defunc_0_add_arg_74118;
            }
            
            double x_74119 = a12_73930 * tmp4_74113;
            double y_74120 = b12_73931 * defunc_1_f_res_74114;
            double x_74121 = x_74119 + y_74120;
            double y_74122 = c12_73932 * defunc_1_f_res_74115;
            double x_74123 = x_74121 + y_74122;
            double defunc_9_fit_fun_res_74124 = defunc_0_f_res_74116 * x_74123;
            double x_74125 = b12_73931 * tmp4_74113;
            double y_74126 = b2_73933 * defunc_1_f_res_74114;
            double x_74127 = x_74125 + y_74126;
            double y_74128 = c2_73934 * defunc_1_f_res_74115;
            double x_74129 = x_74127 + y_74128;
            double defunc_9_slope_fun_res_74130 = defunc_0_f_res_74116 *
                   x_74129;
            double defunc_1_op_res_74131 = defunc_9_fit_fun_res_74124 +
                   redout_74096;
            double defunc_1_op_res_74132 = defunc_9_slope_fun_res_74130 +
                   redout_74097;
            double redout_tmp_74147 = defunc_1_op_res_74131;
            double redout_tmp_74148 = defunc_1_op_res_74132;
            
            redout_74096 = redout_tmp_74147;
            redout_74097 = redout_tmp_74148;
        }
        defunc_2_reduce_res_73935 = redout_74096;
        defunc_2_reduce_res_73936 = redout_74097;
        ((double *) mem_70871.mem)[gtid_73787] = defunc_2_reduce_res_73935;
        ((double *) mem_70874.mem)[gtid_73787] = defunc_2_reduce_res_73936;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77215_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77215_end -
                 futhark_mc_segmap_parloop_77215_start;
        
        ctx->futhark_mc_segmap_parloop_77215_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77215_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77215_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77213(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73786 = tid;
    int num_tasks_74007 = info.nsubtasks;
    struct futhark_mc_task_77212 *futhark_mc_task_77212 =
                                 (struct futhark_mc_task_77212 *) args;
    struct futhark_context *ctx = futhark_mc_task_77212->ctx;
    uint64_t futhark_mc_segmap_task_77213_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77213_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77212->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77212->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77212->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77212->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77212->free_i_65392;
    bool x_65393 = futhark_mc_task_77212->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77212->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77212->free_loop_cond_65403;
    int64_t last_res_68015 = futhark_mc_task_77212->free_last_res_68015;
    int64_t min_arg_68034 = futhark_mc_task_77212->free_min_arg_68034;
    int64_t min_arg_68035 = futhark_mc_task_77212->free_min_arg_68035;
    int64_t min_res_68036 = futhark_mc_task_77212->free_min_res_68036;
    double max_res_68040 = futhark_mc_task_77212->free_max_res_68040;
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_task_77212->free_mem_70859, .size =
                                 0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_task_77212->free_mem_70862, .size =
                                 0, .references =NULL};
    struct memblock mem_70865 = {.desc ="mem_70865", .mem =
                                 futhark_mc_task_77212->free_mem_70865, .size =
                                 0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_task_77212->free_mem_70868, .size =
                                 0, .references =NULL};
    struct memblock mem_70871 = {.desc ="mem_70871", .mem =
                                 futhark_mc_task_77212->free_mem_70871, .size =
                                 0, .references =NULL};
    struct memblock mem_70874 = {.desc ="mem_70874", .mem =
                                 futhark_mc_task_77212->free_mem_70874, .size =
                                 0, .references =NULL};
    int64_t iter_74008;
    struct futhark_mc_segmap_parloop_struct_77214
    futhark_mc_segmap_parloop_struct_77214;
    
    futhark_mc_segmap_parloop_struct_77214.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77214.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77214.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77214.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77214.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77214.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77214.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77214.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77214.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77214.free_last_res_68015 = last_res_68015;
    futhark_mc_segmap_parloop_struct_77214.free_min_arg_68034 = min_arg_68034;
    futhark_mc_segmap_parloop_struct_77214.free_min_arg_68035 = min_arg_68035;
    futhark_mc_segmap_parloop_struct_77214.free_min_res_68036 = min_res_68036;
    futhark_mc_segmap_parloop_struct_77214.free_max_res_68040 = max_res_68040;
    futhark_mc_segmap_parloop_struct_77214.free_mem_70859 = mem_70859.mem;
    futhark_mc_segmap_parloop_struct_77214.free_mem_70862 = mem_70862.mem;
    futhark_mc_segmap_parloop_struct_77214.free_mem_70865 = mem_70865.mem;
    futhark_mc_segmap_parloop_struct_77214.free_mem_70868 = mem_70868.mem;
    futhark_mc_segmap_parloop_struct_77214.free_mem_70871 = mem_70871.mem;
    futhark_mc_segmap_parloop_struct_77214.free_mem_70874 = mem_70874.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77215_task;
    
    futhark_mc_segmap_parloop_77215_task.name =
        "futhark_mc_segmap_parloop_77215";
    futhark_mc_segmap_parloop_77215_task.fn = futhark_mc_segmap_parloop_77215;
    futhark_mc_segmap_parloop_77215_task.args =
        &futhark_mc_segmap_parloop_struct_77214;
    futhark_mc_segmap_parloop_77215_task.iterations = iterations;
    futhark_mc_segmap_parloop_77215_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77215_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77215_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77215_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77215_task);
    
    if (futhark_mc_segmap_parloop_77215_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77215_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77215_total_end -
                 futhark_mc_segmap_parloop_77215_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77215_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77215_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77215_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77213_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77213_end -
                 futhark_mc_segmap_task_77213_start;
        
        ctx->futhark_mc_segmap_task_77213_runs[tid]++;
        ctx->futhark_mc_segmap_task_77213_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77213_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77217 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_68015;
    int64_t free_min_arg_68034;
    int64_t free_min_arg_68035;
    int64_t free_min_res_68036;
    double free_max_res_68040;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70865;
    unsigned char *free_mem_70868;
    unsigned char *free_mem_70871;
    unsigned char *free_mem_70874;
};
struct futhark_mc_task_77219 {
    struct futhark_context *ctx;
    int64_t free_last_res_68015;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70868;
    int64_t free_min_res_73591;
    int64_t free_max_res_73656;
    double free_defunc_1_f_res_73675;
    double *retval_defunc_2_reduce_res_73676;
    double *retval_defunc_2_reduce_res_73677;
    double *retval_defunc_2_reduce_res_73678;
    double *retval_defunc_2_reduce_res_73679;
    double *retval_defunc_2_reduce_res_73680;
};
struct futhark_mc_segred_stage_1_parloop_struct_77226 {
    struct futhark_context *ctx;
    int64_t free_last_res_68015;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70868;
    int64_t free_min_res_73591;
    int64_t free_max_res_73656;
    double free_defunc_1_f_res_73675;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74293;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74295;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74297;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74299;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74301;
};
static int futhark_mc_segred_stage_1_parloop_77227(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_74205, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77226
    *futhark_mc_segred_stage_1_parloop_struct_77226 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77226 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77226->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77227_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77227_start = get_wall_time();
    
    int64_t last_res_68015 =
            futhark_mc_segred_stage_1_parloop_struct_77226->free_last_res_68015;
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77226->free_mem_70862,
                                 .size =0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77226->free_mem_70868,
                                 .size =0, .references =NULL};
    int64_t min_res_73591 =
            futhark_mc_segred_stage_1_parloop_struct_77226->free_min_res_73591;
    int64_t max_res_73656 =
            futhark_mc_segred_stage_1_parloop_struct_77226->free_max_res_73656;
    double defunc_1_f_res_73675 =
           futhark_mc_segred_stage_1_parloop_struct_77226->free_defunc_1_f_res_73675;
    struct memblock reduce_stage_1_tid_res_arr_mem_74293 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74293",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77226->free_reduce_stage_1_tid_res_arr_mem_74293,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_74295 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74295",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77226->free_reduce_stage_1_tid_res_arr_mem_74295,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_74297 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74297",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77226->free_reduce_stage_1_tid_res_arr_mem_74297,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_74299 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74299",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77226->free_reduce_stage_1_tid_res_arr_mem_74299,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_74301 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74301",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77226->free_reduce_stage_1_tid_res_arr_mem_74301,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74303 = start;
    double x_74207;
    double x_74208;
    double x_74210;
    double x_74211;
    double x_74213;
    double x_74214;
    double x_74216;
    double x_74217;
    double x_74219;
    double x_74220;
    double local_acc_74304 = 0.0;
    double local_acc_74305 = 0.0;
    double local_acc_74306 = 0.0;
    double local_acc_74307 = 0.0;
    double local_acc_74308 = 0.0;
    
    for (; iter_74303 < end; iter_74303++) {
        int64_t gtid_74206 = iter_74303;
        double x_74222;
        
        x_74222 = ((double *) mem_70868.mem)[gtid_74206];
        
        bool cond_74223 = sle64(last_res_68015, gtid_74206);
        int64_t defunc_0_f_res_74224;
        
        if (cond_74223) {
            defunc_0_f_res_74224 = (int64_t) 0;
        } else {
            int64_t i_74225 = add64(max_res_73656, gtid_74206);
            int64_t defunc_0_add_arg_74226;
            
            defunc_0_add_arg_74226 = ((int64_t *) mem_70862.mem)[i_74225];
            
            int64_t defunc_1_add_res_74227 = add64((int64_t) 1,
                                                   defunc_0_add_arg_74226);
            
            defunc_0_f_res_74224 = defunc_1_add_res_74227;
        }
        
        int64_t binop_p_74228 = sub64(defunc_0_f_res_74224, min_res_73591);
        double defunc_0_f_res_74229 = sitofp_i64_f64(binop_p_74228);
        double abs_res_74230 = fabs(defunc_0_f_res_74229);
        double tmp1_74231 = abs_res_74230 / defunc_1_f_res_73675;
        double x_74232 = tmp1_74231 * tmp1_74231;
        double y_74233 = tmp1_74231 * x_74232;
        double tmp2_74234 = 1.0 - y_74233;
        double x_74235 = tmp2_74234 * tmp2_74234;
        double tmp3_74236 = tmp2_74234 * x_74235;
        double w_j_74237 = x_74222 * tmp3_74236;
        double xw_j_74238 = defunc_0_f_res_74229 * w_j_74237;
        double x2w_j_74239 = defunc_0_f_res_74229 * xw_j_74238;
        double x3w_j_74240 = defunc_0_f_res_74229 * x2w_j_74239;
        double x4w_j_74241 = defunc_0_f_res_74229 * x3w_j_74240;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_74207 = local_acc_74304;
        }
        // Load next params
        {
            x_74208 = w_j_74237;
        }
        // Red body
        {
            double defunc_1_op_res_74209 = x_74207 + x_74208;
            
            local_acc_74304 = defunc_1_op_res_74209;
        }
        // Load accum params
        {
            x_74210 = local_acc_74305;
        }
        // Load next params
        {
            x_74211 = xw_j_74238;
        }
        // Red body
        {
            double defunc_1_op_res_74212 = x_74210 + x_74211;
            
            local_acc_74305 = defunc_1_op_res_74212;
        }
        // Load accum params
        {
            x_74213 = local_acc_74306;
        }
        // Load next params
        {
            x_74214 = x2w_j_74239;
        }
        // Red body
        {
            double defunc_1_op_res_74215 = x_74213 + x_74214;
            
            local_acc_74306 = defunc_1_op_res_74215;
        }
        // Load accum params
        {
            x_74216 = local_acc_74307;
        }
        // Load next params
        {
            x_74217 = x3w_j_74240;
        }
        // Red body
        {
            double defunc_1_op_res_74218 = x_74216 + x_74217;
            
            local_acc_74307 = defunc_1_op_res_74218;
        }
        // Load accum params
        {
            x_74219 = local_acc_74308;
        }
        // Load next params
        {
            x_74220 = x4w_j_74241;
        }
        // Red body
        {
            double defunc_1_op_res_74221 = x_74219 + x_74220;
            
            local_acc_74308 = defunc_1_op_res_74221;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_74293.mem)[flat_tid_74205] =
        local_acc_74304;
    ((double *) reduce_stage_1_tid_res_arr_mem_74295.mem)[flat_tid_74205] =
        local_acc_74305;
    ((double *) reduce_stage_1_tid_res_arr_mem_74297.mem)[flat_tid_74205] =
        local_acc_74306;
    ((double *) reduce_stage_1_tid_res_arr_mem_74299.mem)[flat_tid_74205] =
        local_acc_74307;
    ((double *) reduce_stage_1_tid_res_arr_mem_74301.mem)[flat_tid_74205] =
        local_acc_74308;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77227_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77227_end -
                 futhark_mc_segred_stage_1_parloop_77227_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77227_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77227_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77227_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77220(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74205 = tid;
    int num_tasks_74292 = info.nsubtasks;
    struct futhark_mc_task_77219 *futhark_mc_task_77219 =
                                 (struct futhark_mc_task_77219 *) args;
    struct futhark_context *ctx = futhark_mc_task_77219->ctx;
    uint64_t futhark_mc_segred_task_77220_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77220_start = get_wall_time();
    
    int64_t last_res_68015 = futhark_mc_task_77219->free_last_res_68015;
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_task_77219->free_mem_70862, .size =
                                 0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_task_77219->free_mem_70868, .size =
                                 0, .references =NULL};
    int64_t min_res_73591 = futhark_mc_task_77219->free_min_res_73591;
    int64_t max_res_73656 = futhark_mc_task_77219->free_max_res_73656;
    double defunc_1_f_res_73675 =
           futhark_mc_task_77219->free_defunc_1_f_res_73675;
    double defunc_2_reduce_res_73676 =
           *futhark_mc_task_77219->retval_defunc_2_reduce_res_73676;
    double defunc_2_reduce_res_73677 =
           *futhark_mc_task_77219->retval_defunc_2_reduce_res_73677;
    double defunc_2_reduce_res_73678 =
           *futhark_mc_task_77219->retval_defunc_2_reduce_res_73678;
    double defunc_2_reduce_res_73679 =
           *futhark_mc_task_77219->retval_defunc_2_reduce_res_73679;
    double defunc_2_reduce_res_73680 =
           *futhark_mc_task_77219->retval_defunc_2_reduce_res_73680;
    size_t reduce_stage_1_tid_res_arr_mem_74293_cached_sizze_77221 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74293 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_74295_cached_sizze_77222 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74295 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_74297_cached_sizze_77223 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74297 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_74299_cached_sizze_77224 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74299 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_74301_cached_sizze_77225 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74301 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_74293_cached_sizze_77221 <
        (size_t) ((int64_t) 8 * num_tasks_74292)) {
        reduce_stage_1_tid_res_arr_mem_74293 =
            realloc(reduce_stage_1_tid_res_arr_mem_74293, (int64_t) 8 *
                    num_tasks_74292);
        reduce_stage_1_tid_res_arr_mem_74293_cached_sizze_77221 = (int64_t) 8 *
            num_tasks_74292;
    }
    if (reduce_stage_1_tid_res_arr_mem_74295_cached_sizze_77222 <
        (size_t) ((int64_t) 8 * num_tasks_74292)) {
        reduce_stage_1_tid_res_arr_mem_74295 =
            realloc(reduce_stage_1_tid_res_arr_mem_74295, (int64_t) 8 *
                    num_tasks_74292);
        reduce_stage_1_tid_res_arr_mem_74295_cached_sizze_77222 = (int64_t) 8 *
            num_tasks_74292;
    }
    if (reduce_stage_1_tid_res_arr_mem_74297_cached_sizze_77223 <
        (size_t) ((int64_t) 8 * num_tasks_74292)) {
        reduce_stage_1_tid_res_arr_mem_74297 =
            realloc(reduce_stage_1_tid_res_arr_mem_74297, (int64_t) 8 *
                    num_tasks_74292);
        reduce_stage_1_tid_res_arr_mem_74297_cached_sizze_77223 = (int64_t) 8 *
            num_tasks_74292;
    }
    if (reduce_stage_1_tid_res_arr_mem_74299_cached_sizze_77224 <
        (size_t) ((int64_t) 8 * num_tasks_74292)) {
        reduce_stage_1_tid_res_arr_mem_74299 =
            realloc(reduce_stage_1_tid_res_arr_mem_74299, (int64_t) 8 *
                    num_tasks_74292);
        reduce_stage_1_tid_res_arr_mem_74299_cached_sizze_77224 = (int64_t) 8 *
            num_tasks_74292;
    }
    if (reduce_stage_1_tid_res_arr_mem_74301_cached_sizze_77225 <
        (size_t) ((int64_t) 8 * num_tasks_74292)) {
        reduce_stage_1_tid_res_arr_mem_74301 =
            realloc(reduce_stage_1_tid_res_arr_mem_74301, (int64_t) 8 *
                    num_tasks_74292);
        reduce_stage_1_tid_res_arr_mem_74301_cached_sizze_77225 = (int64_t) 8 *
            num_tasks_74292;
    }
    
    int64_t iter_74303;
    struct futhark_mc_segred_stage_1_parloop_struct_77226
    futhark_mc_segred_stage_1_parloop_struct_77226;
    
    futhark_mc_segred_stage_1_parloop_struct_77226.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_last_res_68015 =
        last_res_68015;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_mem_70862 =
        mem_70862.mem;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_mem_70868 =
        mem_70868.mem;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_min_res_73591 =
        min_res_73591;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_max_res_73656 =
        max_res_73656;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_defunc_1_f_res_73675 =
        defunc_1_f_res_73675;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_reduce_stage_1_tid_res_arr_mem_74293 =
        reduce_stage_1_tid_res_arr_mem_74293;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_reduce_stage_1_tid_res_arr_mem_74295 =
        reduce_stage_1_tid_res_arr_mem_74295;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_reduce_stage_1_tid_res_arr_mem_74297 =
        reduce_stage_1_tid_res_arr_mem_74297;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_reduce_stage_1_tid_res_arr_mem_74299 =
        reduce_stage_1_tid_res_arr_mem_74299;
    futhark_mc_segred_stage_1_parloop_struct_77226.free_reduce_stage_1_tid_res_arr_mem_74301 =
        reduce_stage_1_tid_res_arr_mem_74301;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77227_task;
    
    futhark_mc_segred_stage_1_parloop_77227_task.name =
        "futhark_mc_segred_stage_1_parloop_77227";
    futhark_mc_segred_stage_1_parloop_77227_task.fn =
        futhark_mc_segred_stage_1_parloop_77227;
    futhark_mc_segred_stage_1_parloop_77227_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77226;
    futhark_mc_segred_stage_1_parloop_77227_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77227_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77227_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77227_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77227_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77227_task);
    
    if (futhark_mc_segred_stage_1_parloop_77227_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77227_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77227_total_end -
                 futhark_mc_segred_stage_1_parloop_77227_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77227_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77227_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77227_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_73676 = 0.0;
        defunc_2_reduce_res_73677 = 0.0;
        defunc_2_reduce_res_73678 = 0.0;
        defunc_2_reduce_res_73679 = 0.0;
        defunc_2_reduce_res_73680 = 0.0;
    }
    
    double x_74309;
    double x_74310;
    double x_74312;
    double x_74313;
    double x_74315;
    double x_74316;
    double x_74318;
    double x_74319;
    double x_74321;
    double x_74322;
    
    for (int32_t i_74324 = 0; i_74324 < num_tasks_74292; i_74324++) {
        flat_tid_74205 = i_74324;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_74309 = defunc_2_reduce_res_73676;
            }
            // load next params
            {
                x_74310 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74293)[flat_tid_74205];
            }
            // red body
            {
                double defunc_1_op_res_74311 = x_74309 + x_74310;
                
                defunc_2_reduce_res_73676 = defunc_1_op_res_74311;
            }
            // load acc params
            {
                x_74312 = defunc_2_reduce_res_73677;
            }
            // load next params
            {
                x_74313 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74295)[flat_tid_74205];
            }
            // red body
            {
                double defunc_1_op_res_74314 = x_74312 + x_74313;
                
                defunc_2_reduce_res_73677 = defunc_1_op_res_74314;
            }
            // load acc params
            {
                x_74315 = defunc_2_reduce_res_73678;
            }
            // load next params
            {
                x_74316 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74297)[flat_tid_74205];
            }
            // red body
            {
                double defunc_1_op_res_74317 = x_74315 + x_74316;
                
                defunc_2_reduce_res_73678 = defunc_1_op_res_74317;
            }
            // load acc params
            {
                x_74318 = defunc_2_reduce_res_73679;
            }
            // load next params
            {
                x_74319 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74299)[flat_tid_74205];
            }
            // red body
            {
                double defunc_1_op_res_74320 = x_74318 + x_74319;
                
                defunc_2_reduce_res_73679 = defunc_1_op_res_74320;
            }
            // load acc params
            {
                x_74321 = defunc_2_reduce_res_73680;
            }
            // load next params
            {
                x_74322 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74301)[flat_tid_74205];
            }
            // red body
            {
                double defunc_1_op_res_74323 = x_74321 + x_74322;
                
                defunc_2_reduce_res_73680 = defunc_1_op_res_74323;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_74293);
        free(reduce_stage_1_tid_res_arr_mem_74295);
        free(reduce_stage_1_tid_res_arr_mem_74297);
        free(reduce_stage_1_tid_res_arr_mem_74299);
        free(reduce_stage_1_tid_res_arr_mem_74301);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77220_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77220_end -
                 futhark_mc_segred_task_77220_start;
        
        ctx->futhark_mc_segred_task_77220_runs[tid]++;
        ctx->futhark_mc_segred_task_77220_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77220_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77219->retval_defunc_2_reduce_res_73676 =
            defunc_2_reduce_res_73676;
        *futhark_mc_task_77219->retval_defunc_2_reduce_res_73677 =
            defunc_2_reduce_res_73677;
        *futhark_mc_task_77219->retval_defunc_2_reduce_res_73678 =
            defunc_2_reduce_res_73678;
        *futhark_mc_task_77219->retval_defunc_2_reduce_res_73679 =
            defunc_2_reduce_res_73679;
        *futhark_mc_task_77219->retval_defunc_2_reduce_res_73680 =
            defunc_2_reduce_res_73680;
    }
    return err;
}
struct futhark_mc_task_77228 {
    struct futhark_context *ctx;
    int64_t free_last_res_68015;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70868;
    int64_t free_min_res_73591;
    int64_t free_max_res_73656;
    double free_defunc_1_f_res_73675;
    double free_a12_73738;
    double free_b12_73739;
    double free_c12_73740;
    double free_b2_73741;
    double free_c2_73742;
    double *retval_defunc_2_reduce_res_73743;
    double *retval_defunc_2_reduce_res_73744;
};
struct futhark_mc_segred_stage_1_parloop_struct_77232 {
    struct futhark_context *ctx;
    int64_t free_last_res_68015;
    unsigned char *free_mem_70859;
    unsigned char *free_mem_70862;
    unsigned char *free_mem_70868;
    int64_t free_min_res_73591;
    int64_t free_max_res_73656;
    double free_defunc_1_f_res_73675;
    double free_a12_73738;
    double free_b12_73739;
    double free_c12_73740;
    double free_b2_73741;
    double free_c2_73742;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74326;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_74328;
};
static int futhark_mc_segred_stage_1_parloop_77233(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_74242, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77232
    *futhark_mc_segred_stage_1_parloop_struct_77232 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77232 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77232->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77233_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77233_start = get_wall_time();
    
    int64_t last_res_68015 =
            futhark_mc_segred_stage_1_parloop_struct_77232->free_last_res_68015;
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77232->free_mem_70859,
                                 .size =0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77232->free_mem_70862,
                                 .size =0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77232->free_mem_70868,
                                 .size =0, .references =NULL};
    int64_t min_res_73591 =
            futhark_mc_segred_stage_1_parloop_struct_77232->free_min_res_73591;
    int64_t max_res_73656 =
            futhark_mc_segred_stage_1_parloop_struct_77232->free_max_res_73656;
    double defunc_1_f_res_73675 =
           futhark_mc_segred_stage_1_parloop_struct_77232->free_defunc_1_f_res_73675;
    double a12_73738 =
           futhark_mc_segred_stage_1_parloop_struct_77232->free_a12_73738;
    double b12_73739 =
           futhark_mc_segred_stage_1_parloop_struct_77232->free_b12_73739;
    double c12_73740 =
           futhark_mc_segred_stage_1_parloop_struct_77232->free_c12_73740;
    double b2_73741 =
           futhark_mc_segred_stage_1_parloop_struct_77232->free_b2_73741;
    double c2_73742 =
           futhark_mc_segred_stage_1_parloop_struct_77232->free_c2_73742;
    struct memblock reduce_stage_1_tid_res_arr_mem_74326 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74326",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77232->free_reduce_stage_1_tid_res_arr_mem_74326,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_74328 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_74328",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77232->free_reduce_stage_1_tid_res_arr_mem_74328,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74330 = start;
    double x_74244;
    double x_74245;
    double x_74247;
    double x_74248;
    double local_acc_74331 = 0.0;
    double local_acc_74332 = 0.0;
    
    for (; iter_74330 < end; iter_74330++) {
        int64_t gtid_74243 = iter_74330;
        double x_74250;
        
        x_74250 = ((double *) mem_70868.mem)[gtid_74243];
        
        bool cond_74251 = sle64(last_res_68015, gtid_74243);
        int64_t defunc_0_f_res_74252;
        
        if (cond_74251) {
            defunc_0_f_res_74252 = (int64_t) 0;
        } else {
            int64_t i_74253 = add64(max_res_73656, gtid_74243);
            int64_t defunc_0_add_arg_74254;
            
            defunc_0_add_arg_74254 = ((int64_t *) mem_70862.mem)[i_74253];
            
            int64_t defunc_1_add_res_74255 = add64((int64_t) 1,
                                                   defunc_0_add_arg_74254);
            
            defunc_0_f_res_74252 = defunc_1_add_res_74255;
        }
        
        int64_t binop_p_74256 = sub64(defunc_0_f_res_74252, min_res_73591);
        double defunc_0_f_res_74257 = sitofp_i64_f64(binop_p_74256);
        double abs_res_74258 = fabs(defunc_0_f_res_74257);
        double tmp1_74259 = abs_res_74258 / defunc_1_f_res_73675;
        double x_74260 = tmp1_74259 * tmp1_74259;
        double y_74261 = tmp1_74259 * x_74260;
        double tmp2_74262 = 1.0 - y_74261;
        double x_74263 = tmp2_74262 * tmp2_74262;
        double tmp3_74264 = tmp2_74262 * x_74263;
        double tmp4_74265 = x_74250 * tmp3_74264;
        double defunc_1_f_res_74266 = defunc_0_f_res_74257 * tmp4_74265;
        double defunc_1_f_res_74267 = defunc_0_f_res_74257 *
               defunc_1_f_res_74266;
        double defunc_0_f_res_74268;
        
        if (cond_74251) {
            defunc_0_f_res_74268 = 0.0;
        } else {
            int64_t i_74269 = add64(max_res_73656, gtid_74243);
            double defunc_0_add_arg_74270;
            
            defunc_0_add_arg_74270 = ((double *) mem_70859.mem)[i_74269];
            defunc_0_f_res_74268 = defunc_0_add_arg_74270;
        }
        
        double x_74271 = a12_73738 * tmp4_74265;
        double y_74272 = b12_73739 * defunc_1_f_res_74266;
        double x_74273 = x_74271 + y_74272;
        double y_74274 = c12_73740 * defunc_1_f_res_74267;
        double x_74275 = x_74273 + y_74274;
        double defunc_9_fit_fun_res_74276 = defunc_0_f_res_74268 * x_74275;
        double x_74277 = b12_73739 * tmp4_74265;
        double y_74278 = b2_73741 * defunc_1_f_res_74266;
        double x_74279 = x_74277 + y_74278;
        double y_74280 = c2_73742 * defunc_1_f_res_74267;
        double x_74281 = x_74279 + y_74280;
        double defunc_9_slope_fun_res_74282 = defunc_0_f_res_74268 * x_74281;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_74244 = local_acc_74331;
        }
        // Load next params
        {
            x_74245 = defunc_9_fit_fun_res_74276;
        }
        // Red body
        {
            double defunc_1_op_res_74246 = x_74244 + x_74245;
            
            local_acc_74331 = defunc_1_op_res_74246;
        }
        // Load accum params
        {
            x_74247 = local_acc_74332;
        }
        // Load next params
        {
            x_74248 = defunc_9_slope_fun_res_74282;
        }
        // Red body
        {
            double defunc_1_op_res_74249 = x_74247 + x_74248;
            
            local_acc_74332 = defunc_1_op_res_74249;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_74326.mem)[flat_tid_74242] =
        local_acc_74331;
    ((double *) reduce_stage_1_tid_res_arr_mem_74328.mem)[flat_tid_74242] =
        local_acc_74332;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77233_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77233_end -
                 futhark_mc_segred_stage_1_parloop_77233_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77233_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77233_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77233_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77229(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74242 = tid;
    int num_tasks_74325 = info.nsubtasks;
    struct futhark_mc_task_77228 *futhark_mc_task_77228 =
                                 (struct futhark_mc_task_77228 *) args;
    struct futhark_context *ctx = futhark_mc_task_77228->ctx;
    uint64_t futhark_mc_segred_task_77229_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77229_start = get_wall_time();
    
    int64_t last_res_68015 = futhark_mc_task_77228->free_last_res_68015;
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_task_77228->free_mem_70859, .size =
                                 0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_task_77228->free_mem_70862, .size =
                                 0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_task_77228->free_mem_70868, .size =
                                 0, .references =NULL};
    int64_t min_res_73591 = futhark_mc_task_77228->free_min_res_73591;
    int64_t max_res_73656 = futhark_mc_task_77228->free_max_res_73656;
    double defunc_1_f_res_73675 =
           futhark_mc_task_77228->free_defunc_1_f_res_73675;
    double a12_73738 = futhark_mc_task_77228->free_a12_73738;
    double b12_73739 = futhark_mc_task_77228->free_b12_73739;
    double c12_73740 = futhark_mc_task_77228->free_c12_73740;
    double b2_73741 = futhark_mc_task_77228->free_b2_73741;
    double c2_73742 = futhark_mc_task_77228->free_c2_73742;
    double defunc_2_reduce_res_73743 =
           *futhark_mc_task_77228->retval_defunc_2_reduce_res_73743;
    double defunc_2_reduce_res_73744 =
           *futhark_mc_task_77228->retval_defunc_2_reduce_res_73744;
    size_t reduce_stage_1_tid_res_arr_mem_74326_cached_sizze_77230 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74326 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_74328_cached_sizze_77231 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_74328 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_74326_cached_sizze_77230 <
        (size_t) ((int64_t) 8 * num_tasks_74325)) {
        reduce_stage_1_tid_res_arr_mem_74326 =
            realloc(reduce_stage_1_tid_res_arr_mem_74326, (int64_t) 8 *
                    num_tasks_74325);
        reduce_stage_1_tid_res_arr_mem_74326_cached_sizze_77230 = (int64_t) 8 *
            num_tasks_74325;
    }
    if (reduce_stage_1_tid_res_arr_mem_74328_cached_sizze_77231 <
        (size_t) ((int64_t) 8 * num_tasks_74325)) {
        reduce_stage_1_tid_res_arr_mem_74328 =
            realloc(reduce_stage_1_tid_res_arr_mem_74328, (int64_t) 8 *
                    num_tasks_74325);
        reduce_stage_1_tid_res_arr_mem_74328_cached_sizze_77231 = (int64_t) 8 *
            num_tasks_74325;
    }
    
    int64_t iter_74330;
    struct futhark_mc_segred_stage_1_parloop_struct_77232
    futhark_mc_segred_stage_1_parloop_struct_77232;
    
    futhark_mc_segred_stage_1_parloop_struct_77232.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_last_res_68015 =
        last_res_68015;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_mem_70859 =
        mem_70859.mem;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_mem_70862 =
        mem_70862.mem;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_mem_70868 =
        mem_70868.mem;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_min_res_73591 =
        min_res_73591;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_max_res_73656 =
        max_res_73656;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_defunc_1_f_res_73675 =
        defunc_1_f_res_73675;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_a12_73738 = a12_73738;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_b12_73739 = b12_73739;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_c12_73740 = c12_73740;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_b2_73741 = b2_73741;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_c2_73742 = c2_73742;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_reduce_stage_1_tid_res_arr_mem_74326 =
        reduce_stage_1_tid_res_arr_mem_74326;
    futhark_mc_segred_stage_1_parloop_struct_77232.free_reduce_stage_1_tid_res_arr_mem_74328 =
        reduce_stage_1_tid_res_arr_mem_74328;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77233_task;
    
    futhark_mc_segred_stage_1_parloop_77233_task.name =
        "futhark_mc_segred_stage_1_parloop_77233";
    futhark_mc_segred_stage_1_parloop_77233_task.fn =
        futhark_mc_segred_stage_1_parloop_77233;
    futhark_mc_segred_stage_1_parloop_77233_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77232;
    futhark_mc_segred_stage_1_parloop_77233_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77233_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77233_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77233_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77233_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77233_task);
    
    if (futhark_mc_segred_stage_1_parloop_77233_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77233_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77233_total_end -
                 futhark_mc_segred_stage_1_parloop_77233_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77233_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77233_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77233_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_73743 = 0.0;
        defunc_2_reduce_res_73744 = 0.0;
    }
    
    double x_74333;
    double x_74334;
    double x_74336;
    double x_74337;
    
    for (int32_t i_74339 = 0; i_74339 < num_tasks_74325; i_74339++) {
        flat_tid_74242 = i_74339;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_74333 = defunc_2_reduce_res_73743;
            }
            // load next params
            {
                x_74334 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74326)[flat_tid_74242];
            }
            // red body
            {
                double defunc_1_op_res_74335 = x_74333 + x_74334;
                
                defunc_2_reduce_res_73743 = defunc_1_op_res_74335;
            }
            // load acc params
            {
                x_74336 = defunc_2_reduce_res_73744;
            }
            // load next params
            {
                x_74337 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_74328)[flat_tid_74242];
            }
            // red body
            {
                double defunc_1_op_res_74338 = x_74336 + x_74337;
                
                defunc_2_reduce_res_73744 = defunc_1_op_res_74338;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_74326);
        free(reduce_stage_1_tid_res_arr_mem_74328);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77229_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77229_end -
                 futhark_mc_segred_task_77229_start;
        
        ctx->futhark_mc_segred_task_77229_runs[tid]++;
        ctx->futhark_mc_segred_task_77229_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77229_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77228->retval_defunc_2_reduce_res_73743 =
            defunc_2_reduce_res_73743;
        *futhark_mc_task_77228->retval_defunc_2_reduce_res_73744 =
            defunc_2_reduce_res_73744;
    }
    return err;
}
static int futhark_mc_segmap_parloop_77218(void *args, int64_t start,
                                           int64_t end, int flat_tid_73588,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77217
    *futhark_mc_segmap_parloop_struct_77217 =
    (struct futhark_mc_segmap_parloop_struct_77217 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77217->ctx;
    uint64_t futhark_mc_segmap_parloop_77218_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77218_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77217->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77217->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77217->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77217->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77217->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77217->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77217->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77217->free_loop_cond_65403;
    int64_t last_res_68015 =
            futhark_mc_segmap_parloop_struct_77217->free_last_res_68015;
    int64_t min_arg_68034 =
            futhark_mc_segmap_parloop_struct_77217->free_min_arg_68034;
    int64_t min_arg_68035 =
            futhark_mc_segmap_parloop_struct_77217->free_min_arg_68035;
    int64_t min_res_68036 =
            futhark_mc_segmap_parloop_struct_77217->free_min_res_68036;
    double max_res_68040 =
           futhark_mc_segmap_parloop_struct_77217->free_max_res_68040;
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_segmap_parloop_struct_77217->free_mem_70859,
                                 .size =0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_segmap_parloop_struct_77217->free_mem_70862,
                                 .size =0, .references =NULL};
    struct memblock mem_70865 = {.desc ="mem_70865", .mem =
                                 futhark_mc_segmap_parloop_struct_77217->free_mem_70865,
                                 .size =0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_segmap_parloop_struct_77217->free_mem_70868,
                                 .size =0, .references =NULL};
    struct memblock mem_70871 = {.desc ="mem_70871", .mem =
                                 futhark_mc_segmap_parloop_struct_77217->free_mem_70871,
                                 .size =0, .references =NULL};
    struct memblock mem_70874 = {.desc ="mem_70874", .mem =
                                 futhark_mc_segmap_parloop_struct_77217->free_mem_70874,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74149 = start;
    
    for (; iter_74149 < end; iter_74149++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74283 = n_m_65386;
        int64_t gtid_73589 = iter_74149;
        int64_t remnant_74284 = iter_74149 - gtid_73589;
        int64_t min_arg_73590 = mul64(jump_65382, gtid_73589);
        int64_t min_res_73591 = smin64(i_65392, min_arg_73590);
        int64_t defunc_0_g_res_73592 = add64((int64_t) 1, min_res_73591);
        bool init_idx_73593;
        int64_t init_idx_73594;
        int64_t init_idx_73595;
        bool loop_while_74150;
        int64_t low_74151;
        int64_t high_74152;
        
        loop_while_74150 = x_65393;
        low_74151 = (int64_t) 0;
        high_74152 = i_65392;
        while (loop_while_74150) {
            int64_t x_74153 = add64(low_74151, high_74152);
            int64_t mid_74154 = sdiv64(x_74153, (int64_t) 2);
            bool x_74155 = sle64((int64_t) 0, mid_74154);
            bool y_74156 = slt64(mid_74154, n_65378);
            bool bounds_check_74157 = x_74155 && y_74156;
            bool index_certs_74158;
            
            if (!bounds_check_74157) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_74154,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_74159;
            
            mid_id_74159 = ((int64_t *) mem_70865.mem)[mid_74154];
            
            bool cond_74160 = slt64(mid_id_74159, (int64_t) 0);
            int64_t mid_idx_74161;
            
            if (cond_74160) {
                mid_idx_74161 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_74161 = mid_id_74159;
            }
            
            bool cond_74162 = sle64(defunc_0_g_res_73592, mid_idx_74161);
            int64_t loopres_74163;
            int64_t loopres_74164;
            
            if (cond_74162) {
                int64_t loopres_t_res_74165 = sub64(mid_74154, (int64_t) 1);
                
                loopres_74163 = low_74151;
                loopres_74164 = loopres_t_res_74165;
            } else {
                int64_t loopres_f_res_74166 = add64((int64_t) 1, mid_74154);
                
                loopres_74163 = loopres_f_res_74166;
                loopres_74164 = high_74152;
            }
            
            bool loop_cond_74167 = sle64(loopres_74163, loopres_74164);
            bool loop_while_tmp_74285 = loop_cond_74167;
            int64_t low_tmp_74286 = loopres_74163;
            int64_t high_tmp_74287 = loopres_74164;
            
            loop_while_74150 = loop_while_tmp_74285;
            low_74151 = low_tmp_74286;
            high_74152 = high_tmp_74287;
        }
        init_idx_73593 = loop_while_74150;
        init_idx_73594 = low_74151;
        init_idx_73595 = high_74152;
        
        bool idx_73614;
        int64_t idx_73615;
        int64_t idx_73616;
        int64_t idx_73617;
        bool loop_while_74168;
        int64_t l_idx_74169;
        int64_t r_idx_74170;
        int64_t span_74171;
        
        loop_while_74168 = loop_cond_65403;
        l_idx_74169 = init_idx_73594;
        r_idx_74170 = init_idx_73594;
        span_74171 = (int64_t) 1;
        while (loop_while_74168) {
            int64_t max_arg_74172 = sub64(l_idx_74169, (int64_t) 1);
            int64_t max_res_74173 = smax64((int64_t) 0, max_arg_74172);
            int64_t min_arg_74174 = add64((int64_t) 1, r_idx_74170);
            int64_t min_res_74175 = smin64(min_arg_68034, min_arg_74174);
            bool x_74176 = sle64((int64_t) 0, max_res_74173);
            bool y_74177 = slt64(max_res_74173, n_65378);
            bool bounds_check_74178 = x_74176 && y_74177;
            bool index_certs_74179;
            
            if (!bounds_check_74178) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_74173,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74180;
            
            x_74180 = ((int64_t *) mem_70865.mem)[max_res_74173];
            
            int64_t abs_arg_74181 = sub64(x_74180, defunc_0_g_res_73592);
            int64_t abs_res_74182 = abs64(abs_arg_74181);
            bool x_74183 = sle64((int64_t) 0, min_res_74175);
            bool y_74184 = slt64(min_res_74175, n_65378);
            bool bounds_check_74185 = x_74183 && y_74184;
            bool index_certs_74186;
            
            if (!bounds_check_74185) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_74175,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74187;
            
            x_74187 = ((int64_t *) mem_70865.mem)[min_res_74175];
            
            int64_t abs_arg_74188 = sub64(x_74187, defunc_0_g_res_73592);
            int64_t abs_res_74189 = abs64(abs_arg_74188);
            bool cond_74190 = max_res_74173 == l_idx_74169;
            int64_t loopres_74191;
            int64_t loopres_74192;
            int64_t loopres_74193;
            
            if (cond_74190) {
                loopres_74191 = l_idx_74169;
                loopres_74192 = r_idx_74170;
                loopres_74193 = min_res_65398;
            } else {
                bool cond_74194 = slt64(abs_res_74182, abs_res_74189);
                bool cond_f_res_74195 = min_res_74175 == r_idx_74170;
                bool x_74196 = !cond_74194;
                bool y_74197 = cond_f_res_74195 && x_74196;
                bool cond_74198 = cond_74194 || y_74197;
                int64_t loopres_f_res_74199;
                
                if (cond_74198) {
                    loopres_f_res_74199 = max_res_74173;
                } else {
                    loopres_f_res_74199 = l_idx_74169;
                }
                
                int64_t loopres_f_res_74200;
                
                if (cond_74198) {
                    loopres_f_res_74200 = r_idx_74170;
                } else {
                    loopres_f_res_74200 = min_res_74175;
                }
                
                int64_t loopres_f_res_74201;
                
                if (cond_74198) {
                    int64_t loopres_f_res_t_res_74202 = add64((int64_t) 1,
                                                              span_74171);
                    
                    loopres_f_res_74201 = loopres_f_res_t_res_74202;
                } else {
                    int64_t loopres_f_res_f_res_74203 = add64((int64_t) 1,
                                                              span_74171);
                    
                    loopres_f_res_74201 = loopres_f_res_f_res_74203;
                }
                loopres_74191 = loopres_f_res_74199;
                loopres_74192 = loopres_f_res_74200;
                loopres_74193 = loopres_f_res_74201;
            }
            
            bool loop_cond_74204 = slt64(loopres_74193, min_res_65398);
            bool loop_while_tmp_74288 = loop_cond_74204;
            int64_t l_idx_tmp_74289 = loopres_74191;
            int64_t r_idx_tmp_74290 = loopres_74192;
            int64_t span_tmp_74291 = loopres_74193;
            
            loop_while_74168 = loop_while_tmp_74288;
            l_idx_74169 = l_idx_tmp_74289;
            r_idx_74170 = r_idx_tmp_74290;
            span_74171 = span_tmp_74291;
        }
        idx_73614 = loop_while_74168;
        idx_73615 = l_idx_74169;
        idx_73616 = r_idx_74170;
        idx_73617 = span_74171;
        
        int64_t min_res_73655 = smin64(min_arg_68035, idx_73615);
        int64_t max_res_73656 = smax64((int64_t) 0, min_res_73655);
        int64_t x_73657 = add64(min_res_68036, max_res_73656);
        int64_t r_73658 = sub64(x_73657, (int64_t) 1);
        bool x_73659 = sle64((int64_t) 0, r_73658);
        bool y_73660 = slt64(r_73658, n_65378);
        bool bounds_check_73661 = x_73659 && y_73660;
        bool index_certs_73662;
        
        if (!bounds_check_73661) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_73658,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_73663;
        
        x_73663 = ((int64_t *) mem_70862.mem)[r_73658];
        
        int64_t abs_arg_73664 = sub64(x_73663, min_res_73591);
        int64_t abs_res_73665 = abs64(abs_arg_73664);
        bool x_73666 = sle64((int64_t) 0, max_res_73656);
        bool y_73667 = slt64(max_res_73656, n_65378);
        bool bounds_check_73668 = x_73666 && y_73667;
        bool index_certs_73669;
        
        if (!bounds_check_73668) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_73656,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_73670;
        
        x_73670 = ((int64_t *) mem_70862.mem)[max_res_73656];
        
        int64_t abs_arg_73671 = sub64(x_73670, min_res_73591);
        int64_t abs_res_73672 = abs64(abs_arg_73671);
        int64_t max_res_73673 = smax64(abs_res_73665, abs_res_73672);
        double defunc_0_f_res_73674 = sitofp_i64_f64(max_res_73673);
        double defunc_1_f_res_73675 = max_res_68040 + defunc_0_f_res_73674;
        double defunc_2_reduce_res_73676;
        double defunc_2_reduce_res_73677;
        double defunc_2_reduce_res_73678;
        double defunc_2_reduce_res_73679;
        double defunc_2_reduce_res_73680;
        int64_t flat_tid_74205 = (int64_t) 0;
        int32_t num_tasks_74292;
        
        defunc_2_reduce_res_73676 = 0.0;
        defunc_2_reduce_res_73677 = 0.0;
        defunc_2_reduce_res_73678 = 0.0;
        defunc_2_reduce_res_73679 = 0.0;
        defunc_2_reduce_res_73680 = 0.0;
        
        struct futhark_mc_task_77219 futhark_mc_task_77219;
        
        futhark_mc_task_77219.ctx = ctx;
        futhark_mc_task_77219.free_last_res_68015 = last_res_68015;
        futhark_mc_task_77219.free_mem_70862 = mem_70862.mem;
        futhark_mc_task_77219.free_mem_70868 = mem_70868.mem;
        futhark_mc_task_77219.free_min_res_73591 = min_res_73591;
        futhark_mc_task_77219.free_max_res_73656 = max_res_73656;
        futhark_mc_task_77219.free_defunc_1_f_res_73675 = defunc_1_f_res_73675;
        futhark_mc_task_77219.retval_defunc_2_reduce_res_73676 =
            &defunc_2_reduce_res_73676;
        futhark_mc_task_77219.retval_defunc_2_reduce_res_73677 =
            &defunc_2_reduce_res_73677;
        futhark_mc_task_77219.retval_defunc_2_reduce_res_73678 =
            &defunc_2_reduce_res_73678;
        futhark_mc_task_77219.retval_defunc_2_reduce_res_73679 =
            &defunc_2_reduce_res_73679;
        futhark_mc_task_77219.retval_defunc_2_reduce_res_73680 =
            &defunc_2_reduce_res_73680;
        
        struct scheduler_segop futhark_mc_task_77219_task;
        
        futhark_mc_task_77219_task.args = &futhark_mc_task_77219;
        futhark_mc_task_77219_task.top_level_fn = futhark_mc_segred_task_77220;
        futhark_mc_task_77219_task.name = "futhark_mc_segred_task_77220";
        futhark_mc_task_77219_task.iterations = q_65380;
        futhark_mc_task_77219_task.task_time =
            &ctx->futhark_mc_segred_task_77220_total_time;
        futhark_mc_task_77219_task.task_iter =
            &ctx->futhark_mc_segred_task_77220_total_iter;
        futhark_mc_task_77219_task.sched = STATIC;
        futhark_mc_task_77219_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77220_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77219_task);
        
        if (futhark_mc_segred_task_77220_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double x_73718 = defunc_2_reduce_res_73678 * defunc_2_reduce_res_73680;
        double y_73719 = defunc_2_reduce_res_73679 * defunc_2_reduce_res_73679;
        double a12_73720 = x_73718 - y_73719;
        double x_73721 = defunc_2_reduce_res_73678 * defunc_2_reduce_res_73679;
        double y_73722 = defunc_2_reduce_res_73677 * defunc_2_reduce_res_73680;
        double b12_73723 = x_73721 - y_73722;
        double x_73724 = defunc_2_reduce_res_73677 * defunc_2_reduce_res_73679;
        double y_73725 = defunc_2_reduce_res_73678 * defunc_2_reduce_res_73678;
        double c12_73726 = x_73724 - y_73725;
        double x_73727 = defunc_2_reduce_res_73676 * defunc_2_reduce_res_73680;
        double b2_73728 = x_73727 - y_73725;
        double x_73729 = defunc_2_reduce_res_73677 * defunc_2_reduce_res_73678;
        double y_73730 = defunc_2_reduce_res_73676 * defunc_2_reduce_res_73679;
        double c2_73731 = x_73729 - y_73730;
        double x_73732 = defunc_2_reduce_res_73676 * a12_73720;
        double y_73733 = defunc_2_reduce_res_73677 * b12_73723;
        double x_73734 = x_73732 + y_73733;
        double y_73735 = defunc_2_reduce_res_73678 * c12_73726;
        double y_73736 = x_73734 + y_73735;
        double det_73737 = 1.0 / y_73736;
        double a12_73738 = a12_73720 * det_73737;
        double b12_73739 = b12_73723 * det_73737;
        double c12_73740 = c12_73726 * det_73737;
        double b2_73741 = b2_73728 * det_73737;
        double c2_73742 = c2_73731 * det_73737;
        double defunc_2_reduce_res_73743;
        double defunc_2_reduce_res_73744;
        int64_t flat_tid_74242 = (int64_t) 0;
        int32_t num_tasks_74325;
        
        defunc_2_reduce_res_73743 = 0.0;
        defunc_2_reduce_res_73744 = 0.0;
        
        struct futhark_mc_task_77228 futhark_mc_task_77228;
        
        futhark_mc_task_77228.ctx = ctx;
        futhark_mc_task_77228.free_last_res_68015 = last_res_68015;
        futhark_mc_task_77228.free_mem_70859 = mem_70859.mem;
        futhark_mc_task_77228.free_mem_70862 = mem_70862.mem;
        futhark_mc_task_77228.free_mem_70868 = mem_70868.mem;
        futhark_mc_task_77228.free_min_res_73591 = min_res_73591;
        futhark_mc_task_77228.free_max_res_73656 = max_res_73656;
        futhark_mc_task_77228.free_defunc_1_f_res_73675 = defunc_1_f_res_73675;
        futhark_mc_task_77228.free_a12_73738 = a12_73738;
        futhark_mc_task_77228.free_b12_73739 = b12_73739;
        futhark_mc_task_77228.free_c12_73740 = c12_73740;
        futhark_mc_task_77228.free_b2_73741 = b2_73741;
        futhark_mc_task_77228.free_c2_73742 = c2_73742;
        futhark_mc_task_77228.retval_defunc_2_reduce_res_73743 =
            &defunc_2_reduce_res_73743;
        futhark_mc_task_77228.retval_defunc_2_reduce_res_73744 =
            &defunc_2_reduce_res_73744;
        
        struct scheduler_segop futhark_mc_task_77228_task;
        
        futhark_mc_task_77228_task.args = &futhark_mc_task_77228;
        futhark_mc_task_77228_task.top_level_fn = futhark_mc_segred_task_77229;
        futhark_mc_task_77228_task.name = "futhark_mc_segred_task_77229";
        futhark_mc_task_77228_task.iterations = q_65380;
        futhark_mc_task_77228_task.task_time =
            &ctx->futhark_mc_segred_task_77229_total_time;
        futhark_mc_task_77228_task.task_iter =
            &ctx->futhark_mc_segred_task_77229_total_iter;
        futhark_mc_task_77228_task.sched = STATIC;
        futhark_mc_task_77228_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77229_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77228_task);
        
        if (futhark_mc_segred_task_77229_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        ((double *) mem_70871.mem)[gtid_73589] = defunc_2_reduce_res_73743;
        ((double *) mem_70874.mem)[gtid_73589] = defunc_2_reduce_res_73744;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77218_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77218_end -
                 futhark_mc_segmap_parloop_77218_start;
        
        ctx->futhark_mc_segmap_parloop_77218_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77218_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77218_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77216(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_73588 = tid;
    int num_tasks_74007 = info.nsubtasks;
    struct futhark_mc_task_77212 *futhark_mc_task_77212 =
                                 (struct futhark_mc_task_77212 *) args;
    struct futhark_context *ctx = futhark_mc_task_77212->ctx;
    uint64_t futhark_mc_segmap_nested_task_77216_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77216_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77212->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77212->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77212->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77212->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77212->free_i_65392;
    bool x_65393 = futhark_mc_task_77212->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77212->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77212->free_loop_cond_65403;
    int64_t last_res_68015 = futhark_mc_task_77212->free_last_res_68015;
    int64_t min_arg_68034 = futhark_mc_task_77212->free_min_arg_68034;
    int64_t min_arg_68035 = futhark_mc_task_77212->free_min_arg_68035;
    int64_t min_res_68036 = futhark_mc_task_77212->free_min_res_68036;
    double max_res_68040 = futhark_mc_task_77212->free_max_res_68040;
    struct memblock mem_70859 = {.desc ="mem_70859", .mem =
                                 futhark_mc_task_77212->free_mem_70859, .size =
                                 0, .references =NULL};
    struct memblock mem_70862 = {.desc ="mem_70862", .mem =
                                 futhark_mc_task_77212->free_mem_70862, .size =
                                 0, .references =NULL};
    struct memblock mem_70865 = {.desc ="mem_70865", .mem =
                                 futhark_mc_task_77212->free_mem_70865, .size =
                                 0, .references =NULL};
    struct memblock mem_70868 = {.desc ="mem_70868", .mem =
                                 futhark_mc_task_77212->free_mem_70868, .size =
                                 0, .references =NULL};
    struct memblock mem_70871 = {.desc ="mem_70871", .mem =
                                 futhark_mc_task_77212->free_mem_70871, .size =
                                 0, .references =NULL};
    struct memblock mem_70874 = {.desc ="mem_70874", .mem =
                                 futhark_mc_task_77212->free_mem_70874, .size =
                                 0, .references =NULL};
    int64_t iter_74149;
    struct futhark_mc_segmap_parloop_struct_77217
    futhark_mc_segmap_parloop_struct_77217;
    
    futhark_mc_segmap_parloop_struct_77217.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77217.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77217.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77217.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77217.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77217.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77217.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77217.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77217.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77217.free_last_res_68015 = last_res_68015;
    futhark_mc_segmap_parloop_struct_77217.free_min_arg_68034 = min_arg_68034;
    futhark_mc_segmap_parloop_struct_77217.free_min_arg_68035 = min_arg_68035;
    futhark_mc_segmap_parloop_struct_77217.free_min_res_68036 = min_res_68036;
    futhark_mc_segmap_parloop_struct_77217.free_max_res_68040 = max_res_68040;
    futhark_mc_segmap_parloop_struct_77217.free_mem_70859 = mem_70859.mem;
    futhark_mc_segmap_parloop_struct_77217.free_mem_70862 = mem_70862.mem;
    futhark_mc_segmap_parloop_struct_77217.free_mem_70865 = mem_70865.mem;
    futhark_mc_segmap_parloop_struct_77217.free_mem_70868 = mem_70868.mem;
    futhark_mc_segmap_parloop_struct_77217.free_mem_70871 = mem_70871.mem;
    futhark_mc_segmap_parloop_struct_77217.free_mem_70874 = mem_70874.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77218_task;
    
    futhark_mc_segmap_parloop_77218_task.name =
        "futhark_mc_segmap_parloop_77218";
    futhark_mc_segmap_parloop_77218_task.fn = futhark_mc_segmap_parloop_77218;
    futhark_mc_segmap_parloop_77218_task.args =
        &futhark_mc_segmap_parloop_struct_77217;
    futhark_mc_segmap_parloop_77218_task.iterations = iterations;
    futhark_mc_segmap_parloop_77218_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77218_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77218_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77218_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77218_task);
    
    if (futhark_mc_segmap_parloop_77218_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77218_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77218_total_end -
                 futhark_mc_segmap_parloop_77218_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77218_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77218_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77218_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77216_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77216_end -
                 futhark_mc_segmap_nested_task_77216_start;
        
        ctx->futhark_mc_segmap_nested_task_77216_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77216_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77216_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77185(void *args, int64_t start,
                                           int64_t end, int flat_tid_68002,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77184
    *futhark_mc_segmap_parloop_struct_77184 =
    (struct futhark_mc_segmap_parloop_struct_77184 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77184->ctx;
    uint64_t futhark_mc_segmap_parloop_77185_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77185_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77184->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77184->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77184->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77184->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77184->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77184->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77184->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77184->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77184->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77184->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77184->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70855 =
            futhark_mc_segmap_parloop_struct_77184->free_bytes_70855;
    int64_t bytes_70867 =
            futhark_mc_segmap_parloop_struct_77184->free_bytes_70867;
    int64_t bytes_70870 =
            futhark_mc_segmap_parloop_struct_77184->free_bytes_70870;
    struct memblock mem_70983 = {.desc ="mem_70983", .mem =
                                 futhark_mc_segmap_parloop_struct_77184->free_mem_70983,
                                 .size =0, .references =NULL};
    struct memblock mem_70987 = {.desc ="mem_70987", .mem =
                                 futhark_mc_segmap_parloop_struct_77184->free_mem_70987,
                                 .size =0, .references =NULL};
    size_t mem_70856_cached_sizze_77186 = 0;
    unsigned char *mem_70856 = NULL;
    size_t mem_70859_cached_sizze_77187 = 0;
    unsigned char *mem_70859 = NULL;
    size_t mem_70862_cached_sizze_77188 = 0;
    unsigned char *mem_70862 = NULL;
    size_t mem_70865_cached_sizze_77189 = 0;
    unsigned char *mem_70865 = NULL;
    size_t mem_70868_cached_sizze_77190 = 0;
    unsigned char *mem_70868 = NULL;
    size_t mem_70871_cached_sizze_77191 = 0;
    unsigned char *mem_70871 = NULL;
    size_t mem_70874_cached_sizze_77192 = 0;
    unsigned char *mem_70874 = NULL;
    int64_t iterations = end - start;
    int64_t iter_73562 = start;
    
    if (mem_70856_cached_sizze_77186 < (size_t) bytes_70855) {
        mem_70856 = realloc(mem_70856, bytes_70855);
        mem_70856_cached_sizze_77186 = bytes_70855;
    }
    if (mem_70859_cached_sizze_77187 < (size_t) bytes_70855) {
        mem_70859 = realloc(mem_70859, bytes_70855);
        mem_70859_cached_sizze_77187 = bytes_70855;
    }
    if (mem_70862_cached_sizze_77188 < (size_t) bytes_70855) {
        mem_70862 = realloc(mem_70862, bytes_70855);
        mem_70862_cached_sizze_77188 = bytes_70855;
    }
    if (mem_70865_cached_sizze_77189 < (size_t) bytes_70855) {
        mem_70865 = realloc(mem_70865, bytes_70855);
        mem_70865_cached_sizze_77189 = bytes_70855;
    }
    if (mem_70868_cached_sizze_77190 < (size_t) bytes_70867) {
        mem_70868 = realloc(mem_70868, bytes_70867);
        mem_70868_cached_sizze_77190 = bytes_70867;
    }
    if (mem_70871_cached_sizze_77191 < (size_t) bytes_70870) {
        mem_70871 = realloc(mem_70871, bytes_70870);
        mem_70871_cached_sizze_77191 = bytes_70870;
    }
    if (mem_70874_cached_sizze_77192 < (size_t) bytes_70870) {
        mem_70874 = realloc(mem_70874, bytes_70870);
        mem_70874_cached_sizze_77192 = bytes_70870;
    }
    for (; iter_73562 < end; iter_73562++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_73975 = m_65377;
        int64_t gtid_68003 = iter_73562;
        int64_t remnant_73976 = iter_73562 - gtid_68003;
        int64_t flat_tid_73563 = (int64_t) 0;
        int32_t num_tasks_73977;
        
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmented segScan");
        
        struct futhark_mc_task_77193 futhark_mc_task_77193;
        
        futhark_mc_task_77193.ctx = ctx;
        futhark_mc_task_77193.free_n_65378 = n_65378;
        futhark_mc_task_77193.free_gtid_68003 = gtid_68003;
        futhark_mc_task_77193.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77193.free_mem_70856 = mem_70856;
        
        struct scheduler_segop futhark_mc_task_77193_task;
        
        futhark_mc_task_77193_task.args = &futhark_mc_task_77193;
        futhark_mc_task_77193_task.top_level_fn = futhark_mc_segscan_task_77194;
        futhark_mc_task_77193_task.name = "futhark_mc_segscan_task_77194";
        futhark_mc_task_77193_task.iterations = n_65378;
        futhark_mc_task_77193_task.task_time =
            &ctx->futhark_mc_segscan_task_77194_total_time;
        futhark_mc_task_77193_task.task_iter =
            &ctx->futhark_mc_segscan_task_77194_total_iter;
        futhark_mc_task_77193_task.sched = STATIC;
        futhark_mc_task_77193_task.nested_fn = NULL;
        
        int futhark_mc_segscan_task_77194_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77193_task);
        
        if (futhark_mc_segscan_task_77194_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t last_res_68015;
        
        last_res_68015 = ((int64_t *) mem_70856)[i_65392];
        for (int64_t i_73991 = 0; i_73991 < n_65378; i_73991++) {
            ((double *) mem_70859)[i_73991] = 0.0;
        }
        for (int64_t i_73992 = 0; i_73992 < n_65378; i_73992++) {
            ((int64_t *) mem_70862)[i_73992] = (int64_t) -1;
        }
        
        int64_t flat_tid_73572 = (int64_t) 0;
        int32_t num_tasks_73993;
        struct futhark_mc_task_77200 futhark_mc_task_77200;
        
        futhark_mc_task_77200.ctx = ctx;
        futhark_mc_task_77200.free_n_65378 = n_65378;
        futhark_mc_task_77200.free_gtid_68003 = gtid_68003;
        futhark_mc_task_77200.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77200.free_mem_70856 = mem_70856;
        futhark_mc_task_77200.free_mem_70859 = mem_70859;
        futhark_mc_task_77200.free_mem_70862 = mem_70862;
        
        struct scheduler_segop futhark_mc_task_77200_task;
        
        futhark_mc_task_77200_task.args = &futhark_mc_task_77200;
        futhark_mc_task_77200_task.top_level_fn = futhark_mc_segmap_task_77201;
        futhark_mc_task_77200_task.name = "futhark_mc_segmap_task_77201";
        futhark_mc_task_77200_task.iterations = n_65378;
        futhark_mc_task_77200_task.task_time =
            &ctx->futhark_mc_segmap_task_77201_total_time;
        futhark_mc_task_77200_task.task_iter =
            &ctx->futhark_mc_segmap_task_77201_total_iter;
        futhark_mc_task_77200_task.sched = STATIC;
        futhark_mc_task_77200_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77201_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77200_task);
        
        if (futhark_mc_segmap_task_77201_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_73580 = (int64_t) 0;
        int32_t num_tasks_73999;
        struct futhark_mc_task_77204 futhark_mc_task_77204;
        
        futhark_mc_task_77204.ctx = ctx;
        futhark_mc_task_77204.free_n_65378 = n_65378;
        futhark_mc_task_77204.free_mem_70862 = mem_70862;
        futhark_mc_task_77204.free_mem_70865 = mem_70865;
        
        struct scheduler_segop futhark_mc_task_77204_task;
        
        futhark_mc_task_77204_task.args = &futhark_mc_task_77204;
        futhark_mc_task_77204_task.top_level_fn = futhark_mc_segmap_task_77205;
        futhark_mc_task_77204_task.name = "futhark_mc_segmap_task_77205";
        futhark_mc_task_77204_task.iterations = n_65378;
        futhark_mc_task_77204_task.task_time =
            &ctx->futhark_mc_segmap_task_77205_total_time;
        futhark_mc_task_77204_task.task_iter =
            &ctx->futhark_mc_segmap_task_77205_total_iter;
        futhark_mc_task_77204_task.sched = STATIC;
        futhark_mc_task_77204_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77205_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77204_task);
        
        if (futhark_mc_segmap_task_77205_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t min_arg_68034 = sub64(last_res_68015, (int64_t) 1);
        int64_t min_arg_68035 = sub64(last_res_68015, min_res_65398);
        int64_t min_res_68036 = smin64(q_65380, last_res_68015);
        double i64_res_68037 = sitofp_i64_f64(last_res_68015);
        double x_68038 = i64_res_65404 - i64_res_68037;
        double max_arg_68039 = x_68038 / 2.0;
        double max_res_68040 = fmax64(0.0, max_arg_68039);
        int64_t flat_tid_73584 = (int64_t) 0;
        int32_t num_tasks_74003;
        struct futhark_mc_task_77208 futhark_mc_task_77208;
        
        futhark_mc_task_77208.ctx = ctx;
        futhark_mc_task_77208.free_q_65380 = q_65380;
        futhark_mc_task_77208.free_last_res_68015 = last_res_68015;
        futhark_mc_task_77208.free_mem_70868 = mem_70868;
        
        struct scheduler_segop futhark_mc_task_77208_task;
        
        futhark_mc_task_77208_task.args = &futhark_mc_task_77208;
        futhark_mc_task_77208_task.top_level_fn = futhark_mc_segmap_task_77209;
        futhark_mc_task_77208_task.name = "futhark_mc_segmap_task_77209";
        futhark_mc_task_77208_task.iterations = q_65380;
        futhark_mc_task_77208_task.task_time =
            &ctx->futhark_mc_segmap_task_77209_total_time;
        futhark_mc_task_77208_task.task_iter =
            &ctx->futhark_mc_segmap_task_77209_total_iter;
        futhark_mc_task_77208_task.sched = STATIC;
        futhark_mc_task_77208_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77209_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77208_task);
        
        if (futhark_mc_segmap_task_77209_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_73786 = (int64_t) 0;
        int32_t num_tasks_74007;
        int64_t flat_tid_73588 = (int64_t) 0;
        struct futhark_mc_task_77212 futhark_mc_task_77212;
        
        futhark_mc_task_77212.ctx = ctx;
        futhark_mc_task_77212.free_n_65378 = n_65378;
        futhark_mc_task_77212.free_q_65380 = q_65380;
        futhark_mc_task_77212.free_jump_65382 = jump_65382;
        futhark_mc_task_77212.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77212.free_i_65392 = i_65392;
        futhark_mc_task_77212.free_x_65393 = x_65393;
        futhark_mc_task_77212.free_min_res_65398 = min_res_65398;
        futhark_mc_task_77212.free_loop_cond_65403 = loop_cond_65403;
        futhark_mc_task_77212.free_last_res_68015 = last_res_68015;
        futhark_mc_task_77212.free_min_arg_68034 = min_arg_68034;
        futhark_mc_task_77212.free_min_arg_68035 = min_arg_68035;
        futhark_mc_task_77212.free_min_res_68036 = min_res_68036;
        futhark_mc_task_77212.free_max_res_68040 = max_res_68040;
        futhark_mc_task_77212.free_mem_70859 = mem_70859;
        futhark_mc_task_77212.free_mem_70862 = mem_70862;
        futhark_mc_task_77212.free_mem_70865 = mem_70865;
        futhark_mc_task_77212.free_mem_70868 = mem_70868;
        futhark_mc_task_77212.free_mem_70871 = mem_70871;
        futhark_mc_task_77212.free_mem_70874 = mem_70874;
        
        struct scheduler_segop futhark_mc_task_77212_task;
        
        futhark_mc_task_77212_task.args = &futhark_mc_task_77212;
        futhark_mc_task_77212_task.top_level_fn = futhark_mc_segmap_task_77213;
        futhark_mc_task_77212_task.name = "futhark_mc_segmap_task_77213";
        futhark_mc_task_77212_task.iterations = n_m_65386;
        futhark_mc_task_77212_task.task_time =
            &ctx->futhark_mc_segmap_task_77213_total_time;
        futhark_mc_task_77212_task.task_iter =
            &ctx->futhark_mc_segmap_task_77213_total_iter;
        futhark_mc_task_77212_task.sched = DYNAMIC;
        futhark_mc_task_77212_task.nested_fn =
            futhark_mc_segmap_nested_task_77216;
        
        int futhark_mc_segmap_task_77213_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77212_task);
        
        if (futhark_mc_segmap_task_77213_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70983.mem + gtid_68003 * n_m_65386 * (int64_t) 8,
                    mem_70871 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_70987.mem + gtid_68003 * n_m_65386 * (int64_t) 8,
                    mem_70874 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70856);
    free(mem_70859);
    free(mem_70862);
    free(mem_70865);
    free(mem_70868);
    free(mem_70871);
    free(mem_70874);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77185_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77185_end -
                 futhark_mc_segmap_parloop_77185_start;
        
        ctx->futhark_mc_segmap_parloop_77185_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77185_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77185_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77183(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_68002 = tid;
    int num_tasks_73311 = info.nsubtasks;
    struct futhark_mc_task_77172 *futhark_mc_task_77172 =
                                 (struct futhark_mc_task_77172 *) args;
    struct futhark_context *ctx = futhark_mc_task_77172->ctx;
    uint64_t futhark_mc_segmap_nested_task_77183_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77183_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77172->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77172->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77172->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77172->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77172->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77172->free_i_65392;
    bool x_65393 = futhark_mc_task_77172->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77172->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77172->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77172->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77172->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70855 = futhark_mc_task_77172->free_bytes_70855;
    int64_t bytes_70867 = futhark_mc_task_77172->free_bytes_70867;
    int64_t bytes_70870 = futhark_mc_task_77172->free_bytes_70870;
    struct memblock mem_70983 = {.desc ="mem_70983", .mem =
                                 futhark_mc_task_77172->free_mem_70983, .size =
                                 0, .references =NULL};
    struct memblock mem_70987 = {.desc ="mem_70987", .mem =
                                 futhark_mc_task_77172->free_mem_70987, .size =
                                 0, .references =NULL};
    int64_t iter_73562;
    struct futhark_mc_segmap_parloop_struct_77184
    futhark_mc_segmap_parloop_struct_77184;
    
    futhark_mc_segmap_parloop_struct_77184.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77184.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77184.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77184.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77184.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77184.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77184.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77184.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77184.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77184.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77184.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77184.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77184.free_bytes_70855 = bytes_70855;
    futhark_mc_segmap_parloop_struct_77184.free_bytes_70867 = bytes_70867;
    futhark_mc_segmap_parloop_struct_77184.free_bytes_70870 = bytes_70870;
    futhark_mc_segmap_parloop_struct_77184.free_mem_70983 = mem_70983.mem;
    futhark_mc_segmap_parloop_struct_77184.free_mem_70987 = mem_70987.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77185_task;
    
    futhark_mc_segmap_parloop_77185_task.name =
        "futhark_mc_segmap_parloop_77185";
    futhark_mc_segmap_parloop_77185_task.fn = futhark_mc_segmap_parloop_77185;
    futhark_mc_segmap_parloop_77185_task.args =
        &futhark_mc_segmap_parloop_struct_77184;
    futhark_mc_segmap_parloop_77185_task.iterations = iterations;
    futhark_mc_segmap_parloop_77185_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77185_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77185_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77185_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77185_task);
    
    if (futhark_mc_segmap_parloop_77185_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77185_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77185_total_end -
                 futhark_mc_segmap_parloop_77185_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77185_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77185_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77185_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77183_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77183_end -
                 futhark_mc_segmap_nested_task_77183_start;
        
        ctx->futhark_mc_segmap_nested_task_77183_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77183_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77183_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77234 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70997;
    int64_t free_bytes_71009;
    int64_t free_bytes_71030;
    unsigned char *free_mem_71140;
};
struct futhark_mc_segmap_parloop_struct_77236 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70997;
    int64_t free_bytes_71009;
    int64_t free_bytes_71030;
    unsigned char *free_mem_71140;
};
static int futhark_mc_segmap_parloop_77237(void *args, int64_t start,
                                           int64_t end, int flat_tid_68447,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77236
    *futhark_mc_segmap_parloop_struct_77236 =
    (struct futhark_mc_segmap_parloop_struct_77236 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77236->ctx;
    uint64_t futhark_mc_segmap_parloop_77237_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77237_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77236->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77236->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77236->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77236->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77236->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77236->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77236->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77236->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77236->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77236->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77236->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70997 =
            futhark_mc_segmap_parloop_struct_77236->free_bytes_70997;
    int64_t bytes_71009 =
            futhark_mc_segmap_parloop_struct_77236->free_bytes_71009;
    int64_t bytes_71030 =
            futhark_mc_segmap_parloop_struct_77236->free_bytes_71030;
    struct memblock mem_71140 = {.desc ="mem_71140", .mem =
                                 futhark_mc_segmap_parloop_struct_77236->free_mem_71140,
                                 .size =0, .references =NULL};
    size_t mem_71034_cached_sizze_77238 = 0;
    unsigned char *mem_71034 = NULL;
    size_t mem_71049_cached_sizze_77239 = 0;
    unsigned char *mem_71049 = NULL;
    size_t mem_71052_cached_sizze_77240 = 0;
    unsigned char *mem_71052 = NULL;
    size_t mem_71079_cached_sizze_77241 = 0;
    unsigned char *mem_71079 = NULL;
    size_t mem_71094_cached_sizze_77242 = 0;
    unsigned char *mem_71094 = NULL;
    size_t mem_71109_cached_sizze_77243 = 0;
    unsigned char *mem_71109 = NULL;
    size_t mem_71119_cached_sizze_77244 = 0;
    unsigned char *mem_71119 = NULL;
    int64_t iterations = end - start;
    int64_t iter_74343 = start;
    
    if (mem_71034_cached_sizze_77238 < (size_t) bytes_70997) {
        mem_71034 = realloc(mem_71034, bytes_70997);
        mem_71034_cached_sizze_77238 = bytes_70997;
    }
    if (mem_71049_cached_sizze_77239 < (size_t) bytes_70997) {
        mem_71049 = realloc(mem_71049, bytes_70997);
        mem_71049_cached_sizze_77239 = bytes_70997;
    }
    if (mem_71052_cached_sizze_77240 < (size_t) bytes_70997) {
        mem_71052 = realloc(mem_71052, bytes_70997);
        mem_71052_cached_sizze_77240 = bytes_70997;
    }
    if (mem_71079_cached_sizze_77241 < (size_t) bytes_70997) {
        mem_71079 = realloc(mem_71079, bytes_70997);
        mem_71079_cached_sizze_77241 = bytes_70997;
    }
    if (mem_71094_cached_sizze_77242 < (size_t) bytes_71009) {
        mem_71094 = realloc(mem_71094, bytes_71009);
        mem_71094_cached_sizze_77242 = bytes_71009;
    }
    if (mem_71109_cached_sizze_77243 < (size_t) bytes_71030) {
        mem_71109 = realloc(mem_71109, bytes_71030);
        mem_71109_cached_sizze_77243 = bytes_71030;
    }
    if (mem_71119_cached_sizze_77244 < (size_t) bytes_71009) {
        mem_71119 = realloc(mem_71119, bytes_71009);
        mem_71119_cached_sizze_77244 = bytes_71009;
    }
    for (; iter_74343 < end; iter_74343++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74500 = m_65377;
        int64_t gtid_68448 = iter_74343;
        int64_t remnant_74501 = iter_74343 - gtid_68448;
        int64_t discard_70345;
        int64_t scanacc_74345 = (int64_t) 0;
        
        for (int64_t i_74344 = 0; i_74344 < n_65378; i_74344++) {
            double x_74347;
            
            x_74347 = ((double *) Y_mem_70603.mem)[gtid_68448 * n_65378 +
                                                   i_74344];
            
            bool isnan_res_74348;
            
            isnan_res_74348 = futrts_isnan64(x_74347);
            
            bool defunc_0_p_res_74349 = !isnan_res_74348;
            int64_t defunc_0_f_res_74350 = btoi_bool_i64(defunc_0_p_res_74349);
            int64_t defunc_1_op_res_74351 = add64(defunc_0_f_res_74350,
                                                  scanacc_74345);
            
            ((int64_t *) mem_71034)[i_74344] = defunc_1_op_res_74351;
            
            int64_t scanacc_tmp_74502 = defunc_1_op_res_74351;
            
            scanacc_74345 = scanacc_tmp_74502;
        }
        discard_70345 = scanacc_74345;
        
        int64_t last_res_66051;
        
        last_res_66051 = ((int64_t *) mem_71034)[i_65392];
        for (int64_t i_74504 = 0; i_74504 < n_65378; i_74504++) {
            ((double *) mem_71049)[i_74504] = 0.0;
        }
        for (int64_t i_74505 = 0; i_74505 < n_65378; i_74505++) {
            ((int64_t *) mem_71052)[i_74505] = (int64_t) -1;
        }
        for (int64_t write_iter_74353 = 0; write_iter_74353 < n_65378;
             write_iter_74353++) {
            double write_iv_74356;
            
            write_iv_74356 = ((double *) Y_mem_70603.mem)[gtid_68448 * n_65378 +
                                                          write_iter_74353];
            
            bool isnan_res_74357;
            
            isnan_res_74357 = futrts_isnan64(write_iv_74356);
            
            bool defunc_0_p_res_74358 = !isnan_res_74357;
            int64_t defunc_1_f_res_74359;
            
            if (defunc_0_p_res_74358) {
                int64_t write_iv_74360;
                
                write_iv_74360 = ((int64_t *) mem_71034)[write_iter_74353];
                
                int64_t defunc_1_f_res_t_res_74361 = sub64(write_iv_74360,
                                                           (int64_t) 1);
                
                defunc_1_f_res_74359 = defunc_1_f_res_t_res_74361;
            } else {
                defunc_1_f_res_74359 = (int64_t) -1;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_74359) &&
                slt64(defunc_1_f_res_74359, n_65378)) {
                ((int64_t *) mem_71052)[defunc_1_f_res_74359] =
                    write_iter_74353;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_74359) &&
                slt64(defunc_1_f_res_74359, n_65378)) {
                if ((int64_t) 8 > 0)
                    memmove(mem_71049 + defunc_1_f_res_74359 * (int64_t) 8,
                            Y_mem_70603.mem + (gtid_68448 * n_65378 +
                                               write_iter_74353) * (int64_t) 8,
                            (int64_t) 8);
            }
        }
        for (int64_t i_74365 = 0; i_74365 < n_65378; i_74365++) {
            int64_t x_74367;
            
            x_74367 = ((int64_t *) mem_71052)[i_74365];
            
            int64_t defunc_0_f_res_74368 = add64((int64_t) 1, x_74367);
            
            ((int64_t *) mem_71079)[i_74365] = defunc_0_f_res_74368;
        }
        
        int64_t min_arg_66066 = sub64(last_res_66051, (int64_t) 1);
        int64_t min_arg_66067 = sub64(last_res_66051, min_res_65398);
        int64_t min_res_66068 = smin64(q_65380, last_res_66051);
        double i64_res_66069 = sitofp_i64_f64(last_res_66051);
        double x_66070 = i64_res_65404 - i64_res_66069;
        double max_arg_66071 = x_66070 / 2.0;
        double max_res_66072 = fmax64(0.0, max_arg_66071);
        
        for (int64_t i_74370 = 0; i_74370 < q_65380; i_74370++) {
            bool cond_74372 = sle64(last_res_66051, i_74370);
            double defunc_0_f_res_74373;
            
            if (cond_74372) {
                defunc_0_f_res_74373 = 0.0;
            } else {
                defunc_0_f_res_74373 = 1.0;
            }
            ((double *) mem_71094)[i_74370] = defunc_0_f_res_74373;
        }
        for (int64_t i_74375 = 0; i_74375 < n_m_65386; i_74375++) {
            int64_t min_arg_74377 = mul64(jump_65382, i_74375);
            int64_t min_res_74378 = smin64(i_65392, min_arg_74377);
            int64_t defunc_0_g_res_74379 = add64((int64_t) 1, min_res_74378);
            bool init_idx_74380;
            int64_t init_idx_74381;
            int64_t init_idx_74382;
            bool loop_while_74383;
            int64_t low_74384;
            int64_t high_74385;
            
            loop_while_74383 = x_65393;
            low_74384 = (int64_t) 0;
            high_74385 = i_65392;
            while (loop_while_74383) {
                int64_t x_74386 = add64(low_74384, high_74385);
                int64_t mid_74387 = sdiv64(x_74386, (int64_t) 2);
                bool x_74388 = sle64((int64_t) 0, mid_74387);
                bool y_74389 = slt64(mid_74387, n_65378);
                bool bounds_check_74390 = x_74388 && y_74389;
                bool index_certs_74391;
                
                if (!bounds_check_74390) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) mid_74387,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t mid_id_74392;
                
                mid_id_74392 = ((int64_t *) mem_71079)[mid_74387];
                
                bool cond_74393 = slt64(mid_id_74392, (int64_t) 0);
                int64_t mid_idx_74394;
                
                if (cond_74393) {
                    mid_idx_74394 = (int64_t) 9223372036854775807;
                } else {
                    mid_idx_74394 = mid_id_74392;
                }
                
                bool cond_74395 = sle64(defunc_0_g_res_74379, mid_idx_74394);
                int64_t loopres_74396;
                int64_t loopres_74397;
                
                if (cond_74395) {
                    int64_t loopres_t_res_74398 = sub64(mid_74387, (int64_t) 1);
                    
                    loopres_74396 = low_74384;
                    loopres_74397 = loopres_t_res_74398;
                } else {
                    int64_t loopres_f_res_74399 = add64((int64_t) 1, mid_74387);
                    
                    loopres_74396 = loopres_f_res_74399;
                    loopres_74397 = high_74385;
                }
                
                bool loop_cond_74400 = sle64(loopres_74396, loopres_74397);
                bool loop_while_tmp_74511 = loop_cond_74400;
                int64_t low_tmp_74512 = loopres_74396;
                int64_t high_tmp_74513 = loopres_74397;
                
                loop_while_74383 = loop_while_tmp_74511;
                low_74384 = low_tmp_74512;
                high_74385 = high_tmp_74513;
            }
            init_idx_74380 = loop_while_74383;
            init_idx_74381 = low_74384;
            init_idx_74382 = high_74385;
            
            bool idx_74401;
            int64_t idx_74402;
            int64_t idx_74403;
            int64_t idx_74404;
            bool loop_while_74405;
            int64_t l_idx_74406;
            int64_t r_idx_74407;
            int64_t span_74408;
            
            loop_while_74405 = loop_cond_65403;
            l_idx_74406 = init_idx_74381;
            r_idx_74407 = init_idx_74381;
            span_74408 = (int64_t) 1;
            while (loop_while_74405) {
                int64_t max_arg_74409 = sub64(l_idx_74406, (int64_t) 1);
                int64_t max_res_74410 = smax64((int64_t) 0, max_arg_74409);
                int64_t min_arg_74411 = add64((int64_t) 1, r_idx_74407);
                int64_t min_res_74412 = smin64(min_arg_66066, min_arg_74411);
                bool x_74413 = sle64((int64_t) 0, max_res_74410);
                bool y_74414 = slt64(max_res_74410, n_65378);
                bool bounds_check_74415 = x_74413 && y_74414;
                bool index_certs_74416;
                
                if (!bounds_check_74415) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) max_res_74410,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_74417;
                
                x_74417 = ((int64_t *) mem_71079)[max_res_74410];
                
                int64_t abs_arg_74418 = sub64(x_74417, defunc_0_g_res_74379);
                int64_t abs_res_74419 = abs64(abs_arg_74418);
                bool x_74420 = sle64((int64_t) 0, min_res_74412);
                bool y_74421 = slt64(min_res_74412, n_65378);
                bool bounds_check_74422 = x_74420 && y_74421;
                bool index_certs_74423;
                
                if (!bounds_check_74422) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) min_res_74412,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_74424;
                
                x_74424 = ((int64_t *) mem_71079)[min_res_74412];
                
                int64_t abs_arg_74425 = sub64(x_74424, defunc_0_g_res_74379);
                int64_t abs_res_74426 = abs64(abs_arg_74425);
                bool cond_74427 = max_res_74410 == l_idx_74406;
                int64_t loopres_74428;
                int64_t loopres_74429;
                int64_t loopres_74430;
                
                if (cond_74427) {
                    loopres_74428 = l_idx_74406;
                    loopres_74429 = r_idx_74407;
                    loopres_74430 = min_res_65398;
                } else {
                    bool cond_74431 = slt64(abs_res_74419, abs_res_74426);
                    bool cond_f_res_74432 = min_res_74412 == r_idx_74407;
                    bool x_74433 = !cond_74431;
                    bool y_74434 = cond_f_res_74432 && x_74433;
                    bool cond_74435 = cond_74431 || y_74434;
                    int64_t loopres_f_res_74436;
                    
                    if (cond_74435) {
                        loopres_f_res_74436 = max_res_74410;
                    } else {
                        loopres_f_res_74436 = l_idx_74406;
                    }
                    
                    int64_t loopres_f_res_74437;
                    
                    if (cond_74435) {
                        loopres_f_res_74437 = r_idx_74407;
                    } else {
                        loopres_f_res_74437 = min_res_74412;
                    }
                    
                    int64_t loopres_f_res_74438;
                    
                    if (cond_74435) {
                        int64_t loopres_f_res_t_res_74439 = add64((int64_t) 1,
                                                                  span_74408);
                        
                        loopres_f_res_74438 = loopres_f_res_t_res_74439;
                    } else {
                        int64_t loopres_f_res_f_res_74440 = add64((int64_t) 1,
                                                                  span_74408);
                        
                        loopres_f_res_74438 = loopres_f_res_f_res_74440;
                    }
                    loopres_74428 = loopres_f_res_74436;
                    loopres_74429 = loopres_f_res_74437;
                    loopres_74430 = loopres_f_res_74438;
                }
                
                bool loop_cond_74441 = slt64(loopres_74430, min_res_65398);
                bool loop_while_tmp_74514 = loop_cond_74441;
                int64_t l_idx_tmp_74515 = loopres_74428;
                int64_t r_idx_tmp_74516 = loopres_74429;
                int64_t span_tmp_74517 = loopres_74430;
                
                loop_while_74405 = loop_while_tmp_74514;
                l_idx_74406 = l_idx_tmp_74515;
                r_idx_74407 = r_idx_tmp_74516;
                span_74408 = span_tmp_74517;
            }
            idx_74401 = loop_while_74405;
            idx_74402 = l_idx_74406;
            idx_74403 = r_idx_74407;
            idx_74404 = span_74408;
            
            int64_t min_res_74442 = smin64(min_arg_66067, idx_74402);
            int64_t max_res_74443 = smax64((int64_t) 0, min_res_74442);
            int64_t x_74444 = add64(min_res_66068, max_res_74443);
            int64_t r_74445 = sub64(x_74444, (int64_t) 1);
            bool x_74446 = sle64((int64_t) 0, r_74445);
            bool y_74447 = slt64(r_74445, n_65378);
            bool bounds_check_74448 = x_74446 && y_74447;
            bool index_certs_74449;
            
            if (!bounds_check_74448) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) r_74445,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74450;
            
            x_74450 = ((int64_t *) mem_71052)[r_74445];
            
            int64_t abs_arg_74451 = sub64(x_74450, min_res_74378);
            int64_t abs_res_74452 = abs64(abs_arg_74451);
            bool x_74453 = sle64((int64_t) 0, max_res_74443);
            bool y_74454 = slt64(max_res_74443, n_65378);
            bool bounds_check_74455 = x_74453 && y_74454;
            bool index_certs_74456;
            
            if (!bounds_check_74455) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_74443,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74457;
            
            x_74457 = ((int64_t *) mem_71052)[max_res_74443];
            
            int64_t abs_arg_74458 = sub64(x_74457, min_res_74378);
            int64_t abs_res_74459 = abs64(abs_arg_74458);
            int64_t max_res_74460 = smax64(abs_res_74452, abs_res_74459);
            double defunc_0_f_res_74461 = sitofp_i64_f64(max_res_74460);
            double defunc_1_f_res_74462 = max_res_66072 + defunc_0_f_res_74461;
            double defunc_2_reduce_res_74464;
            double redout_74467 = 0.0;
            
            for (int64_t i_74466 = 0; i_74466 < q_65380; i_74466++) {
                double x_74469;
                
                x_74469 = ((double *) mem_71094)[i_74466];
                
                bool cond_74470 = sle64(last_res_66051, i_74466);
                int64_t defunc_0_f_res_74471;
                
                if (cond_74470) {
                    defunc_0_f_res_74471 = (int64_t) 0;
                } else {
                    int64_t i_74472 = add64(max_res_74443, i_74466);
                    int64_t defunc_0_add_arg_74473;
                    
                    defunc_0_add_arg_74473 = ((int64_t *) mem_71052)[i_74472];
                    
                    int64_t defunc_1_add_res_74474 = add64((int64_t) 1,
                                                           defunc_0_add_arg_74473);
                    
                    defunc_0_f_res_74471 = defunc_1_add_res_74474;
                }
                
                int64_t binop_p_74475 = sub64(defunc_0_f_res_74471,
                                              min_res_74378);
                double defunc_0_f_res_74476 = sitofp_i64_f64(binop_p_74475);
                double abs_res_74477 = fabs(defunc_0_f_res_74476);
                double tmp1_74478 = abs_res_74477 / defunc_1_f_res_74462;
                double x_74479 = tmp1_74478 * tmp1_74478;
                double y_74480 = tmp1_74478 * x_74479;
                double tmp2_74481 = 1.0 - y_74480;
                double x_74482 = tmp2_74481 * tmp2_74481;
                double tmp3_74483 = tmp2_74481 * x_74482;
                double tmp4_74484 = x_74469 * tmp3_74483;
                double defunc_1_op_res_74485 = tmp4_74484 + redout_74467;
                
                ((double *) mem_71119)[i_74466] = tmp4_74484;
                
                double redout_tmp_74518 = defunc_1_op_res_74485;
                
                redout_74467 = redout_tmp_74518;
            }
            defunc_2_reduce_res_74464 = redout_74467;
            
            double a0_74487 = 1.0 / defunc_2_reduce_res_74464;
            double defunc_2_reduce_res_74488;
            double redout_74490 = 0.0;
            
            for (int64_t i_74489 = 0; i_74489 < q_65380; i_74489++) {
                double x_74491;
                
                x_74491 = ((double *) mem_71119)[i_74489];
                
                bool cond_74492 = sle64(last_res_66051, i_74489);
                double defunc_0_f_res_74493;
                
                if (cond_74492) {
                    defunc_0_f_res_74493 = 0.0;
                } else {
                    int64_t i_74494 = add64(max_res_74443, i_74489);
                    double defunc_0_add_arg_74495;
                    
                    defunc_0_add_arg_74495 = ((double *) mem_71049)[i_74494];
                    defunc_0_f_res_74493 = defunc_0_add_arg_74495;
                }
                
                double x_74496 = a0_74487 * x_74491;
                double defunc_9_fit_fun_res_74497 = defunc_0_f_res_74493 *
                       x_74496;
                double defunc_1_op_res_74498 = defunc_9_fit_fun_res_74497 +
                       redout_74490;
                double redout_tmp_74520 = defunc_1_op_res_74498;
                
                redout_74490 = redout_tmp_74520;
            }
            defunc_2_reduce_res_74488 = redout_74490;
            ((double *) mem_71109)[i_74375] = defunc_2_reduce_res_74488;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71140.mem + gtid_68448 * n_m_65386 * (int64_t) 8,
                    mem_71109 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71034);
    free(mem_71049);
    free(mem_71052);
    free(mem_71079);
    free(mem_71094);
    free(mem_71109);
    free(mem_71119);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77237_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77237_end -
                 futhark_mc_segmap_parloop_77237_start;
        
        ctx->futhark_mc_segmap_parloop_77237_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77237_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77237_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77235(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_68447 = tid;
    int num_tasks_74342 = info.nsubtasks;
    struct futhark_mc_task_77234 *futhark_mc_task_77234 =
                                 (struct futhark_mc_task_77234 *) args;
    struct futhark_context *ctx = futhark_mc_task_77234->ctx;
    uint64_t futhark_mc_segmap_task_77235_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77235_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77234->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77234->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77234->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77234->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77234->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77234->free_i_65392;
    bool x_65393 = futhark_mc_task_77234->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77234->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77234->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77234->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77234->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70997 = futhark_mc_task_77234->free_bytes_70997;
    int64_t bytes_71009 = futhark_mc_task_77234->free_bytes_71009;
    int64_t bytes_71030 = futhark_mc_task_77234->free_bytes_71030;
    struct memblock mem_71140 = {.desc ="mem_71140", .mem =
                                 futhark_mc_task_77234->free_mem_71140, .size =
                                 0, .references =NULL};
    int64_t iter_74343;
    struct futhark_mc_segmap_parloop_struct_77236
    futhark_mc_segmap_parloop_struct_77236;
    
    futhark_mc_segmap_parloop_struct_77236.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77236.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77236.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77236.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77236.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77236.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77236.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77236.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77236.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77236.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77236.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77236.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77236.free_bytes_70997 = bytes_70997;
    futhark_mc_segmap_parloop_struct_77236.free_bytes_71009 = bytes_71009;
    futhark_mc_segmap_parloop_struct_77236.free_bytes_71030 = bytes_71030;
    futhark_mc_segmap_parloop_struct_77236.free_mem_71140 = mem_71140.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77237_task;
    
    futhark_mc_segmap_parloop_77237_task.name =
        "futhark_mc_segmap_parloop_77237";
    futhark_mc_segmap_parloop_77237_task.fn = futhark_mc_segmap_parloop_77237;
    futhark_mc_segmap_parloop_77237_task.args =
        &futhark_mc_segmap_parloop_struct_77236;
    futhark_mc_segmap_parloop_77237_task.iterations = iterations;
    futhark_mc_segmap_parloop_77237_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77237_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77237_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77237_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77237_task);
    
    if (futhark_mc_segmap_parloop_77237_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77237_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77237_total_end -
                 futhark_mc_segmap_parloop_77237_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77237_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77237_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77237_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77235_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77235_end -
                 futhark_mc_segmap_task_77235_start;
        
        ctx->futhark_mc_segmap_task_77235_runs[tid]++;
        ctx->futhark_mc_segmap_task_77235_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77235_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77246 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_70997;
    int64_t free_bytes_71009;
    int64_t free_bytes_71030;
    unsigned char *free_mem_71140;
};
struct futhark_mc_task_77254 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68596;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70998;
};
struct futhark_mc_scan_stage_1_parloop_struct_77257 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68596;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70998;
};
static int futhark_mc_scan_stage_1_parloop_77258(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_74522, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_1_parloop_struct_77257
    *futhark_mc_scan_stage_1_parloop_struct_77257 =
    (struct futhark_mc_scan_stage_1_parloop_struct_77257 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_1_parloop_struct_77257->ctx;
    uint64_t futhark_mc_scan_stage_1_parloop_77258_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77258_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_1_parloop_struct_77257->free_n_65378;
    int64_t gtid_68596 =
            futhark_mc_scan_stage_1_parloop_struct_77257->free_gtid_68596;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_1_parloop_struct_77257->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70998 = {.desc ="mem_70998", .mem =
                                 futhark_mc_scan_stage_1_parloop_struct_77257->free_mem_70998,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74801 = start;
    int64_t x_74524;
    int64_t x_74525;
    
    x_74524 = (int64_t) 0;
    for (; iter_74801 < end; iter_74801++) {
        int64_t gtid_74523 = iter_74801;
        
        // stage 1 scan body
        {
            double x_74527;
            
            x_74527 = ((double *) Y_mem_70603.mem)[gtid_68596 * n_65378 +
                                                   gtid_74523];
            
            bool isnan_res_74528;
            
            isnan_res_74528 = futrts_isnan64(x_74527);
            
            bool defunc_0_p_res_74529 = !isnan_res_74528;
            int64_t defunc_0_f_res_74530 = btoi_bool_i64(defunc_0_p_res_74529);
            
            // write mapped values results to memory
            { }
            x_74524 = x_74524;
            // Read next values
            {
                x_74525 = defunc_0_f_res_74530;
            }
            
            int64_t defunc_1_op_res_74526 = add64(x_74524, x_74525);
            
            ((int64_t *) mem_70998.mem)[gtid_74523] = defunc_1_op_res_74526;
            x_74524 = defunc_1_op_res_74526;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77258_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77258_end -
                 futhark_mc_scan_stage_1_parloop_77258_start;
        
        ctx->futhark_mc_scan_stage_1_parloop_77258_runs[tid]++;
        ctx->futhark_mc_scan_stage_1_parloop_77258_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_1_parloop_77258_iter[tid] += iterations;
    }
    return err;
}
struct futhark_mc_scan_stage_3_parloop_struct_77259 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68596;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70998;
};
static int futhark_mc_scan_stage_3_parloop_77260(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_74522, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_3_parloop_struct_77259
    *futhark_mc_scan_stage_3_parloop_struct_77259 =
    (struct futhark_mc_scan_stage_3_parloop_struct_77259 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_3_parloop_struct_77259->ctx;
    uint64_t futhark_mc_scan_stage_3_parloop_77260_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_3_parloop_77260_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_3_parloop_struct_77259->free_n_65378;
    int64_t gtid_68596 =
            futhark_mc_scan_stage_3_parloop_struct_77259->free_gtid_68596;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_3_parloop_struct_77259->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70998 = {.desc ="mem_70998", .mem =
                                 futhark_mc_scan_stage_3_parloop_struct_77259->free_mem_70998,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74813 = start;
    int64_t x_74810;
    int64_t x_74811;
    
    if (iter_74813 == (int64_t) 0) {
        x_74810 = (int64_t) 0;
    } else {
        x_74810 = ((int64_t *) mem_70998.mem)[iter_74813 - (int64_t) 1];
    }
    for (; iter_74813 < end; iter_74813++) {
        int64_t gtid_74523 = iter_74813;
        
        // stage 3 scan body
        {
            double x_74527;
            
            x_74527 = ((double *) Y_mem_70603.mem)[gtid_68596 * n_65378 +
                                                   gtid_74523];
            
            bool isnan_res_74528;
            
            isnan_res_74528 = futrts_isnan64(x_74527);
            
            bool defunc_0_p_res_74529 = !isnan_res_74528;
            int64_t defunc_0_f_res_74530 = btoi_bool_i64(defunc_0_p_res_74529);
            
            x_74810 = x_74810;
            x_74811 = defunc_0_f_res_74530;
            
            int64_t defunc_1_op_res_74812 = add64(x_74810, x_74811);
            
            ((int64_t *) mem_70998.mem)[gtid_74523] = defunc_1_op_res_74812;
            x_74810 = defunc_1_op_res_74812;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_3_parloop_77260_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77260_end -
                 futhark_mc_scan_stage_3_parloop_77260_start;
        
        ctx->futhark_mc_scan_stage_3_parloop_77260_runs[tid]++;
        ctx->futhark_mc_scan_stage_3_parloop_77260_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_3_parloop_77260_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segscan_task_77255(void *args, int64_t iterations, int tid,
                                  struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74522 = tid;
    int num_tasks_74800 = info.nsubtasks;
    struct futhark_mc_task_77254 *futhark_mc_task_77254 =
                                 (struct futhark_mc_task_77254 *) args;
    struct futhark_context *ctx = futhark_mc_task_77254->ctx;
    uint64_t futhark_mc_segscan_task_77255_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segscan_task_77255_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77254->free_n_65378;
    int64_t gtid_68596 = futhark_mc_task_77254->free_gtid_68596;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77254->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70998 = {.desc ="mem_70998", .mem =
                                 futhark_mc_task_77254->free_mem_70998, .size =
                                 0, .references =NULL};
    size_t scan_stage_2_accum_mem_74807_cached_sizze_77256 = 0;
    unsigned char *scan_stage_2_accum_mem_74807 = NULL;
    int64_t iter_74801;
    struct futhark_mc_scan_stage_1_parloop_struct_77257
    futhark_mc_scan_stage_1_parloop_struct_77257;
    
    futhark_mc_scan_stage_1_parloop_struct_77257.ctx = ctx;
    futhark_mc_scan_stage_1_parloop_struct_77257.free_n_65378 = n_65378;
    futhark_mc_scan_stage_1_parloop_struct_77257.free_gtid_68596 = gtid_68596;
    futhark_mc_scan_stage_1_parloop_struct_77257.free_Y_mem_70603 =
        Y_mem_70603.mem;
    futhark_mc_scan_stage_1_parloop_struct_77257.free_mem_70998 = mem_70998.mem;
    
    struct scheduler_parloop futhark_mc_scan_stage_1_parloop_77258_task;
    
    futhark_mc_scan_stage_1_parloop_77258_task.name =
        "futhark_mc_scan_stage_1_parloop_77258";
    futhark_mc_scan_stage_1_parloop_77258_task.fn =
        futhark_mc_scan_stage_1_parloop_77258;
    futhark_mc_scan_stage_1_parloop_77258_task.args =
        &futhark_mc_scan_stage_1_parloop_struct_77257;
    futhark_mc_scan_stage_1_parloop_77258_task.iterations = iterations;
    futhark_mc_scan_stage_1_parloop_77258_task.info = info;
    
    uint64_t futhark_mc_scan_stage_1_parloop_77258_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77258_total_start = get_wall_time();
    
    int futhark_mc_scan_stage_1_parloop_77258_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_scan_stage_1_parloop_77258_task);
    
    if (futhark_mc_scan_stage_1_parloop_77258_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77258_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77258_total_end -
                 futhark_mc_scan_stage_1_parloop_77258_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77258_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77258_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77258_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    if (slt32(1, num_tasks_74800)) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmentedScan stage 2");
        
        int64_t x_74802;
        int64_t x_74803;
        int64_t offset_74805 = (int64_t) 0;
        int64_t offset_index_74806 = (int64_t) 0;
        
        if (scan_stage_2_accum_mem_74807_cached_sizze_77256 <
            (size_t) (int64_t) 8) {
            scan_stage_2_accum_mem_74807 = realloc(scan_stage_2_accum_mem_74807,
                                                   (int64_t) 8);
            scan_stage_2_accum_mem_74807_cached_sizze_77256 = (int64_t) 8;
        }
        ((int64_t *) scan_stage_2_accum_mem_74807)[(int64_t) 0] = (int64_t) 0;
        for (int32_t i_74809 = 0; i_74809 < num_tasks_74800 - 1; i_74809++) {
            offset_74805 = squot64(n_65378, sext_i32_i64(num_tasks_74800));
            if (slt64(sext_i32_i64(i_74809), srem64(n_65378,
                                                    sext_i32_i64(num_tasks_74800)))) {
                offset_74805 += (int64_t) 1;
            }
            offset_index_74806 += offset_74805;
            
            int64_t gtid_74523 = offset_index_74806;
            double x_74527;
            
            x_74527 = ((double *) Y_mem_70603.mem)[gtid_68596 * n_65378 +
                                                   gtid_74523];
            
            bool isnan_res_74528;
            
            isnan_res_74528 = futrts_isnan64(x_74527);
            
            bool defunc_0_p_res_74529 = !isnan_res_74528;
            int64_t defunc_0_f_res_74530 = btoi_bool_i64(defunc_0_p_res_74529);
            
            // Read carry in
            {
                x_74802 =
                    ((int64_t *) scan_stage_2_accum_mem_74807)[(int64_t) 0];
            }
            // Read next values
            {
                x_74803 = ((int64_t *) mem_70998.mem)[offset_index_74806 -
                                                      (int64_t) 1];
            }
            
            int64_t defunc_1_op_res_74804 = add64(x_74802, x_74803);
            
            ((int64_t *) mem_70998.mem)[offset_index_74806 - (int64_t) 1] =
                defunc_1_op_res_74804;
            ((int64_t *) scan_stage_2_accum_mem_74807)[(int64_t) 0] =
                defunc_1_op_res_74804;
        }
        
        int64_t iter_74813 = (int64_t) 0;
        struct futhark_mc_scan_stage_3_parloop_struct_77259
        futhark_mc_scan_stage_3_parloop_struct_77259;
        
        futhark_mc_scan_stage_3_parloop_struct_77259.ctx = ctx;
        futhark_mc_scan_stage_3_parloop_struct_77259.free_n_65378 = n_65378;
        futhark_mc_scan_stage_3_parloop_struct_77259.free_gtid_68596 =
            gtid_68596;
        futhark_mc_scan_stage_3_parloop_struct_77259.free_Y_mem_70603 =
            Y_mem_70603.mem;
        futhark_mc_scan_stage_3_parloop_struct_77259.free_mem_70998 =
            mem_70998.mem;
        
        struct scheduler_parloop futhark_mc_scan_stage_3_parloop_77260_task;
        
        futhark_mc_scan_stage_3_parloop_77260_task.name =
            "futhark_mc_scan_stage_3_parloop_77260";
        futhark_mc_scan_stage_3_parloop_77260_task.fn =
            futhark_mc_scan_stage_3_parloop_77260;
        futhark_mc_scan_stage_3_parloop_77260_task.args =
            &futhark_mc_scan_stage_3_parloop_struct_77259;
        futhark_mc_scan_stage_3_parloop_77260_task.iterations = iterations;
        futhark_mc_scan_stage_3_parloop_77260_task.info = info;
        
        uint64_t futhark_mc_scan_stage_3_parloop_77260_total_start = 0;
        
        if (ctx->profiling && !ctx->profiling_paused)
            futhark_mc_scan_stage_3_parloop_77260_total_start = get_wall_time();
        
        int futhark_mc_scan_stage_3_parloop_77260_err =
            scheduler_execute_task(&ctx->scheduler,
                                   &futhark_mc_scan_stage_3_parloop_77260_task);
        
        if (futhark_mc_scan_stage_3_parloop_77260_err != 0) {
            err = 1;
            goto cleanup;
        }
        if (ctx->profiling && !ctx->profiling_paused) {
            uint64_t futhark_mc_scan_stage_3_parloop_77260_total_end =
                     get_wall_time();
            uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77260_total_end -
                     futhark_mc_scan_stage_3_parloop_77260_total_start;
            
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77260_total_runs,
                               1, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77260_total_total_runtime,
                               elapsed, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77260_total_iter,
                               iterations, __ATOMIC_RELAXED);
        }
    }
    
  cleanup:
    {
        free(scan_stage_2_accum_mem_74807);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segscan_task_77255_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segscan_task_77255_end -
                 futhark_mc_segscan_task_77255_start;
        
        ctx->futhark_mc_segscan_task_77255_runs[tid]++;
        ctx->futhark_mc_segscan_task_77255_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segscan_task_77255_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77261 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68596;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70998;
    unsigned char *free_mem_71001;
    unsigned char *free_mem_71004;
};
struct futhark_mc_segmap_parloop_struct_77263 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_68596;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_70998;
    unsigned char *free_mem_71001;
    unsigned char *free_mem_71004;
};
static int futhark_mc_segmap_parloop_77264(void *args, int64_t start,
                                           int64_t end, int flat_tid_74531,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77263
    *futhark_mc_segmap_parloop_struct_77263 =
    (struct futhark_mc_segmap_parloop_struct_77263 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77263->ctx;
    uint64_t futhark_mc_segmap_parloop_77264_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77264_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77263->free_n_65378;
    int64_t gtid_68596 =
            futhark_mc_segmap_parloop_struct_77263->free_gtid_68596;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77263->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70998 = {.desc ="mem_70998", .mem =
                                 futhark_mc_segmap_parloop_struct_77263->free_mem_70998,
                                 .size =0, .references =NULL};
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_segmap_parloop_struct_77263->free_mem_71001,
                                 .size =0, .references =NULL};
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_segmap_parloop_struct_77263->free_mem_71004,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74817 = start;
    
    for (; iter_74817 < end; iter_74817++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74820 = n_65378;
        int64_t gtid_74532 = iter_74817;
        int64_t remnant_74821 = iter_74817 - gtid_74532;
        double x_74533;
        
        x_74533 = ((double *) Y_mem_70603.mem)[gtid_68596 * n_65378 +
                                               gtid_74532];
        
        bool isnan_res_74534;
        
        isnan_res_74534 = futrts_isnan64(x_74533);
        
        bool defunc_0_p_res_74535 = !isnan_res_74534;
        int64_t defunc_1_f_res_74536;
        
        if (defunc_0_p_res_74535) {
            int64_t x_74818;
            
            x_74818 = ((int64_t *) mem_70998.mem)[gtid_74532];
            
            int64_t defunc_1_f_res_t_res_74819 = sub64(x_74818, (int64_t) 1);
            
            defunc_1_f_res_74536 = defunc_1_f_res_t_res_74819;
        } else {
            defunc_1_f_res_74536 = (int64_t) -1;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_74536) &&
            slt64(defunc_1_f_res_74536, n_65378)) {
            ((int64_t *) mem_71004.mem)[defunc_1_f_res_74536] = gtid_74532;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_74536) &&
            slt64(defunc_1_f_res_74536, n_65378)) {
            ((double *) mem_71001.mem)[defunc_1_f_res_74536] = x_74533;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77264_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77264_end -
                 futhark_mc_segmap_parloop_77264_start;
        
        ctx->futhark_mc_segmap_parloop_77264_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77264_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77264_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77262(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74531 = tid;
    int num_tasks_74816 = info.nsubtasks;
    struct futhark_mc_task_77261 *futhark_mc_task_77261 =
                                 (struct futhark_mc_task_77261 *) args;
    struct futhark_context *ctx = futhark_mc_task_77261->ctx;
    uint64_t futhark_mc_segmap_task_77262_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77262_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77261->free_n_65378;
    int64_t gtid_68596 = futhark_mc_task_77261->free_gtid_68596;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77261->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_70998 = {.desc ="mem_70998", .mem =
                                 futhark_mc_task_77261->free_mem_70998, .size =
                                 0, .references =NULL};
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_task_77261->free_mem_71001, .size =
                                 0, .references =NULL};
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_task_77261->free_mem_71004, .size =
                                 0, .references =NULL};
    int64_t iter_74817;
    struct futhark_mc_segmap_parloop_struct_77263
    futhark_mc_segmap_parloop_struct_77263;
    
    futhark_mc_segmap_parloop_struct_77263.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77263.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77263.free_gtid_68596 = gtid_68596;
    futhark_mc_segmap_parloop_struct_77263.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77263.free_mem_70998 = mem_70998.mem;
    futhark_mc_segmap_parloop_struct_77263.free_mem_71001 = mem_71001.mem;
    futhark_mc_segmap_parloop_struct_77263.free_mem_71004 = mem_71004.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77264_task;
    
    futhark_mc_segmap_parloop_77264_task.name =
        "futhark_mc_segmap_parloop_77264";
    futhark_mc_segmap_parloop_77264_task.fn = futhark_mc_segmap_parloop_77264;
    futhark_mc_segmap_parloop_77264_task.args =
        &futhark_mc_segmap_parloop_struct_77263;
    futhark_mc_segmap_parloop_77264_task.iterations = iterations;
    futhark_mc_segmap_parloop_77264_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77264_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77264_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77264_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77264_task);
    
    if (futhark_mc_segmap_parloop_77264_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77264_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77264_total_end -
                 futhark_mc_segmap_parloop_77264_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77264_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77264_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77264_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77262_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77262_end -
                 futhark_mc_segmap_task_77262_start;
        
        ctx->futhark_mc_segmap_task_77262_runs[tid]++;
        ctx->futhark_mc_segmap_task_77262_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77262_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77265 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71007;
};
struct futhark_mc_segmap_parloop_struct_77267 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71007;
};
static int futhark_mc_segmap_parloop_77268(void *args, int64_t start,
                                           int64_t end, int flat_tid_74539,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77267
    *futhark_mc_segmap_parloop_struct_77267 =
    (struct futhark_mc_segmap_parloop_struct_77267 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77267->ctx;
    uint64_t futhark_mc_segmap_parloop_77268_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77268_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77267->free_n_65378;
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_segmap_parloop_struct_77267->free_mem_71004,
                                 .size =0, .references =NULL};
    struct memblock mem_71007 = {.desc ="mem_71007", .mem =
                                 futhark_mc_segmap_parloop_struct_77267->free_mem_71007,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74823 = start;
    
    for (; iter_74823 < end; iter_74823++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74824 = n_65378;
        int64_t gtid_74540 = iter_74823;
        int64_t remnant_74825 = iter_74823 - gtid_74540;
        int64_t x_74541;
        
        x_74541 = ((int64_t *) mem_71004.mem)[gtid_74540];
        
        int64_t defunc_0_f_res_74542 = add64((int64_t) 1, x_74541);
        
        ((int64_t *) mem_71007.mem)[gtid_74540] = defunc_0_f_res_74542;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77268_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77268_end -
                 futhark_mc_segmap_parloop_77268_start;
        
        ctx->futhark_mc_segmap_parloop_77268_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77268_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77268_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77266(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74539 = tid;
    int num_tasks_74822 = info.nsubtasks;
    struct futhark_mc_task_77265 *futhark_mc_task_77265 =
                                 (struct futhark_mc_task_77265 *) args;
    struct futhark_context *ctx = futhark_mc_task_77265->ctx;
    uint64_t futhark_mc_segmap_task_77266_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77266_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77265->free_n_65378;
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_task_77265->free_mem_71004, .size =
                                 0, .references =NULL};
    struct memblock mem_71007 = {.desc ="mem_71007", .mem =
                                 futhark_mc_task_77265->free_mem_71007, .size =
                                 0, .references =NULL};
    int64_t iter_74823;
    struct futhark_mc_segmap_parloop_struct_77267
    futhark_mc_segmap_parloop_struct_77267;
    
    futhark_mc_segmap_parloop_struct_77267.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77267.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77267.free_mem_71004 = mem_71004.mem;
    futhark_mc_segmap_parloop_struct_77267.free_mem_71007 = mem_71007.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77268_task;
    
    futhark_mc_segmap_parloop_77268_task.name =
        "futhark_mc_segmap_parloop_77268";
    futhark_mc_segmap_parloop_77268_task.fn = futhark_mc_segmap_parloop_77268;
    futhark_mc_segmap_parloop_77268_task.args =
        &futhark_mc_segmap_parloop_struct_77267;
    futhark_mc_segmap_parloop_77268_task.iterations = iterations;
    futhark_mc_segmap_parloop_77268_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77268_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77268_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77268_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77268_task);
    
    if (futhark_mc_segmap_parloop_77268_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77268_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77268_total_end -
                 futhark_mc_segmap_parloop_77268_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77268_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77268_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77268_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77266_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77266_end -
                 futhark_mc_segmap_task_77266_start;
        
        ctx->futhark_mc_segmap_task_77266_runs[tid]++;
        ctx->futhark_mc_segmap_task_77266_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77266_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77269 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_68608;
    unsigned char *free_mem_71010;
};
struct futhark_mc_segmap_parloop_struct_77271 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_68608;
    unsigned char *free_mem_71010;
};
static int futhark_mc_segmap_parloop_77272(void *args, int64_t start,
                                           int64_t end, int flat_tid_74543,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77271
    *futhark_mc_segmap_parloop_struct_77271 =
    (struct futhark_mc_segmap_parloop_struct_77271 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77271->ctx;
    uint64_t futhark_mc_segmap_parloop_77272_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77272_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77271->free_q_65380;
    int64_t last_res_68608 =
            futhark_mc_segmap_parloop_struct_77271->free_last_res_68608;
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_segmap_parloop_struct_77271->free_mem_71010,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_74827 = start;
    
    for (; iter_74827 < end; iter_74827++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74828 = q_65380;
        int64_t gtid_74544 = iter_74827;
        int64_t remnant_74829 = iter_74827 - gtid_74544;
        bool cond_74545 = sle64(last_res_68608, gtid_74544);
        double defunc_0_f_res_74546;
        
        if (cond_74545) {
            defunc_0_f_res_74546 = 0.0;
        } else {
            defunc_0_f_res_74546 = 1.0;
        }
        ((double *) mem_71010.mem)[gtid_74544] = defunc_0_f_res_74546;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77272_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77272_end -
                 futhark_mc_segmap_parloop_77272_start;
        
        ctx->futhark_mc_segmap_parloop_77272_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77272_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77272_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77270(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74543 = tid;
    int num_tasks_74826 = info.nsubtasks;
    struct futhark_mc_task_77269 *futhark_mc_task_77269 =
                                 (struct futhark_mc_task_77269 *) args;
    struct futhark_context *ctx = futhark_mc_task_77269->ctx;
    uint64_t futhark_mc_segmap_task_77270_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77270_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77269->free_q_65380;
    int64_t last_res_68608 = futhark_mc_task_77269->free_last_res_68608;
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_task_77269->free_mem_71010, .size =
                                 0, .references =NULL};
    int64_t iter_74827;
    struct futhark_mc_segmap_parloop_struct_77271
    futhark_mc_segmap_parloop_struct_77271;
    
    futhark_mc_segmap_parloop_struct_77271.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77271.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77271.free_last_res_68608 = last_res_68608;
    futhark_mc_segmap_parloop_struct_77271.free_mem_71010 = mem_71010.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77272_task;
    
    futhark_mc_segmap_parloop_77272_task.name =
        "futhark_mc_segmap_parloop_77272";
    futhark_mc_segmap_parloop_77272_task.fn = futhark_mc_segmap_parloop_77272;
    futhark_mc_segmap_parloop_77272_task.args =
        &futhark_mc_segmap_parloop_struct_77271;
    futhark_mc_segmap_parloop_77272_task.iterations = iterations;
    futhark_mc_segmap_parloop_77272_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77272_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77272_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77272_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77272_task);
    
    if (futhark_mc_segmap_parloop_77272_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77272_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77272_total_end -
                 futhark_mc_segmap_parloop_77272_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77272_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77272_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77272_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77270_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77270_end -
                 futhark_mc_segmap_task_77270_start;
        
        ctx->futhark_mc_segmap_task_77270_runs[tid]++;
        ctx->futhark_mc_segmap_task_77270_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77270_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77273 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_68608;
    int64_t free_min_arg_68627;
    int64_t free_min_arg_68628;
    int64_t free_min_res_68629;
    double free_max_res_68633;
    unsigned char *free_mem_71001;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71007;
    int64_t free_bytes_71009;
    unsigned char *free_mem_71010;
    unsigned char *free_mem_71031;
};
struct futhark_mc_segmap_parloop_struct_77275 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_68608;
    int64_t free_min_arg_68627;
    int64_t free_min_arg_68628;
    int64_t free_min_res_68629;
    double free_max_res_68633;
    unsigned char *free_mem_71001;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71007;
    int64_t free_bytes_71009;
    unsigned char *free_mem_71010;
    unsigned char *free_mem_71031;
};
static int futhark_mc_segmap_parloop_77276(void *args, int64_t start,
                                           int64_t end, int flat_tid_74673,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77275
    *futhark_mc_segmap_parloop_struct_77275 =
    (struct futhark_mc_segmap_parloop_struct_77275 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77275->ctx;
    uint64_t futhark_mc_segmap_parloop_77276_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77276_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77275->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77275->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77275->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77275->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77275->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77275->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77275->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77275->free_loop_cond_65403;
    int64_t last_res_68608 =
            futhark_mc_segmap_parloop_struct_77275->free_last_res_68608;
    int64_t min_arg_68627 =
            futhark_mc_segmap_parloop_struct_77275->free_min_arg_68627;
    int64_t min_arg_68628 =
            futhark_mc_segmap_parloop_struct_77275->free_min_arg_68628;
    int64_t min_res_68629 =
            futhark_mc_segmap_parloop_struct_77275->free_min_res_68629;
    double max_res_68633 =
           futhark_mc_segmap_parloop_struct_77275->free_max_res_68633;
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_segmap_parloop_struct_77275->free_mem_71001,
                                 .size =0, .references =NULL};
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_segmap_parloop_struct_77275->free_mem_71004,
                                 .size =0, .references =NULL};
    struct memblock mem_71007 = {.desc ="mem_71007", .mem =
                                 futhark_mc_segmap_parloop_struct_77275->free_mem_71007,
                                 .size =0, .references =NULL};
    int64_t bytes_71009 =
            futhark_mc_segmap_parloop_struct_77275->free_bytes_71009;
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_segmap_parloop_struct_77275->free_mem_71010,
                                 .size =0, .references =NULL};
    struct memblock mem_71031 = {.desc ="mem_71031", .mem =
                                 futhark_mc_segmap_parloop_struct_77275->free_mem_71031,
                                 .size =0, .references =NULL};
    size_t mem_74761_cached_sizze_77277 = 0;
    unsigned char *mem_74761 = NULL;
    int64_t iterations = end - start;
    int64_t iter_74831 = start;
    
    if (mem_74761_cached_sizze_77277 < (size_t) bytes_71009) {
        mem_74761 = realloc(mem_74761, bytes_71009);
        mem_74761_cached_sizze_77277 = bytes_71009;
    }
    for (; iter_74831 < end; iter_74831++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74918 = n_m_65386;
        int64_t gtid_74674 = iter_74831;
        int64_t remnant_74919 = iter_74831 - gtid_74674;
        int64_t min_arg_74675 = mul64(jump_65382, gtid_74674);
        int64_t min_res_74676 = smin64(i_65392, min_arg_74675);
        int64_t defunc_0_g_res_74677 = add64((int64_t) 1, min_res_74676);
        bool init_idx_74678;
        int64_t init_idx_74679;
        int64_t init_idx_74680;
        bool loop_while_74832;
        int64_t low_74833;
        int64_t high_74834;
        
        loop_while_74832 = x_65393;
        low_74833 = (int64_t) 0;
        high_74834 = i_65392;
        while (loop_while_74832) {
            int64_t x_74835 = add64(low_74833, high_74834);
            int64_t mid_74836 = sdiv64(x_74835, (int64_t) 2);
            bool x_74837 = sle64((int64_t) 0, mid_74836);
            bool y_74838 = slt64(mid_74836, n_65378);
            bool bounds_check_74839 = x_74837 && y_74838;
            bool index_certs_74840;
            
            if (!bounds_check_74839) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_74836,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_74841;
            
            mid_id_74841 = ((int64_t *) mem_71007.mem)[mid_74836];
            
            bool cond_74842 = slt64(mid_id_74841, (int64_t) 0);
            int64_t mid_idx_74843;
            
            if (cond_74842) {
                mid_idx_74843 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_74843 = mid_id_74841;
            }
            
            bool cond_74844 = sle64(defunc_0_g_res_74677, mid_idx_74843);
            int64_t loopres_74845;
            int64_t loopres_74846;
            
            if (cond_74844) {
                int64_t loopres_t_res_74847 = sub64(mid_74836, (int64_t) 1);
                
                loopres_74845 = low_74833;
                loopres_74846 = loopres_t_res_74847;
            } else {
                int64_t loopres_f_res_74848 = add64((int64_t) 1, mid_74836);
                
                loopres_74845 = loopres_f_res_74848;
                loopres_74846 = high_74834;
            }
            
            bool loop_cond_74849 = sle64(loopres_74845, loopres_74846);
            bool loop_while_tmp_74920 = loop_cond_74849;
            int64_t low_tmp_74921 = loopres_74845;
            int64_t high_tmp_74922 = loopres_74846;
            
            loop_while_74832 = loop_while_tmp_74920;
            low_74833 = low_tmp_74921;
            high_74834 = high_tmp_74922;
        }
        init_idx_74678 = loop_while_74832;
        init_idx_74679 = low_74833;
        init_idx_74680 = high_74834;
        
        bool idx_74699;
        int64_t idx_74700;
        int64_t idx_74701;
        int64_t idx_74702;
        bool loop_while_74850;
        int64_t l_idx_74851;
        int64_t r_idx_74852;
        int64_t span_74853;
        
        loop_while_74850 = loop_cond_65403;
        l_idx_74851 = init_idx_74679;
        r_idx_74852 = init_idx_74679;
        span_74853 = (int64_t) 1;
        while (loop_while_74850) {
            int64_t max_arg_74854 = sub64(l_idx_74851, (int64_t) 1);
            int64_t max_res_74855 = smax64((int64_t) 0, max_arg_74854);
            int64_t min_arg_74856 = add64((int64_t) 1, r_idx_74852);
            int64_t min_res_74857 = smin64(min_arg_68627, min_arg_74856);
            bool x_74858 = sle64((int64_t) 0, max_res_74855);
            bool y_74859 = slt64(max_res_74855, n_65378);
            bool bounds_check_74860 = x_74858 && y_74859;
            bool index_certs_74861;
            
            if (!bounds_check_74860) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_74855,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74862;
            
            x_74862 = ((int64_t *) mem_71007.mem)[max_res_74855];
            
            int64_t abs_arg_74863 = sub64(x_74862, defunc_0_g_res_74677);
            int64_t abs_res_74864 = abs64(abs_arg_74863);
            bool x_74865 = sle64((int64_t) 0, min_res_74857);
            bool y_74866 = slt64(min_res_74857, n_65378);
            bool bounds_check_74867 = x_74865 && y_74866;
            bool index_certs_74868;
            
            if (!bounds_check_74867) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_74857,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74869;
            
            x_74869 = ((int64_t *) mem_71007.mem)[min_res_74857];
            
            int64_t abs_arg_74870 = sub64(x_74869, defunc_0_g_res_74677);
            int64_t abs_res_74871 = abs64(abs_arg_74870);
            bool cond_74872 = max_res_74855 == l_idx_74851;
            int64_t loopres_74873;
            int64_t loopres_74874;
            int64_t loopres_74875;
            
            if (cond_74872) {
                loopres_74873 = l_idx_74851;
                loopres_74874 = r_idx_74852;
                loopres_74875 = min_res_65398;
            } else {
                bool cond_74876 = slt64(abs_res_74864, abs_res_74871);
                bool cond_f_res_74877 = min_res_74857 == r_idx_74852;
                bool x_74878 = !cond_74876;
                bool y_74879 = cond_f_res_74877 && x_74878;
                bool cond_74880 = cond_74876 || y_74879;
                int64_t loopres_f_res_74881;
                
                if (cond_74880) {
                    loopres_f_res_74881 = max_res_74855;
                } else {
                    loopres_f_res_74881 = l_idx_74851;
                }
                
                int64_t loopres_f_res_74882;
                
                if (cond_74880) {
                    loopres_f_res_74882 = r_idx_74852;
                } else {
                    loopres_f_res_74882 = min_res_74857;
                }
                
                int64_t loopres_f_res_74883;
                
                if (cond_74880) {
                    int64_t loopres_f_res_t_res_74884 = add64((int64_t) 1,
                                                              span_74853);
                    
                    loopres_f_res_74883 = loopres_f_res_t_res_74884;
                } else {
                    int64_t loopres_f_res_f_res_74885 = add64((int64_t) 1,
                                                              span_74853);
                    
                    loopres_f_res_74883 = loopres_f_res_f_res_74885;
                }
                loopres_74873 = loopres_f_res_74881;
                loopres_74874 = loopres_f_res_74882;
                loopres_74875 = loopres_f_res_74883;
            }
            
            bool loop_cond_74886 = slt64(loopres_74875, min_res_65398);
            bool loop_while_tmp_74923 = loop_cond_74886;
            int64_t l_idx_tmp_74924 = loopres_74873;
            int64_t r_idx_tmp_74925 = loopres_74874;
            int64_t span_tmp_74926 = loopres_74875;
            
            loop_while_74850 = loop_while_tmp_74923;
            l_idx_74851 = l_idx_tmp_74924;
            r_idx_74852 = r_idx_tmp_74925;
            span_74853 = span_tmp_74926;
        }
        idx_74699 = loop_while_74850;
        idx_74700 = l_idx_74851;
        idx_74701 = r_idx_74852;
        idx_74702 = span_74853;
        
        int64_t min_res_74740 = smin64(min_arg_68628, idx_74700);
        int64_t max_res_74741 = smax64((int64_t) 0, min_res_74740);
        int64_t x_74742 = add64(min_res_68629, max_res_74741);
        int64_t r_74743 = sub64(x_74742, (int64_t) 1);
        bool x_74744 = sle64((int64_t) 0, r_74743);
        bool y_74745 = slt64(r_74743, n_65378);
        bool bounds_check_74746 = x_74744 && y_74745;
        bool index_certs_74747;
        
        if (!bounds_check_74746) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_74743,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_74748;
        
        x_74748 = ((int64_t *) mem_71004.mem)[r_74743];
        
        int64_t abs_arg_74749 = sub64(x_74748, min_res_74676);
        int64_t abs_res_74750 = abs64(abs_arg_74749);
        bool x_74751 = sle64((int64_t) 0, max_res_74741);
        bool y_74752 = slt64(max_res_74741, n_65378);
        bool bounds_check_74753 = x_74751 && y_74752;
        bool index_certs_74754;
        
        if (!bounds_check_74753) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_74741,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_74755;
        
        x_74755 = ((int64_t *) mem_71004.mem)[max_res_74741];
        
        int64_t abs_arg_74756 = sub64(x_74755, min_res_74676);
        int64_t abs_res_74757 = abs64(abs_arg_74756);
        int64_t max_res_74758 = smax64(abs_res_74750, abs_res_74757);
        double defunc_0_f_res_74759 = sitofp_i64_f64(max_res_74758);
        double defunc_1_f_res_74760 = max_res_68633 + defunc_0_f_res_74759;
        double defunc_2_reduce_res_74763;
        double redout_74888 = 0.0;
        
        for (int64_t i_74887 = 0; i_74887 < q_65380; i_74887++) {
            double x_74890;
            
            x_74890 = ((double *) mem_71010.mem)[i_74887];
            
            bool cond_74891 = sle64(last_res_68608, i_74887);
            int64_t defunc_0_f_res_74892;
            
            if (cond_74891) {
                defunc_0_f_res_74892 = (int64_t) 0;
            } else {
                int64_t i_74893 = add64(max_res_74741, i_74887);
                int64_t defunc_0_add_arg_74894;
                
                defunc_0_add_arg_74894 = ((int64_t *) mem_71004.mem)[i_74893];
                
                int64_t defunc_1_add_res_74895 = add64((int64_t) 1,
                                                       defunc_0_add_arg_74894);
                
                defunc_0_f_res_74892 = defunc_1_add_res_74895;
            }
            
            int64_t binop_p_74896 = sub64(defunc_0_f_res_74892, min_res_74676);
            double defunc_0_f_res_74897 = sitofp_i64_f64(binop_p_74896);
            double abs_res_74898 = fabs(defunc_0_f_res_74897);
            double tmp1_74899 = abs_res_74898 / defunc_1_f_res_74760;
            double x_74900 = tmp1_74899 * tmp1_74899;
            double y_74901 = tmp1_74899 * x_74900;
            double tmp2_74902 = 1.0 - y_74901;
            double x_74903 = tmp2_74902 * tmp2_74902;
            double tmp3_74904 = tmp2_74902 * x_74903;
            double tmp4_74905 = x_74890 * tmp3_74904;
            double defunc_1_op_res_74906 = tmp4_74905 + redout_74888;
            
            ((double *) mem_74761)[i_74887] = tmp4_74905;
            
            double redout_tmp_74927 = defunc_1_op_res_74906;
            
            redout_74888 = redout_tmp_74927;
        }
        defunc_2_reduce_res_74763 = redout_74888;
        
        double a0_74786 = 1.0 / defunc_2_reduce_res_74763;
        double defunc_2_reduce_res_74787;
        double redout_74909 = 0.0;
        
        for (int64_t i_74908 = 0; i_74908 < q_65380; i_74908++) {
            double x_74910;
            
            x_74910 = ((double *) mem_74761)[i_74908];
            
            bool cond_74911 = sle64(last_res_68608, i_74908);
            double defunc_0_f_res_74912;
            
            if (cond_74911) {
                defunc_0_f_res_74912 = 0.0;
            } else {
                int64_t i_74913 = add64(max_res_74741, i_74908);
                double defunc_0_add_arg_74914;
                
                defunc_0_add_arg_74914 = ((double *) mem_71001.mem)[i_74913];
                defunc_0_f_res_74912 = defunc_0_add_arg_74914;
            }
            
            double x_74915 = a0_74786 * x_74910;
            double defunc_9_fit_fun_res_74916 = defunc_0_f_res_74912 * x_74915;
            double defunc_1_op_res_74917 = defunc_9_fit_fun_res_74916 +
                   redout_74909;
            double redout_tmp_74929 = defunc_1_op_res_74917;
            
            redout_74909 = redout_tmp_74929;
        }
        defunc_2_reduce_res_74787 = redout_74909;
        ((double *) mem_71031.mem)[gtid_74674] = defunc_2_reduce_res_74787;
    }
    
  cleanup:
    { }
    free(mem_74761);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77276_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77276_end -
                 futhark_mc_segmap_parloop_77276_start;
        
        ctx->futhark_mc_segmap_parloop_77276_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77276_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77276_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77274(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74673 = tid;
    int num_tasks_74830 = info.nsubtasks;
    struct futhark_mc_task_77273 *futhark_mc_task_77273 =
                                 (struct futhark_mc_task_77273 *) args;
    struct futhark_context *ctx = futhark_mc_task_77273->ctx;
    uint64_t futhark_mc_segmap_task_77274_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77274_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77273->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77273->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77273->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77273->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77273->free_i_65392;
    bool x_65393 = futhark_mc_task_77273->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77273->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77273->free_loop_cond_65403;
    int64_t last_res_68608 = futhark_mc_task_77273->free_last_res_68608;
    int64_t min_arg_68627 = futhark_mc_task_77273->free_min_arg_68627;
    int64_t min_arg_68628 = futhark_mc_task_77273->free_min_arg_68628;
    int64_t min_res_68629 = futhark_mc_task_77273->free_min_res_68629;
    double max_res_68633 = futhark_mc_task_77273->free_max_res_68633;
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_task_77273->free_mem_71001, .size =
                                 0, .references =NULL};
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_task_77273->free_mem_71004, .size =
                                 0, .references =NULL};
    struct memblock mem_71007 = {.desc ="mem_71007", .mem =
                                 futhark_mc_task_77273->free_mem_71007, .size =
                                 0, .references =NULL};
    int64_t bytes_71009 = futhark_mc_task_77273->free_bytes_71009;
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_task_77273->free_mem_71010, .size =
                                 0, .references =NULL};
    struct memblock mem_71031 = {.desc ="mem_71031", .mem =
                                 futhark_mc_task_77273->free_mem_71031, .size =
                                 0, .references =NULL};
    int64_t iter_74831;
    struct futhark_mc_segmap_parloop_struct_77275
    futhark_mc_segmap_parloop_struct_77275;
    
    futhark_mc_segmap_parloop_struct_77275.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77275.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77275.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77275.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77275.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77275.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77275.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77275.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77275.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77275.free_last_res_68608 = last_res_68608;
    futhark_mc_segmap_parloop_struct_77275.free_min_arg_68627 = min_arg_68627;
    futhark_mc_segmap_parloop_struct_77275.free_min_arg_68628 = min_arg_68628;
    futhark_mc_segmap_parloop_struct_77275.free_min_res_68629 = min_res_68629;
    futhark_mc_segmap_parloop_struct_77275.free_max_res_68633 = max_res_68633;
    futhark_mc_segmap_parloop_struct_77275.free_mem_71001 = mem_71001.mem;
    futhark_mc_segmap_parloop_struct_77275.free_mem_71004 = mem_71004.mem;
    futhark_mc_segmap_parloop_struct_77275.free_mem_71007 = mem_71007.mem;
    futhark_mc_segmap_parloop_struct_77275.free_bytes_71009 = bytes_71009;
    futhark_mc_segmap_parloop_struct_77275.free_mem_71010 = mem_71010.mem;
    futhark_mc_segmap_parloop_struct_77275.free_mem_71031 = mem_71031.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77276_task;
    
    futhark_mc_segmap_parloop_77276_task.name =
        "futhark_mc_segmap_parloop_77276";
    futhark_mc_segmap_parloop_77276_task.fn = futhark_mc_segmap_parloop_77276;
    futhark_mc_segmap_parloop_77276_task.args =
        &futhark_mc_segmap_parloop_struct_77275;
    futhark_mc_segmap_parloop_77276_task.iterations = iterations;
    futhark_mc_segmap_parloop_77276_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77276_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77276_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77276_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77276_task);
    
    if (futhark_mc_segmap_parloop_77276_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77276_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77276_total_end -
                 futhark_mc_segmap_parloop_77276_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77276_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77276_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77276_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77274_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77274_end -
                 futhark_mc_segmap_task_77274_start;
        
        ctx->futhark_mc_segmap_task_77274_runs[tid]++;
        ctx->futhark_mc_segmap_task_77274_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77274_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77279 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_68608;
    int64_t free_min_arg_68627;
    int64_t free_min_arg_68628;
    int64_t free_min_res_68629;
    double free_max_res_68633;
    unsigned char *free_mem_71001;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71007;
    int64_t free_bytes_71009;
    unsigned char *free_mem_71010;
    unsigned char *free_mem_71031;
};
struct futhark_mc_task_77282 {
    struct futhark_context *ctx;
    int64_t free_last_res_68608;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71010;
    int64_t free_min_res_74550;
    int64_t free_max_res_74615;
    double free_defunc_1_f_res_74634;
    double *retval_defunc_2_reduce_res_74636;
    unsigned char *retval_mem_74635;
};
struct futhark_mc_segred_stage_1_parloop_struct_77285 {
    struct futhark_context *ctx;
    int64_t free_last_res_68608;
    unsigned char *free_mem_71004;
    unsigned char *free_mem_71010;
    int64_t free_min_res_74550;
    int64_t free_max_res_74615;
    double free_defunc_1_f_res_74634;
    unsigned char *free_mem_74635;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75029;
};
static int futhark_mc_segred_stage_1_parloop_77286(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_74986, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77285
    *futhark_mc_segred_stage_1_parloop_struct_77285 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77285 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77285->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77286_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77286_start = get_wall_time();
    
    int64_t last_res_68608 =
            futhark_mc_segred_stage_1_parloop_struct_77285->free_last_res_68608;
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77285->free_mem_71004,
                                 .size =0, .references =NULL};
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77285->free_mem_71010,
                                 .size =0, .references =NULL};
    int64_t min_res_74550 =
            futhark_mc_segred_stage_1_parloop_struct_77285->free_min_res_74550;
    int64_t max_res_74615 =
            futhark_mc_segred_stage_1_parloop_struct_77285->free_max_res_74615;
    double defunc_1_f_res_74634 =
           futhark_mc_segred_stage_1_parloop_struct_77285->free_defunc_1_f_res_74634;
    struct memblock mem_74635 = {.desc ="mem_74635", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77285->free_mem_74635,
                                 .size =0, .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_75029 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75029",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77285->free_reduce_stage_1_tid_res_arr_mem_75029,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75031 = start;
    double x_74988;
    double x_74989;
    double local_acc_75032 = 0.0;
    
    for (; iter_75031 < end; iter_75031++) {
        int64_t gtid_74987 = iter_75031;
        double x_74991;
        
        x_74991 = ((double *) mem_71010.mem)[gtid_74987];
        
        bool cond_74992 = sle64(last_res_68608, gtid_74987);
        int64_t defunc_0_f_res_74993;
        
        if (cond_74992) {
            defunc_0_f_res_74993 = (int64_t) 0;
        } else {
            int64_t i_74994 = add64(max_res_74615, gtid_74987);
            int64_t defunc_0_add_arg_74995;
            
            defunc_0_add_arg_74995 = ((int64_t *) mem_71004.mem)[i_74994];
            
            int64_t defunc_1_add_res_74996 = add64((int64_t) 1,
                                                   defunc_0_add_arg_74995);
            
            defunc_0_f_res_74993 = defunc_1_add_res_74996;
        }
        
        int64_t binop_p_74997 = sub64(defunc_0_f_res_74993, min_res_74550);
        double defunc_0_f_res_74998 = sitofp_i64_f64(binop_p_74997);
        double abs_res_74999 = fabs(defunc_0_f_res_74998);
        double tmp1_75000 = abs_res_74999 / defunc_1_f_res_74634;
        double x_75001 = tmp1_75000 * tmp1_75000;
        double y_75002 = tmp1_75000 * x_75001;
        double tmp2_75003 = 1.0 - y_75002;
        double x_75004 = tmp2_75003 * tmp2_75003;
        double tmp3_75005 = tmp2_75003 * x_75004;
        double tmp4_75006 = x_74991 * tmp3_75005;
        
        // save map-out results
        {
            ((double *) mem_74635.mem)[gtid_74987] = tmp4_75006;
        }
        // Load accum params
        {
            x_74988 = local_acc_75032;
        }
        // Load next params
        {
            x_74989 = tmp4_75006;
        }
        // Red body
        {
            double defunc_1_op_res_74990 = x_74988 + x_74989;
            
            local_acc_75032 = defunc_1_op_res_74990;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_75029.mem)[flat_tid_74986] =
        local_acc_75032;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77286_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77286_end -
                 futhark_mc_segred_stage_1_parloop_77286_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77286_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77286_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77286_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77283(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74986 = tid;
    int num_tasks_75028 = info.nsubtasks;
    struct futhark_mc_task_77282 *futhark_mc_task_77282 =
                                 (struct futhark_mc_task_77282 *) args;
    struct futhark_context *ctx = futhark_mc_task_77282->ctx;
    uint64_t futhark_mc_segred_task_77283_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77283_start = get_wall_time();
    
    int64_t last_res_68608 = futhark_mc_task_77282->free_last_res_68608;
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_task_77282->free_mem_71004, .size =
                                 0, .references =NULL};
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_task_77282->free_mem_71010, .size =
                                 0, .references =NULL};
    int64_t min_res_74550 = futhark_mc_task_77282->free_min_res_74550;
    int64_t max_res_74615 = futhark_mc_task_77282->free_max_res_74615;
    double defunc_1_f_res_74634 =
           futhark_mc_task_77282->free_defunc_1_f_res_74634;
    double defunc_2_reduce_res_74636 =
           *futhark_mc_task_77282->retval_defunc_2_reduce_res_74636;
    struct memblock mem_74635 = {.desc ="mem_74635", .mem =
                                 futhark_mc_task_77282->retval_mem_74635,
                                 .size =0, .references =NULL};
    size_t reduce_stage_1_tid_res_arr_mem_75029_cached_sizze_77284 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75029 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_75029_cached_sizze_77284 <
        (size_t) ((int64_t) 8 * num_tasks_75028)) {
        reduce_stage_1_tid_res_arr_mem_75029 =
            realloc(reduce_stage_1_tid_res_arr_mem_75029, (int64_t) 8 *
                    num_tasks_75028);
        reduce_stage_1_tid_res_arr_mem_75029_cached_sizze_77284 = (int64_t) 8 *
            num_tasks_75028;
    }
    
    int64_t iter_75031;
    struct futhark_mc_segred_stage_1_parloop_struct_77285
    futhark_mc_segred_stage_1_parloop_struct_77285;
    
    futhark_mc_segred_stage_1_parloop_struct_77285.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_last_res_68608 =
        last_res_68608;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_mem_71004 =
        mem_71004.mem;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_mem_71010 =
        mem_71010.mem;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_min_res_74550 =
        min_res_74550;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_max_res_74615 =
        max_res_74615;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_defunc_1_f_res_74634 =
        defunc_1_f_res_74634;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_mem_74635 =
        mem_74635.mem;
    futhark_mc_segred_stage_1_parloop_struct_77285.free_reduce_stage_1_tid_res_arr_mem_75029 =
        reduce_stage_1_tid_res_arr_mem_75029;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77286_task;
    
    futhark_mc_segred_stage_1_parloop_77286_task.name =
        "futhark_mc_segred_stage_1_parloop_77286";
    futhark_mc_segred_stage_1_parloop_77286_task.fn =
        futhark_mc_segred_stage_1_parloop_77286;
    futhark_mc_segred_stage_1_parloop_77286_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77285;
    futhark_mc_segred_stage_1_parloop_77286_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77286_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77286_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77286_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77286_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77286_task);
    
    if (futhark_mc_segred_stage_1_parloop_77286_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77286_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77286_total_end -
                 futhark_mc_segred_stage_1_parloop_77286_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77286_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77286_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77286_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_74636 = 0.0;
    }
    
    double x_75033;
    double x_75034;
    
    for (int32_t i_75036 = 0; i_75036 < num_tasks_75028; i_75036++) {
        flat_tid_74986 = i_75036;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_75033 = defunc_2_reduce_res_74636;
            }
            // load next params
            {
                x_75034 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75029)[flat_tid_74986];
            }
            // red body
            {
                double defunc_1_op_res_75035 = x_75033 + x_75034;
                
                defunc_2_reduce_res_74636 = defunc_1_op_res_75035;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_75029);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77283_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77283_end -
                 futhark_mc_segred_task_77283_start;
        
        ctx->futhark_mc_segred_task_77283_runs[tid]++;
        ctx->futhark_mc_segred_task_77283_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77283_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77282->retval_defunc_2_reduce_res_74636 =
            defunc_2_reduce_res_74636;
        futhark_mc_task_77282->retval_mem_74635 = mem_74635.mem;
    }
    return err;
}
struct futhark_mc_task_77287 {
    struct futhark_context *ctx;
    int64_t free_last_res_68608;
    unsigned char *free_mem_71001;
    int64_t free_max_res_74615;
    unsigned char *free_mem_74635;
    double free_a0_74659;
    double *retval_defunc_2_reduce_res_74660;
};
struct futhark_mc_segred_stage_1_parloop_struct_77290 {
    struct futhark_context *ctx;
    int64_t free_last_res_68608;
    unsigned char *free_mem_71001;
    int64_t free_max_res_74615;
    unsigned char *free_mem_74635;
    double free_a0_74659;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75038;
};
static int futhark_mc_segred_stage_1_parloop_77291(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_75007, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77290
    *futhark_mc_segred_stage_1_parloop_struct_77290 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77290 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77290->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77291_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77291_start = get_wall_time();
    
    int64_t last_res_68608 =
            futhark_mc_segred_stage_1_parloop_struct_77290->free_last_res_68608;
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77290->free_mem_71001,
                                 .size =0, .references =NULL};
    int64_t max_res_74615 =
            futhark_mc_segred_stage_1_parloop_struct_77290->free_max_res_74615;
    struct memblock mem_74635 = {.desc ="mem_74635", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77290->free_mem_74635,
                                 .size =0, .references =NULL};
    double a0_74659 =
           futhark_mc_segred_stage_1_parloop_struct_77290->free_a0_74659;
    struct memblock reduce_stage_1_tid_res_arr_mem_75038 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75038",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77290->free_reduce_stage_1_tid_res_arr_mem_75038,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75040 = start;
    double x_75009;
    double x_75010;
    double local_acc_75041 = 0.0;
    
    for (; iter_75040 < end; iter_75040++) {
        int64_t gtid_75008 = iter_75040;
        double x_75012;
        
        x_75012 = ((double *) mem_74635.mem)[gtid_75008];
        
        bool cond_75013 = sle64(last_res_68608, gtid_75008);
        double defunc_0_f_res_75014;
        
        if (cond_75013) {
            defunc_0_f_res_75014 = 0.0;
        } else {
            int64_t i_75015 = add64(max_res_74615, gtid_75008);
            double defunc_0_add_arg_75016;
            
            defunc_0_add_arg_75016 = ((double *) mem_71001.mem)[i_75015];
            defunc_0_f_res_75014 = defunc_0_add_arg_75016;
        }
        
        double x_75017 = a0_74659 * x_75012;
        double defunc_9_fit_fun_res_75018 = defunc_0_f_res_75014 * x_75017;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_75009 = local_acc_75041;
        }
        // Load next params
        {
            x_75010 = defunc_9_fit_fun_res_75018;
        }
        // Red body
        {
            double defunc_1_op_res_75011 = x_75009 + x_75010;
            
            local_acc_75041 = defunc_1_op_res_75011;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_75038.mem)[flat_tid_75007] =
        local_acc_75041;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77291_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77291_end -
                 futhark_mc_segred_stage_1_parloop_77291_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77291_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77291_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77291_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77288(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75007 = tid;
    int num_tasks_75037 = info.nsubtasks;
    struct futhark_mc_task_77287 *futhark_mc_task_77287 =
                                 (struct futhark_mc_task_77287 *) args;
    struct futhark_context *ctx = futhark_mc_task_77287->ctx;
    uint64_t futhark_mc_segred_task_77288_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77288_start = get_wall_time();
    
    int64_t last_res_68608 = futhark_mc_task_77287->free_last_res_68608;
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_task_77287->free_mem_71001, .size =
                                 0, .references =NULL};
    int64_t max_res_74615 = futhark_mc_task_77287->free_max_res_74615;
    struct memblock mem_74635 = {.desc ="mem_74635", .mem =
                                 futhark_mc_task_77287->free_mem_74635, .size =
                                 0, .references =NULL};
    double a0_74659 = futhark_mc_task_77287->free_a0_74659;
    double defunc_2_reduce_res_74660 =
           *futhark_mc_task_77287->retval_defunc_2_reduce_res_74660;
    size_t reduce_stage_1_tid_res_arr_mem_75038_cached_sizze_77289 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75038 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_75038_cached_sizze_77289 <
        (size_t) ((int64_t) 8 * num_tasks_75037)) {
        reduce_stage_1_tid_res_arr_mem_75038 =
            realloc(reduce_stage_1_tid_res_arr_mem_75038, (int64_t) 8 *
                    num_tasks_75037);
        reduce_stage_1_tid_res_arr_mem_75038_cached_sizze_77289 = (int64_t) 8 *
            num_tasks_75037;
    }
    
    int64_t iter_75040;
    struct futhark_mc_segred_stage_1_parloop_struct_77290
    futhark_mc_segred_stage_1_parloop_struct_77290;
    
    futhark_mc_segred_stage_1_parloop_struct_77290.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77290.free_last_res_68608 =
        last_res_68608;
    futhark_mc_segred_stage_1_parloop_struct_77290.free_mem_71001 =
        mem_71001.mem;
    futhark_mc_segred_stage_1_parloop_struct_77290.free_max_res_74615 =
        max_res_74615;
    futhark_mc_segred_stage_1_parloop_struct_77290.free_mem_74635 =
        mem_74635.mem;
    futhark_mc_segred_stage_1_parloop_struct_77290.free_a0_74659 = a0_74659;
    futhark_mc_segred_stage_1_parloop_struct_77290.free_reduce_stage_1_tid_res_arr_mem_75038 =
        reduce_stage_1_tid_res_arr_mem_75038;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77291_task;
    
    futhark_mc_segred_stage_1_parloop_77291_task.name =
        "futhark_mc_segred_stage_1_parloop_77291";
    futhark_mc_segred_stage_1_parloop_77291_task.fn =
        futhark_mc_segred_stage_1_parloop_77291;
    futhark_mc_segred_stage_1_parloop_77291_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77290;
    futhark_mc_segred_stage_1_parloop_77291_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77291_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77291_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77291_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77291_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77291_task);
    
    if (futhark_mc_segred_stage_1_parloop_77291_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77291_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77291_total_end -
                 futhark_mc_segred_stage_1_parloop_77291_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77291_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77291_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77291_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_74660 = 0.0;
    }
    
    double x_75042;
    double x_75043;
    
    for (int32_t i_75045 = 0; i_75045 < num_tasks_75037; i_75045++) {
        flat_tid_75007 = i_75045;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_75042 = defunc_2_reduce_res_74660;
            }
            // load next params
            {
                x_75043 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75038)[flat_tid_75007];
            }
            // red body
            {
                double defunc_1_op_res_75044 = x_75042 + x_75043;
                
                defunc_2_reduce_res_74660 = defunc_1_op_res_75044;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_75038);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77288_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77288_end -
                 futhark_mc_segred_task_77288_start;
        
        ctx->futhark_mc_segred_task_77288_runs[tid]++;
        ctx->futhark_mc_segred_task_77288_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77288_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77287->retval_defunc_2_reduce_res_74660 =
            defunc_2_reduce_res_74660;
    }
    return err;
}
static int futhark_mc_segmap_parloop_77280(void *args, int64_t start,
                                           int64_t end, int flat_tid_74547,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77279
    *futhark_mc_segmap_parloop_struct_77279 =
    (struct futhark_mc_segmap_parloop_struct_77279 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77279->ctx;
    uint64_t futhark_mc_segmap_parloop_77280_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77280_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77279->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77279->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77279->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77279->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77279->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77279->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77279->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77279->free_loop_cond_65403;
    int64_t last_res_68608 =
            futhark_mc_segmap_parloop_struct_77279->free_last_res_68608;
    int64_t min_arg_68627 =
            futhark_mc_segmap_parloop_struct_77279->free_min_arg_68627;
    int64_t min_arg_68628 =
            futhark_mc_segmap_parloop_struct_77279->free_min_arg_68628;
    int64_t min_res_68629 =
            futhark_mc_segmap_parloop_struct_77279->free_min_res_68629;
    double max_res_68633 =
           futhark_mc_segmap_parloop_struct_77279->free_max_res_68633;
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_segmap_parloop_struct_77279->free_mem_71001,
                                 .size =0, .references =NULL};
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_segmap_parloop_struct_77279->free_mem_71004,
                                 .size =0, .references =NULL};
    struct memblock mem_71007 = {.desc ="mem_71007", .mem =
                                 futhark_mc_segmap_parloop_struct_77279->free_mem_71007,
                                 .size =0, .references =NULL};
    int64_t bytes_71009 =
            futhark_mc_segmap_parloop_struct_77279->free_bytes_71009;
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_segmap_parloop_struct_77279->free_mem_71010,
                                 .size =0, .references =NULL};
    struct memblock mem_71031 = {.desc ="mem_71031", .mem =
                                 futhark_mc_segmap_parloop_struct_77279->free_mem_71031,
                                 .size =0, .references =NULL};
    size_t mem_74635_cached_sizze_77281 = 0;
    unsigned char *mem_74635 = NULL;
    int64_t iterations = end - start;
    int64_t iter_74930 = start;
    
    if (mem_74635_cached_sizze_77281 < (size_t) bytes_71009) {
        mem_74635 = realloc(mem_74635, bytes_71009);
        mem_74635_cached_sizze_77281 = bytes_71009;
    }
    for (; iter_74930 < end; iter_74930++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75019 = n_m_65386;
        int64_t gtid_74548 = iter_74930;
        int64_t remnant_75020 = iter_74930 - gtid_74548;
        int64_t min_arg_74549 = mul64(jump_65382, gtid_74548);
        int64_t min_res_74550 = smin64(i_65392, min_arg_74549);
        int64_t defunc_0_g_res_74551 = add64((int64_t) 1, min_res_74550);
        bool init_idx_74552;
        int64_t init_idx_74553;
        int64_t init_idx_74554;
        bool loop_while_74931;
        int64_t low_74932;
        int64_t high_74933;
        
        loop_while_74931 = x_65393;
        low_74932 = (int64_t) 0;
        high_74933 = i_65392;
        while (loop_while_74931) {
            int64_t x_74934 = add64(low_74932, high_74933);
            int64_t mid_74935 = sdiv64(x_74934, (int64_t) 2);
            bool x_74936 = sle64((int64_t) 0, mid_74935);
            bool y_74937 = slt64(mid_74935, n_65378);
            bool bounds_check_74938 = x_74936 && y_74937;
            bool index_certs_74939;
            
            if (!bounds_check_74938) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_74935,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_74940;
            
            mid_id_74940 = ((int64_t *) mem_71007.mem)[mid_74935];
            
            bool cond_74941 = slt64(mid_id_74940, (int64_t) 0);
            int64_t mid_idx_74942;
            
            if (cond_74941) {
                mid_idx_74942 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_74942 = mid_id_74940;
            }
            
            bool cond_74943 = sle64(defunc_0_g_res_74551, mid_idx_74942);
            int64_t loopres_74944;
            int64_t loopres_74945;
            
            if (cond_74943) {
                int64_t loopres_t_res_74946 = sub64(mid_74935, (int64_t) 1);
                
                loopres_74944 = low_74932;
                loopres_74945 = loopres_t_res_74946;
            } else {
                int64_t loopres_f_res_74947 = add64((int64_t) 1, mid_74935);
                
                loopres_74944 = loopres_f_res_74947;
                loopres_74945 = high_74933;
            }
            
            bool loop_cond_74948 = sle64(loopres_74944, loopres_74945);
            bool loop_while_tmp_75021 = loop_cond_74948;
            int64_t low_tmp_75022 = loopres_74944;
            int64_t high_tmp_75023 = loopres_74945;
            
            loop_while_74931 = loop_while_tmp_75021;
            low_74932 = low_tmp_75022;
            high_74933 = high_tmp_75023;
        }
        init_idx_74552 = loop_while_74931;
        init_idx_74553 = low_74932;
        init_idx_74554 = high_74933;
        
        bool idx_74573;
        int64_t idx_74574;
        int64_t idx_74575;
        int64_t idx_74576;
        bool loop_while_74949;
        int64_t l_idx_74950;
        int64_t r_idx_74951;
        int64_t span_74952;
        
        loop_while_74949 = loop_cond_65403;
        l_idx_74950 = init_idx_74553;
        r_idx_74951 = init_idx_74553;
        span_74952 = (int64_t) 1;
        while (loop_while_74949) {
            int64_t max_arg_74953 = sub64(l_idx_74950, (int64_t) 1);
            int64_t max_res_74954 = smax64((int64_t) 0, max_arg_74953);
            int64_t min_arg_74955 = add64((int64_t) 1, r_idx_74951);
            int64_t min_res_74956 = smin64(min_arg_68627, min_arg_74955);
            bool x_74957 = sle64((int64_t) 0, max_res_74954);
            bool y_74958 = slt64(max_res_74954, n_65378);
            bool bounds_check_74959 = x_74957 && y_74958;
            bool index_certs_74960;
            
            if (!bounds_check_74959) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_74954,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74961;
            
            x_74961 = ((int64_t *) mem_71007.mem)[max_res_74954];
            
            int64_t abs_arg_74962 = sub64(x_74961, defunc_0_g_res_74551);
            int64_t abs_res_74963 = abs64(abs_arg_74962);
            bool x_74964 = sle64((int64_t) 0, min_res_74956);
            bool y_74965 = slt64(min_res_74956, n_65378);
            bool bounds_check_74966 = x_74964 && y_74965;
            bool index_certs_74967;
            
            if (!bounds_check_74966) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_74956,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_74968;
            
            x_74968 = ((int64_t *) mem_71007.mem)[min_res_74956];
            
            int64_t abs_arg_74969 = sub64(x_74968, defunc_0_g_res_74551);
            int64_t abs_res_74970 = abs64(abs_arg_74969);
            bool cond_74971 = max_res_74954 == l_idx_74950;
            int64_t loopres_74972;
            int64_t loopres_74973;
            int64_t loopres_74974;
            
            if (cond_74971) {
                loopres_74972 = l_idx_74950;
                loopres_74973 = r_idx_74951;
                loopres_74974 = min_res_65398;
            } else {
                bool cond_74975 = slt64(abs_res_74963, abs_res_74970);
                bool cond_f_res_74976 = min_res_74956 == r_idx_74951;
                bool x_74977 = !cond_74975;
                bool y_74978 = cond_f_res_74976 && x_74977;
                bool cond_74979 = cond_74975 || y_74978;
                int64_t loopres_f_res_74980;
                
                if (cond_74979) {
                    loopres_f_res_74980 = max_res_74954;
                } else {
                    loopres_f_res_74980 = l_idx_74950;
                }
                
                int64_t loopres_f_res_74981;
                
                if (cond_74979) {
                    loopres_f_res_74981 = r_idx_74951;
                } else {
                    loopres_f_res_74981 = min_res_74956;
                }
                
                int64_t loopres_f_res_74982;
                
                if (cond_74979) {
                    int64_t loopres_f_res_t_res_74983 = add64((int64_t) 1,
                                                              span_74952);
                    
                    loopres_f_res_74982 = loopres_f_res_t_res_74983;
                } else {
                    int64_t loopres_f_res_f_res_74984 = add64((int64_t) 1,
                                                              span_74952);
                    
                    loopres_f_res_74982 = loopres_f_res_f_res_74984;
                }
                loopres_74972 = loopres_f_res_74980;
                loopres_74973 = loopres_f_res_74981;
                loopres_74974 = loopres_f_res_74982;
            }
            
            bool loop_cond_74985 = slt64(loopres_74974, min_res_65398);
            bool loop_while_tmp_75024 = loop_cond_74985;
            int64_t l_idx_tmp_75025 = loopres_74972;
            int64_t r_idx_tmp_75026 = loopres_74973;
            int64_t span_tmp_75027 = loopres_74974;
            
            loop_while_74949 = loop_while_tmp_75024;
            l_idx_74950 = l_idx_tmp_75025;
            r_idx_74951 = r_idx_tmp_75026;
            span_74952 = span_tmp_75027;
        }
        idx_74573 = loop_while_74949;
        idx_74574 = l_idx_74950;
        idx_74575 = r_idx_74951;
        idx_74576 = span_74952;
        
        int64_t min_res_74614 = smin64(min_arg_68628, idx_74574);
        int64_t max_res_74615 = smax64((int64_t) 0, min_res_74614);
        int64_t x_74616 = add64(min_res_68629, max_res_74615);
        int64_t r_74617 = sub64(x_74616, (int64_t) 1);
        bool x_74618 = sle64((int64_t) 0, r_74617);
        bool y_74619 = slt64(r_74617, n_65378);
        bool bounds_check_74620 = x_74618 && y_74619;
        bool index_certs_74621;
        
        if (!bounds_check_74620) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_74617,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_74622;
        
        x_74622 = ((int64_t *) mem_71004.mem)[r_74617];
        
        int64_t abs_arg_74623 = sub64(x_74622, min_res_74550);
        int64_t abs_res_74624 = abs64(abs_arg_74623);
        bool x_74625 = sle64((int64_t) 0, max_res_74615);
        bool y_74626 = slt64(max_res_74615, n_65378);
        bool bounds_check_74627 = x_74625 && y_74626;
        bool index_certs_74628;
        
        if (!bounds_check_74627) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_74615,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_74629;
        
        x_74629 = ((int64_t *) mem_71004.mem)[max_res_74615];
        
        int64_t abs_arg_74630 = sub64(x_74629, min_res_74550);
        int64_t abs_res_74631 = abs64(abs_arg_74630);
        int64_t max_res_74632 = smax64(abs_res_74624, abs_res_74631);
        double defunc_0_f_res_74633 = sitofp_i64_f64(max_res_74632);
        double defunc_1_f_res_74634 = max_res_68633 + defunc_0_f_res_74633;
        double defunc_2_reduce_res_74636;
        int64_t flat_tid_74986 = (int64_t) 0;
        int32_t num_tasks_75028;
        
        defunc_2_reduce_res_74636 = 0.0;
        
        struct futhark_mc_task_77282 futhark_mc_task_77282;
        
        futhark_mc_task_77282.ctx = ctx;
        futhark_mc_task_77282.free_last_res_68608 = last_res_68608;
        futhark_mc_task_77282.free_mem_71004 = mem_71004.mem;
        futhark_mc_task_77282.free_mem_71010 = mem_71010.mem;
        futhark_mc_task_77282.free_min_res_74550 = min_res_74550;
        futhark_mc_task_77282.free_max_res_74615 = max_res_74615;
        futhark_mc_task_77282.free_defunc_1_f_res_74634 = defunc_1_f_res_74634;
        futhark_mc_task_77282.retval_defunc_2_reduce_res_74636 =
            &defunc_2_reduce_res_74636;
        futhark_mc_task_77282.retval_mem_74635 = mem_74635;
        
        struct scheduler_segop futhark_mc_task_77282_task;
        
        futhark_mc_task_77282_task.args = &futhark_mc_task_77282;
        futhark_mc_task_77282_task.top_level_fn = futhark_mc_segred_task_77283;
        futhark_mc_task_77282_task.name = "futhark_mc_segred_task_77283";
        futhark_mc_task_77282_task.iterations = q_65380;
        futhark_mc_task_77282_task.task_time =
            &ctx->futhark_mc_segred_task_77283_total_time;
        futhark_mc_task_77282_task.task_iter =
            &ctx->futhark_mc_segred_task_77283_total_iter;
        futhark_mc_task_77282_task.sched = STATIC;
        futhark_mc_task_77282_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77283_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77282_task);
        
        if (futhark_mc_segred_task_77283_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double a0_74659 = 1.0 / defunc_2_reduce_res_74636;
        double defunc_2_reduce_res_74660;
        int64_t flat_tid_75007 = (int64_t) 0;
        int32_t num_tasks_75037;
        
        defunc_2_reduce_res_74660 = 0.0;
        
        struct futhark_mc_task_77287 futhark_mc_task_77287;
        
        futhark_mc_task_77287.ctx = ctx;
        futhark_mc_task_77287.free_last_res_68608 = last_res_68608;
        futhark_mc_task_77287.free_mem_71001 = mem_71001.mem;
        futhark_mc_task_77287.free_max_res_74615 = max_res_74615;
        futhark_mc_task_77287.free_mem_74635 = mem_74635;
        futhark_mc_task_77287.free_a0_74659 = a0_74659;
        futhark_mc_task_77287.retval_defunc_2_reduce_res_74660 =
            &defunc_2_reduce_res_74660;
        
        struct scheduler_segop futhark_mc_task_77287_task;
        
        futhark_mc_task_77287_task.args = &futhark_mc_task_77287;
        futhark_mc_task_77287_task.top_level_fn = futhark_mc_segred_task_77288;
        futhark_mc_task_77287_task.name = "futhark_mc_segred_task_77288";
        futhark_mc_task_77287_task.iterations = q_65380;
        futhark_mc_task_77287_task.task_time =
            &ctx->futhark_mc_segred_task_77288_total_time;
        futhark_mc_task_77287_task.task_iter =
            &ctx->futhark_mc_segred_task_77288_total_iter;
        futhark_mc_task_77287_task.sched = STATIC;
        futhark_mc_task_77287_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77288_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77287_task);
        
        if (futhark_mc_segred_task_77288_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        ((double *) mem_71031.mem)[gtid_74548] = defunc_2_reduce_res_74660;
    }
    
  cleanup:
    { }
    free(mem_74635);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77280_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77280_end -
                 futhark_mc_segmap_parloop_77280_start;
        
        ctx->futhark_mc_segmap_parloop_77280_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77280_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77280_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77278(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_74547 = tid;
    int num_tasks_74830 = info.nsubtasks;
    struct futhark_mc_task_77273 *futhark_mc_task_77273 =
                                 (struct futhark_mc_task_77273 *) args;
    struct futhark_context *ctx = futhark_mc_task_77273->ctx;
    uint64_t futhark_mc_segmap_nested_task_77278_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77278_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77273->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77273->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77273->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77273->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77273->free_i_65392;
    bool x_65393 = futhark_mc_task_77273->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77273->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77273->free_loop_cond_65403;
    int64_t last_res_68608 = futhark_mc_task_77273->free_last_res_68608;
    int64_t min_arg_68627 = futhark_mc_task_77273->free_min_arg_68627;
    int64_t min_arg_68628 = futhark_mc_task_77273->free_min_arg_68628;
    int64_t min_res_68629 = futhark_mc_task_77273->free_min_res_68629;
    double max_res_68633 = futhark_mc_task_77273->free_max_res_68633;
    struct memblock mem_71001 = {.desc ="mem_71001", .mem =
                                 futhark_mc_task_77273->free_mem_71001, .size =
                                 0, .references =NULL};
    struct memblock mem_71004 = {.desc ="mem_71004", .mem =
                                 futhark_mc_task_77273->free_mem_71004, .size =
                                 0, .references =NULL};
    struct memblock mem_71007 = {.desc ="mem_71007", .mem =
                                 futhark_mc_task_77273->free_mem_71007, .size =
                                 0, .references =NULL};
    int64_t bytes_71009 = futhark_mc_task_77273->free_bytes_71009;
    struct memblock mem_71010 = {.desc ="mem_71010", .mem =
                                 futhark_mc_task_77273->free_mem_71010, .size =
                                 0, .references =NULL};
    struct memblock mem_71031 = {.desc ="mem_71031", .mem =
                                 futhark_mc_task_77273->free_mem_71031, .size =
                                 0, .references =NULL};
    int64_t iter_74930;
    struct futhark_mc_segmap_parloop_struct_77279
    futhark_mc_segmap_parloop_struct_77279;
    
    futhark_mc_segmap_parloop_struct_77279.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77279.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77279.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77279.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77279.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77279.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77279.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77279.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77279.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77279.free_last_res_68608 = last_res_68608;
    futhark_mc_segmap_parloop_struct_77279.free_min_arg_68627 = min_arg_68627;
    futhark_mc_segmap_parloop_struct_77279.free_min_arg_68628 = min_arg_68628;
    futhark_mc_segmap_parloop_struct_77279.free_min_res_68629 = min_res_68629;
    futhark_mc_segmap_parloop_struct_77279.free_max_res_68633 = max_res_68633;
    futhark_mc_segmap_parloop_struct_77279.free_mem_71001 = mem_71001.mem;
    futhark_mc_segmap_parloop_struct_77279.free_mem_71004 = mem_71004.mem;
    futhark_mc_segmap_parloop_struct_77279.free_mem_71007 = mem_71007.mem;
    futhark_mc_segmap_parloop_struct_77279.free_bytes_71009 = bytes_71009;
    futhark_mc_segmap_parloop_struct_77279.free_mem_71010 = mem_71010.mem;
    futhark_mc_segmap_parloop_struct_77279.free_mem_71031 = mem_71031.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77280_task;
    
    futhark_mc_segmap_parloop_77280_task.name =
        "futhark_mc_segmap_parloop_77280";
    futhark_mc_segmap_parloop_77280_task.fn = futhark_mc_segmap_parloop_77280;
    futhark_mc_segmap_parloop_77280_task.args =
        &futhark_mc_segmap_parloop_struct_77279;
    futhark_mc_segmap_parloop_77280_task.iterations = iterations;
    futhark_mc_segmap_parloop_77280_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77280_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77280_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77280_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77280_task);
    
    if (futhark_mc_segmap_parloop_77280_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77280_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77280_total_end -
                 futhark_mc_segmap_parloop_77280_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77280_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77280_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77280_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77278_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77278_end -
                 futhark_mc_segmap_nested_task_77278_start;
        
        ctx->futhark_mc_segmap_nested_task_77278_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77278_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77278_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77247(void *args, int64_t start,
                                           int64_t end, int flat_tid_68595,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77246
    *futhark_mc_segmap_parloop_struct_77246 =
    (struct futhark_mc_segmap_parloop_struct_77246 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77246->ctx;
    uint64_t futhark_mc_segmap_parloop_77247_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77247_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77246->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77246->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77246->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77246->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77246->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77246->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77246->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77246->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77246->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77246->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77246->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70997 =
            futhark_mc_segmap_parloop_struct_77246->free_bytes_70997;
    int64_t bytes_71009 =
            futhark_mc_segmap_parloop_struct_77246->free_bytes_71009;
    int64_t bytes_71030 =
            futhark_mc_segmap_parloop_struct_77246->free_bytes_71030;
    struct memblock mem_71140 = {.desc ="mem_71140", .mem =
                                 futhark_mc_segmap_parloop_struct_77246->free_mem_71140,
                                 .size =0, .references =NULL};
    size_t mem_70998_cached_sizze_77248 = 0;
    unsigned char *mem_70998 = NULL;
    size_t mem_71001_cached_sizze_77249 = 0;
    unsigned char *mem_71001 = NULL;
    size_t mem_71004_cached_sizze_77250 = 0;
    unsigned char *mem_71004 = NULL;
    size_t mem_71007_cached_sizze_77251 = 0;
    unsigned char *mem_71007 = NULL;
    size_t mem_71010_cached_sizze_77252 = 0;
    unsigned char *mem_71010 = NULL;
    size_t mem_71031_cached_sizze_77253 = 0;
    unsigned char *mem_71031 = NULL;
    int64_t iterations = end - start;
    int64_t iter_74521 = start;
    
    if (mem_70998_cached_sizze_77248 < (size_t) bytes_70997) {
        mem_70998 = realloc(mem_70998, bytes_70997);
        mem_70998_cached_sizze_77248 = bytes_70997;
    }
    if (mem_71001_cached_sizze_77249 < (size_t) bytes_70997) {
        mem_71001 = realloc(mem_71001, bytes_70997);
        mem_71001_cached_sizze_77249 = bytes_70997;
    }
    if (mem_71004_cached_sizze_77250 < (size_t) bytes_70997) {
        mem_71004 = realloc(mem_71004, bytes_70997);
        mem_71004_cached_sizze_77250 = bytes_70997;
    }
    if (mem_71007_cached_sizze_77251 < (size_t) bytes_70997) {
        mem_71007 = realloc(mem_71007, bytes_70997);
        mem_71007_cached_sizze_77251 = bytes_70997;
    }
    if (mem_71010_cached_sizze_77252 < (size_t) bytes_71009) {
        mem_71010 = realloc(mem_71010, bytes_71009);
        mem_71010_cached_sizze_77252 = bytes_71009;
    }
    if (mem_71031_cached_sizze_77253 < (size_t) bytes_71030) {
        mem_71031 = realloc(mem_71031, bytes_71030);
        mem_71031_cached_sizze_77253 = bytes_71030;
    }
    for (; iter_74521 < end; iter_74521++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_74798 = m_65377;
        int64_t gtid_68596 = iter_74521;
        int64_t remnant_74799 = iter_74521 - gtid_68596;
        int64_t flat_tid_74522 = (int64_t) 0;
        int32_t num_tasks_74800;
        
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmented segScan");
        
        struct futhark_mc_task_77254 futhark_mc_task_77254;
        
        futhark_mc_task_77254.ctx = ctx;
        futhark_mc_task_77254.free_n_65378 = n_65378;
        futhark_mc_task_77254.free_gtid_68596 = gtid_68596;
        futhark_mc_task_77254.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77254.free_mem_70998 = mem_70998;
        
        struct scheduler_segop futhark_mc_task_77254_task;
        
        futhark_mc_task_77254_task.args = &futhark_mc_task_77254;
        futhark_mc_task_77254_task.top_level_fn = futhark_mc_segscan_task_77255;
        futhark_mc_task_77254_task.name = "futhark_mc_segscan_task_77255";
        futhark_mc_task_77254_task.iterations = n_65378;
        futhark_mc_task_77254_task.task_time =
            &ctx->futhark_mc_segscan_task_77255_total_time;
        futhark_mc_task_77254_task.task_iter =
            &ctx->futhark_mc_segscan_task_77255_total_iter;
        futhark_mc_task_77254_task.sched = STATIC;
        futhark_mc_task_77254_task.nested_fn = NULL;
        
        int futhark_mc_segscan_task_77255_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77254_task);
        
        if (futhark_mc_segscan_task_77255_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t last_res_68608;
        
        last_res_68608 = ((int64_t *) mem_70998)[i_65392];
        for (int64_t i_74814 = 0; i_74814 < n_65378; i_74814++) {
            ((double *) mem_71001)[i_74814] = 0.0;
        }
        for (int64_t i_74815 = 0; i_74815 < n_65378; i_74815++) {
            ((int64_t *) mem_71004)[i_74815] = (int64_t) -1;
        }
        
        int64_t flat_tid_74531 = (int64_t) 0;
        int32_t num_tasks_74816;
        struct futhark_mc_task_77261 futhark_mc_task_77261;
        
        futhark_mc_task_77261.ctx = ctx;
        futhark_mc_task_77261.free_n_65378 = n_65378;
        futhark_mc_task_77261.free_gtid_68596 = gtid_68596;
        futhark_mc_task_77261.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77261.free_mem_70998 = mem_70998;
        futhark_mc_task_77261.free_mem_71001 = mem_71001;
        futhark_mc_task_77261.free_mem_71004 = mem_71004;
        
        struct scheduler_segop futhark_mc_task_77261_task;
        
        futhark_mc_task_77261_task.args = &futhark_mc_task_77261;
        futhark_mc_task_77261_task.top_level_fn = futhark_mc_segmap_task_77262;
        futhark_mc_task_77261_task.name = "futhark_mc_segmap_task_77262";
        futhark_mc_task_77261_task.iterations = n_65378;
        futhark_mc_task_77261_task.task_time =
            &ctx->futhark_mc_segmap_task_77262_total_time;
        futhark_mc_task_77261_task.task_iter =
            &ctx->futhark_mc_segmap_task_77262_total_iter;
        futhark_mc_task_77261_task.sched = STATIC;
        futhark_mc_task_77261_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77262_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77261_task);
        
        if (futhark_mc_segmap_task_77262_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_74539 = (int64_t) 0;
        int32_t num_tasks_74822;
        struct futhark_mc_task_77265 futhark_mc_task_77265;
        
        futhark_mc_task_77265.ctx = ctx;
        futhark_mc_task_77265.free_n_65378 = n_65378;
        futhark_mc_task_77265.free_mem_71004 = mem_71004;
        futhark_mc_task_77265.free_mem_71007 = mem_71007;
        
        struct scheduler_segop futhark_mc_task_77265_task;
        
        futhark_mc_task_77265_task.args = &futhark_mc_task_77265;
        futhark_mc_task_77265_task.top_level_fn = futhark_mc_segmap_task_77266;
        futhark_mc_task_77265_task.name = "futhark_mc_segmap_task_77266";
        futhark_mc_task_77265_task.iterations = n_65378;
        futhark_mc_task_77265_task.task_time =
            &ctx->futhark_mc_segmap_task_77266_total_time;
        futhark_mc_task_77265_task.task_iter =
            &ctx->futhark_mc_segmap_task_77266_total_iter;
        futhark_mc_task_77265_task.sched = STATIC;
        futhark_mc_task_77265_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77266_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77265_task);
        
        if (futhark_mc_segmap_task_77266_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t min_arg_68627 = sub64(last_res_68608, (int64_t) 1);
        int64_t min_arg_68628 = sub64(last_res_68608, min_res_65398);
        int64_t min_res_68629 = smin64(q_65380, last_res_68608);
        double i64_res_68630 = sitofp_i64_f64(last_res_68608);
        double x_68631 = i64_res_65404 - i64_res_68630;
        double max_arg_68632 = x_68631 / 2.0;
        double max_res_68633 = fmax64(0.0, max_arg_68632);
        int64_t flat_tid_74543 = (int64_t) 0;
        int32_t num_tasks_74826;
        struct futhark_mc_task_77269 futhark_mc_task_77269;
        
        futhark_mc_task_77269.ctx = ctx;
        futhark_mc_task_77269.free_q_65380 = q_65380;
        futhark_mc_task_77269.free_last_res_68608 = last_res_68608;
        futhark_mc_task_77269.free_mem_71010 = mem_71010;
        
        struct scheduler_segop futhark_mc_task_77269_task;
        
        futhark_mc_task_77269_task.args = &futhark_mc_task_77269;
        futhark_mc_task_77269_task.top_level_fn = futhark_mc_segmap_task_77270;
        futhark_mc_task_77269_task.name = "futhark_mc_segmap_task_77270";
        futhark_mc_task_77269_task.iterations = q_65380;
        futhark_mc_task_77269_task.task_time =
            &ctx->futhark_mc_segmap_task_77270_total_time;
        futhark_mc_task_77269_task.task_iter =
            &ctx->futhark_mc_segmap_task_77270_total_iter;
        futhark_mc_task_77269_task.sched = STATIC;
        futhark_mc_task_77269_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77270_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77269_task);
        
        if (futhark_mc_segmap_task_77270_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_74673 = (int64_t) 0;
        int32_t num_tasks_74830;
        int64_t flat_tid_74547 = (int64_t) 0;
        struct futhark_mc_task_77273 futhark_mc_task_77273;
        
        futhark_mc_task_77273.ctx = ctx;
        futhark_mc_task_77273.free_n_65378 = n_65378;
        futhark_mc_task_77273.free_q_65380 = q_65380;
        futhark_mc_task_77273.free_jump_65382 = jump_65382;
        futhark_mc_task_77273.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77273.free_i_65392 = i_65392;
        futhark_mc_task_77273.free_x_65393 = x_65393;
        futhark_mc_task_77273.free_min_res_65398 = min_res_65398;
        futhark_mc_task_77273.free_loop_cond_65403 = loop_cond_65403;
        futhark_mc_task_77273.free_last_res_68608 = last_res_68608;
        futhark_mc_task_77273.free_min_arg_68627 = min_arg_68627;
        futhark_mc_task_77273.free_min_arg_68628 = min_arg_68628;
        futhark_mc_task_77273.free_min_res_68629 = min_res_68629;
        futhark_mc_task_77273.free_max_res_68633 = max_res_68633;
        futhark_mc_task_77273.free_mem_71001 = mem_71001;
        futhark_mc_task_77273.free_mem_71004 = mem_71004;
        futhark_mc_task_77273.free_mem_71007 = mem_71007;
        futhark_mc_task_77273.free_bytes_71009 = bytes_71009;
        futhark_mc_task_77273.free_mem_71010 = mem_71010;
        futhark_mc_task_77273.free_mem_71031 = mem_71031;
        
        struct scheduler_segop futhark_mc_task_77273_task;
        
        futhark_mc_task_77273_task.args = &futhark_mc_task_77273;
        futhark_mc_task_77273_task.top_level_fn = futhark_mc_segmap_task_77274;
        futhark_mc_task_77273_task.name = "futhark_mc_segmap_task_77274";
        futhark_mc_task_77273_task.iterations = n_m_65386;
        futhark_mc_task_77273_task.task_time =
            &ctx->futhark_mc_segmap_task_77274_total_time;
        futhark_mc_task_77273_task.task_iter =
            &ctx->futhark_mc_segmap_task_77274_total_iter;
        futhark_mc_task_77273_task.sched = DYNAMIC;
        futhark_mc_task_77273_task.nested_fn =
            futhark_mc_segmap_nested_task_77278;
        
        int futhark_mc_segmap_task_77274_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77273_task);
        
        if (futhark_mc_segmap_task_77274_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71140.mem + gtid_68596 * n_m_65386 * (int64_t) 8,
                    mem_71031 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_70998);
    free(mem_71001);
    free(mem_71004);
    free(mem_71007);
    free(mem_71010);
    free(mem_71031);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77247_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77247_end -
                 futhark_mc_segmap_parloop_77247_start;
        
        ctx->futhark_mc_segmap_parloop_77247_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77247_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77247_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77245(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_68595 = tid;
    int num_tasks_74342 = info.nsubtasks;
    struct futhark_mc_task_77234 *futhark_mc_task_77234 =
                                 (struct futhark_mc_task_77234 *) args;
    struct futhark_context *ctx = futhark_mc_task_77234->ctx;
    uint64_t futhark_mc_segmap_nested_task_77245_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77245_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77234->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77234->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77234->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77234->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77234->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77234->free_i_65392;
    bool x_65393 = futhark_mc_task_77234->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77234->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77234->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77234->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77234->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_70997 = futhark_mc_task_77234->free_bytes_70997;
    int64_t bytes_71009 = futhark_mc_task_77234->free_bytes_71009;
    int64_t bytes_71030 = futhark_mc_task_77234->free_bytes_71030;
    struct memblock mem_71140 = {.desc ="mem_71140", .mem =
                                 futhark_mc_task_77234->free_mem_71140, .size =
                                 0, .references =NULL};
    int64_t iter_74521;
    struct futhark_mc_segmap_parloop_struct_77246
    futhark_mc_segmap_parloop_struct_77246;
    
    futhark_mc_segmap_parloop_struct_77246.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77246.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77246.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77246.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77246.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77246.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77246.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77246.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77246.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77246.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77246.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77246.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77246.free_bytes_70997 = bytes_70997;
    futhark_mc_segmap_parloop_struct_77246.free_bytes_71009 = bytes_71009;
    futhark_mc_segmap_parloop_struct_77246.free_bytes_71030 = bytes_71030;
    futhark_mc_segmap_parloop_struct_77246.free_mem_71140 = mem_71140.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77247_task;
    
    futhark_mc_segmap_parloop_77247_task.name =
        "futhark_mc_segmap_parloop_77247";
    futhark_mc_segmap_parloop_77247_task.fn = futhark_mc_segmap_parloop_77247;
    futhark_mc_segmap_parloop_77247_task.args =
        &futhark_mc_segmap_parloop_struct_77246;
    futhark_mc_segmap_parloop_77247_task.iterations = iterations;
    futhark_mc_segmap_parloop_77247_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77247_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77247_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77247_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77247_task);
    
    if (futhark_mc_segmap_parloop_77247_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77247_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77247_total_end -
                 futhark_mc_segmap_parloop_77247_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77247_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77247_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77247_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77245_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77245_end -
                 futhark_mc_segmap_nested_task_77245_start;
        
        ctx->futhark_mc_segmap_nested_task_77245_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77245_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77245_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77292 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_71142;
    int64_t free_bytes_71154;
    int64_t free_bytes_71193;
    unsigned char *free_mem_71336;
    unsigned char *free_mem_71340;
};
struct futhark_mc_segmap_parloop_struct_77294 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_71142;
    int64_t free_bytes_71154;
    int64_t free_bytes_71193;
    unsigned char *free_mem_71336;
    unsigned char *free_mem_71340;
};
static int futhark_mc_segmap_parloop_77295(void *args, int64_t start,
                                           int64_t end, int flat_tid_68893,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77294
    *futhark_mc_segmap_parloop_struct_77294 =
    (struct futhark_mc_segmap_parloop_struct_77294 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77294->ctx;
    uint64_t futhark_mc_segmap_parloop_77295_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77295_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77294->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77294->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77294->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77294->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77294->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77294->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77294->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77294->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77294->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77294->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77294->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71142 =
            futhark_mc_segmap_parloop_struct_77294->free_bytes_71142;
    int64_t bytes_71154 =
            futhark_mc_segmap_parloop_struct_77294->free_bytes_71154;
    int64_t bytes_71193 =
            futhark_mc_segmap_parloop_struct_77294->free_bytes_71193;
    struct memblock mem_71336 = {.desc ="mem_71336", .mem =
                                 futhark_mc_segmap_parloop_struct_77294->free_mem_71336,
                                 .size =0, .references =NULL};
    struct memblock mem_71340 = {.desc ="mem_71340", .mem =
                                 futhark_mc_segmap_parloop_struct_77294->free_mem_71340,
                                 .size =0, .references =NULL};
    size_t mem_71200_cached_sizze_77296 = 0;
    unsigned char *mem_71200 = NULL;
    size_t mem_71215_cached_sizze_77297 = 0;
    unsigned char *mem_71215 = NULL;
    size_t mem_71218_cached_sizze_77298 = 0;
    unsigned char *mem_71218 = NULL;
    size_t mem_71245_cached_sizze_77299 = 0;
    unsigned char *mem_71245 = NULL;
    size_t mem_71260_cached_sizze_77300 = 0;
    unsigned char *mem_71260 = NULL;
    size_t mem_71275_cached_sizze_77301 = 0;
    unsigned char *mem_71275 = NULL;
    size_t mem_71278_cached_sizze_77302 = 0;
    unsigned char *mem_71278 = NULL;
    size_t mem_71295_cached_sizze_77303 = 0;
    unsigned char *mem_71295 = NULL;
    size_t mem_71298_cached_sizze_77304 = 0;
    unsigned char *mem_71298 = NULL;
    int64_t iterations = end - start;
    int64_t iter_75047 = start;
    
    if (mem_71200_cached_sizze_77296 < (size_t) bytes_71142) {
        mem_71200 = realloc(mem_71200, bytes_71142);
        mem_71200_cached_sizze_77296 = bytes_71142;
    }
    if (mem_71215_cached_sizze_77297 < (size_t) bytes_71142) {
        mem_71215 = realloc(mem_71215, bytes_71142);
        mem_71215_cached_sizze_77297 = bytes_71142;
    }
    if (mem_71218_cached_sizze_77298 < (size_t) bytes_71142) {
        mem_71218 = realloc(mem_71218, bytes_71142);
        mem_71218_cached_sizze_77298 = bytes_71142;
    }
    if (mem_71245_cached_sizze_77299 < (size_t) bytes_71142) {
        mem_71245 = realloc(mem_71245, bytes_71142);
        mem_71245_cached_sizze_77299 = bytes_71142;
    }
    if (mem_71260_cached_sizze_77300 < (size_t) bytes_71154) {
        mem_71260 = realloc(mem_71260, bytes_71154);
        mem_71260_cached_sizze_77300 = bytes_71154;
    }
    if (mem_71275_cached_sizze_77301 < (size_t) bytes_71193) {
        mem_71275 = realloc(mem_71275, bytes_71193);
        mem_71275_cached_sizze_77301 = bytes_71193;
    }
    if (mem_71278_cached_sizze_77302 < (size_t) bytes_71193) {
        mem_71278 = realloc(mem_71278, bytes_71193);
        mem_71278_cached_sizze_77302 = bytes_71193;
    }
    if (mem_71295_cached_sizze_77303 < (size_t) bytes_71154) {
        mem_71295 = realloc(mem_71295, bytes_71154);
        mem_71295_cached_sizze_77303 = bytes_71154;
    }
    if (mem_71298_cached_sizze_77304 < (size_t) bytes_71154) {
        mem_71298 = realloc(mem_71298, bytes_71154);
        mem_71298_cached_sizze_77304 = bytes_71154;
    }
    for (; iter_75047 < end; iter_75047++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75235 = m_65377;
        int64_t gtid_68894 = iter_75047;
        int64_t remnant_75236 = iter_75047 - gtid_68894;
        int64_t discard_70391;
        int64_t scanacc_75049 = (int64_t) 0;
        
        for (int64_t i_75048 = 0; i_75048 < n_65378; i_75048++) {
            double x_75051;
            
            x_75051 = ((double *) Y_mem_70603.mem)[gtid_68894 * n_65378 +
                                                   i_75048];
            
            bool isnan_res_75052;
            
            isnan_res_75052 = futrts_isnan64(x_75051);
            
            bool defunc_0_p_res_75053 = !isnan_res_75052;
            int64_t defunc_0_f_res_75054 = btoi_bool_i64(defunc_0_p_res_75053);
            int64_t defunc_1_op_res_75055 = add64(defunc_0_f_res_75054,
                                                  scanacc_75049);
            
            ((int64_t *) mem_71200)[i_75048] = defunc_1_op_res_75055;
            
            int64_t scanacc_tmp_75237 = defunc_1_op_res_75055;
            
            scanacc_75049 = scanacc_tmp_75237;
        }
        discard_70391 = scanacc_75049;
        
        int64_t last_res_66217;
        
        last_res_66217 = ((int64_t *) mem_71200)[i_65392];
        for (int64_t i_75239 = 0; i_75239 < n_65378; i_75239++) {
            ((double *) mem_71215)[i_75239] = 0.0;
        }
        for (int64_t i_75240 = 0; i_75240 < n_65378; i_75240++) {
            ((int64_t *) mem_71218)[i_75240] = (int64_t) -1;
        }
        for (int64_t write_iter_75057 = 0; write_iter_75057 < n_65378;
             write_iter_75057++) {
            double write_iv_75060;
            
            write_iv_75060 = ((double *) Y_mem_70603.mem)[gtid_68894 * n_65378 +
                                                          write_iter_75057];
            
            bool isnan_res_75061;
            
            isnan_res_75061 = futrts_isnan64(write_iv_75060);
            
            bool defunc_0_p_res_75062 = !isnan_res_75061;
            int64_t defunc_1_f_res_75063;
            
            if (defunc_0_p_res_75062) {
                int64_t write_iv_75064;
                
                write_iv_75064 = ((int64_t *) mem_71200)[write_iter_75057];
                
                int64_t defunc_1_f_res_t_res_75065 = sub64(write_iv_75064,
                                                           (int64_t) 1);
                
                defunc_1_f_res_75063 = defunc_1_f_res_t_res_75065;
            } else {
                defunc_1_f_res_75063 = (int64_t) -1;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_75063) &&
                slt64(defunc_1_f_res_75063, n_65378)) {
                ((int64_t *) mem_71218)[defunc_1_f_res_75063] =
                    write_iter_75057;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_75063) &&
                slt64(defunc_1_f_res_75063, n_65378)) {
                if ((int64_t) 8 > 0)
                    memmove(mem_71215 + defunc_1_f_res_75063 * (int64_t) 8,
                            Y_mem_70603.mem + (gtid_68894 * n_65378 +
                                               write_iter_75057) * (int64_t) 8,
                            (int64_t) 8);
            }
        }
        for (int64_t i_75069 = 0; i_75069 < n_65378; i_75069++) {
            int64_t x_75071;
            
            x_75071 = ((int64_t *) mem_71218)[i_75069];
            
            int64_t defunc_0_f_res_75072 = add64((int64_t) 1, x_75071);
            
            ((int64_t *) mem_71245)[i_75069] = defunc_0_f_res_75072;
        }
        
        int64_t min_arg_66232 = sub64(last_res_66217, (int64_t) 1);
        int64_t min_arg_66233 = sub64(last_res_66217, min_res_65398);
        int64_t min_res_66234 = smin64(q_65380, last_res_66217);
        double i64_res_66235 = sitofp_i64_f64(last_res_66217);
        double x_66236 = i64_res_65404 - i64_res_66235;
        double max_arg_66237 = x_66236 / 2.0;
        double max_res_66238 = fmax64(0.0, max_arg_66237);
        
        for (int64_t i_75074 = 0; i_75074 < q_65380; i_75074++) {
            bool cond_75076 = sle64(last_res_66217, i_75074);
            double defunc_0_f_res_75077;
            
            if (cond_75076) {
                defunc_0_f_res_75077 = 0.0;
            } else {
                defunc_0_f_res_75077 = 1.0;
            }
            ((double *) mem_71260)[i_75074] = defunc_0_f_res_75077;
        }
        for (int64_t i_75079 = 0; i_75079 < n_m_65386; i_75079++) {
            int64_t min_arg_75082 = mul64(jump_65382, i_75079);
            int64_t min_res_75083 = smin64(i_65392, min_arg_75082);
            int64_t defunc_0_g_res_75084 = add64((int64_t) 1, min_res_75083);
            bool init_idx_75085;
            int64_t init_idx_75086;
            int64_t init_idx_75087;
            bool loop_while_75088;
            int64_t low_75089;
            int64_t high_75090;
            
            loop_while_75088 = x_65393;
            low_75089 = (int64_t) 0;
            high_75090 = i_65392;
            while (loop_while_75088) {
                int64_t x_75091 = add64(low_75089, high_75090);
                int64_t mid_75092 = sdiv64(x_75091, (int64_t) 2);
                bool x_75093 = sle64((int64_t) 0, mid_75092);
                bool y_75094 = slt64(mid_75092, n_65378);
                bool bounds_check_75095 = x_75093 && y_75094;
                bool index_certs_75096;
                
                if (!bounds_check_75095) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) mid_75092,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t mid_id_75097;
                
                mid_id_75097 = ((int64_t *) mem_71245)[mid_75092];
                
                bool cond_75098 = slt64(mid_id_75097, (int64_t) 0);
                int64_t mid_idx_75099;
                
                if (cond_75098) {
                    mid_idx_75099 = (int64_t) 9223372036854775807;
                } else {
                    mid_idx_75099 = mid_id_75097;
                }
                
                bool cond_75100 = sle64(defunc_0_g_res_75084, mid_idx_75099);
                int64_t loopres_75101;
                int64_t loopres_75102;
                
                if (cond_75100) {
                    int64_t loopres_t_res_75103 = sub64(mid_75092, (int64_t) 1);
                    
                    loopres_75101 = low_75089;
                    loopres_75102 = loopres_t_res_75103;
                } else {
                    int64_t loopres_f_res_75104 = add64((int64_t) 1, mid_75092);
                    
                    loopres_75101 = loopres_f_res_75104;
                    loopres_75102 = high_75090;
                }
                
                bool loop_cond_75105 = sle64(loopres_75101, loopres_75102);
                bool loop_while_tmp_75247 = loop_cond_75105;
                int64_t low_tmp_75248 = loopres_75101;
                int64_t high_tmp_75249 = loopres_75102;
                
                loop_while_75088 = loop_while_tmp_75247;
                low_75089 = low_tmp_75248;
                high_75090 = high_tmp_75249;
            }
            init_idx_75085 = loop_while_75088;
            init_idx_75086 = low_75089;
            init_idx_75087 = high_75090;
            
            bool idx_75106;
            int64_t idx_75107;
            int64_t idx_75108;
            int64_t idx_75109;
            bool loop_while_75110;
            int64_t l_idx_75111;
            int64_t r_idx_75112;
            int64_t span_75113;
            
            loop_while_75110 = loop_cond_65403;
            l_idx_75111 = init_idx_75086;
            r_idx_75112 = init_idx_75086;
            span_75113 = (int64_t) 1;
            while (loop_while_75110) {
                int64_t max_arg_75114 = sub64(l_idx_75111, (int64_t) 1);
                int64_t max_res_75115 = smax64((int64_t) 0, max_arg_75114);
                int64_t min_arg_75116 = add64((int64_t) 1, r_idx_75112);
                int64_t min_res_75117 = smin64(min_arg_66232, min_arg_75116);
                bool x_75118 = sle64((int64_t) 0, max_res_75115);
                bool y_75119 = slt64(max_res_75115, n_65378);
                bool bounds_check_75120 = x_75118 && y_75119;
                bool index_certs_75121;
                
                if (!bounds_check_75120) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) max_res_75115,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_75122;
                
                x_75122 = ((int64_t *) mem_71245)[max_res_75115];
                
                int64_t abs_arg_75123 = sub64(x_75122, defunc_0_g_res_75084);
                int64_t abs_res_75124 = abs64(abs_arg_75123);
                bool x_75125 = sle64((int64_t) 0, min_res_75117);
                bool y_75126 = slt64(min_res_75117, n_65378);
                bool bounds_check_75127 = x_75125 && y_75126;
                bool index_certs_75128;
                
                if (!bounds_check_75127) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) min_res_75117,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_75129;
                
                x_75129 = ((int64_t *) mem_71245)[min_res_75117];
                
                int64_t abs_arg_75130 = sub64(x_75129, defunc_0_g_res_75084);
                int64_t abs_res_75131 = abs64(abs_arg_75130);
                bool cond_75132 = max_res_75115 == l_idx_75111;
                int64_t loopres_75133;
                int64_t loopres_75134;
                int64_t loopres_75135;
                
                if (cond_75132) {
                    loopres_75133 = l_idx_75111;
                    loopres_75134 = r_idx_75112;
                    loopres_75135 = min_res_65398;
                } else {
                    bool cond_75136 = slt64(abs_res_75124, abs_res_75131);
                    bool cond_f_res_75137 = min_res_75117 == r_idx_75112;
                    bool x_75138 = !cond_75136;
                    bool y_75139 = cond_f_res_75137 && x_75138;
                    bool cond_75140 = cond_75136 || y_75139;
                    int64_t loopres_f_res_75141;
                    
                    if (cond_75140) {
                        loopres_f_res_75141 = max_res_75115;
                    } else {
                        loopres_f_res_75141 = l_idx_75111;
                    }
                    
                    int64_t loopres_f_res_75142;
                    
                    if (cond_75140) {
                        loopres_f_res_75142 = r_idx_75112;
                    } else {
                        loopres_f_res_75142 = min_res_75117;
                    }
                    
                    int64_t loopres_f_res_75143;
                    
                    if (cond_75140) {
                        int64_t loopres_f_res_t_res_75144 = add64((int64_t) 1,
                                                                  span_75113);
                        
                        loopres_f_res_75143 = loopres_f_res_t_res_75144;
                    } else {
                        int64_t loopres_f_res_f_res_75145 = add64((int64_t) 1,
                                                                  span_75113);
                        
                        loopres_f_res_75143 = loopres_f_res_f_res_75145;
                    }
                    loopres_75133 = loopres_f_res_75141;
                    loopres_75134 = loopres_f_res_75142;
                    loopres_75135 = loopres_f_res_75143;
                }
                
                bool loop_cond_75146 = slt64(loopres_75135, min_res_65398);
                bool loop_while_tmp_75250 = loop_cond_75146;
                int64_t l_idx_tmp_75251 = loopres_75133;
                int64_t r_idx_tmp_75252 = loopres_75134;
                int64_t span_tmp_75253 = loopres_75135;
                
                loop_while_75110 = loop_while_tmp_75250;
                l_idx_75111 = l_idx_tmp_75251;
                r_idx_75112 = r_idx_tmp_75252;
                span_75113 = span_tmp_75253;
            }
            idx_75106 = loop_while_75110;
            idx_75107 = l_idx_75111;
            idx_75108 = r_idx_75112;
            idx_75109 = span_75113;
            
            int64_t min_res_75147 = smin64(min_arg_66233, idx_75107);
            int64_t max_res_75148 = smax64((int64_t) 0, min_res_75147);
            int64_t x_75149 = add64(min_res_66234, max_res_75148);
            int64_t r_75150 = sub64(x_75149, (int64_t) 1);
            bool x_75151 = sle64((int64_t) 0, r_75150);
            bool y_75152 = slt64(r_75150, n_65378);
            bool bounds_check_75153 = x_75151 && y_75152;
            bool index_certs_75154;
            
            if (!bounds_check_75153) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) r_75150,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_75155;
            
            x_75155 = ((int64_t *) mem_71218)[r_75150];
            
            int64_t abs_arg_75156 = sub64(x_75155, min_res_75083);
            int64_t abs_res_75157 = abs64(abs_arg_75156);
            bool x_75158 = sle64((int64_t) 0, max_res_75148);
            bool y_75159 = slt64(max_res_75148, n_65378);
            bool bounds_check_75160 = x_75158 && y_75159;
            bool index_certs_75161;
            
            if (!bounds_check_75160) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_75148,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_75162;
            
            x_75162 = ((int64_t *) mem_71218)[max_res_75148];
            
            int64_t abs_arg_75163 = sub64(x_75162, min_res_75083);
            int64_t abs_res_75164 = abs64(abs_arg_75163);
            int64_t max_res_75165 = smax64(abs_res_75157, abs_res_75164);
            double defunc_0_f_res_75166 = sitofp_i64_f64(max_res_75165);
            double defunc_1_f_res_75167 = max_res_66238 + defunc_0_f_res_75166;
            double defunc_2_reduce_res_75170;
            double defunc_2_reduce_res_75171;
            double defunc_2_reduce_res_75172;
            double redout_75176;
            double redout_75177;
            double redout_75178;
            
            redout_75176 = 0.0;
            redout_75177 = 0.0;
            redout_75178 = 0.0;
            for (int64_t i_75175 = 0; i_75175 < q_65380; i_75175++) {
                double x_75181;
                
                x_75181 = ((double *) mem_71260)[i_75175];
                
                bool cond_75182 = sle64(last_res_66217, i_75175);
                int64_t defunc_0_f_res_75183;
                
                if (cond_75182) {
                    defunc_0_f_res_75183 = (int64_t) 0;
                } else {
                    int64_t i_75184 = add64(max_res_75148, i_75175);
                    int64_t defunc_0_add_arg_75185;
                    
                    defunc_0_add_arg_75185 = ((int64_t *) mem_71218)[i_75184];
                    
                    int64_t defunc_1_add_res_75186 = add64((int64_t) 1,
                                                           defunc_0_add_arg_75185);
                    
                    defunc_0_f_res_75183 = defunc_1_add_res_75186;
                }
                
                int64_t binop_p_75187 = sub64(defunc_0_f_res_75183,
                                              min_res_75083);
                double defunc_0_f_res_75188 = sitofp_i64_f64(binop_p_75187);
                double abs_res_75189 = fabs(defunc_0_f_res_75188);
                double tmp1_75190 = abs_res_75189 / defunc_1_f_res_75167;
                double x_75191 = tmp1_75190 * tmp1_75190;
                double y_75192 = tmp1_75190 * x_75191;
                double tmp2_75193 = 1.0 - y_75192;
                double x_75194 = tmp2_75193 * tmp2_75193;
                double tmp3_75195 = tmp2_75193 * x_75194;
                double tmp4_75196 = x_75181 * tmp3_75195;
                double defunc_1_f_res_75197 = defunc_0_f_res_75188 * tmp4_75196;
                double defunc_1_f_res_75198 = defunc_0_f_res_75188 *
                       defunc_1_f_res_75197;
                double defunc_1_op_res_75199 = tmp4_75196 + redout_75176;
                double defunc_1_op_res_75200 = defunc_1_f_res_75197 +
                       redout_75177;
                double defunc_1_op_res_75201 = defunc_1_f_res_75198 +
                       redout_75178;
                
                ((double *) mem_71295)[i_75175] = defunc_1_f_res_75197;
                ((double *) mem_71298)[i_75175] = tmp4_75196;
                
                double redout_tmp_75254 = defunc_1_op_res_75199;
                double redout_tmp_75255 = defunc_1_op_res_75200;
                double redout_tmp_75256 = defunc_1_op_res_75201;
                
                redout_75176 = redout_tmp_75254;
                redout_75177 = redout_tmp_75255;
                redout_75178 = redout_tmp_75256;
            }
            defunc_2_reduce_res_75170 = redout_75176;
            defunc_2_reduce_res_75171 = redout_75177;
            defunc_2_reduce_res_75172 = redout_75178;
            
            double x_75204 = defunc_2_reduce_res_75170 *
                   defunc_2_reduce_res_75172;
            double y_75205 = defunc_2_reduce_res_75171 *
                   defunc_2_reduce_res_75171;
            double y_75206 = x_75204 - y_75205;
            double det1_75207 = 1.0 / y_75206;
            double a11_75208 = defunc_2_reduce_res_75172 * det1_75207;
            double x_75209 = 0.0 - defunc_2_reduce_res_75171;
            double b11_75210 = det1_75207 * x_75209;
            double c11_75211 = defunc_2_reduce_res_75170 * det1_75207;
            double defunc_2_reduce_res_75212;
            double defunc_2_reduce_res_75213;
            double redout_75215;
            double redout_75216;
            
            redout_75215 = 0.0;
            redout_75216 = 0.0;
            for (int64_t i_75214 = 0; i_75214 < q_65380; i_75214++) {
                double x_75217;
                
                x_75217 = ((double *) mem_71298)[i_75214];
                
                double x_75218;
                
                x_75218 = ((double *) mem_71295)[i_75214];
                
                bool cond_75219 = sle64(last_res_66217, i_75214);
                double defunc_0_f_res_75220;
                
                if (cond_75219) {
                    defunc_0_f_res_75220 = 0.0;
                } else {
                    int64_t i_75221 = add64(max_res_75148, i_75214);
                    double defunc_0_add_arg_75222;
                    
                    defunc_0_add_arg_75222 = ((double *) mem_71215)[i_75221];
                    defunc_0_f_res_75220 = defunc_0_add_arg_75222;
                }
                
                double x_75223 = a11_75208 * x_75217;
                double y_75224 = b11_75210 * x_75218;
                double x_75225 = x_75223 + y_75224;
                double defunc_9_fit_fun_res_75226 = defunc_0_f_res_75220 *
                       x_75225;
                double x_75227 = b11_75210 * x_75217;
                double y_75228 = c11_75211 * x_75218;
                double x_75229 = x_75227 + y_75228;
                double defunc_9_slope_fun_res_75230 = defunc_0_f_res_75220 *
                       x_75229;
                double defunc_1_op_res_75231 = defunc_9_fit_fun_res_75226 +
                       redout_75215;
                double defunc_1_op_res_75232 = defunc_9_slope_fun_res_75230 +
                       redout_75216;
                double redout_tmp_75259 = defunc_1_op_res_75231;
                double redout_tmp_75260 = defunc_1_op_res_75232;
                
                redout_75215 = redout_tmp_75259;
                redout_75216 = redout_tmp_75260;
            }
            defunc_2_reduce_res_75212 = redout_75215;
            defunc_2_reduce_res_75213 = redout_75216;
            ((double *) mem_71275)[i_75079] = defunc_2_reduce_res_75212;
            ((double *) mem_71278)[i_75079] = defunc_2_reduce_res_75213;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71336.mem + gtid_68894 * n_m_65386 * (int64_t) 8,
                    mem_71275 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71340.mem + gtid_68894 * n_m_65386 * (int64_t) 8,
                    mem_71278 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71200);
    free(mem_71215);
    free(mem_71218);
    free(mem_71245);
    free(mem_71260);
    free(mem_71275);
    free(mem_71278);
    free(mem_71295);
    free(mem_71298);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77295_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77295_end -
                 futhark_mc_segmap_parloop_77295_start;
        
        ctx->futhark_mc_segmap_parloop_77295_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77295_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77295_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77293(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_68893 = tid;
    int num_tasks_75046 = info.nsubtasks;
    struct futhark_mc_task_77292 *futhark_mc_task_77292 =
                                 (struct futhark_mc_task_77292 *) args;
    struct futhark_context *ctx = futhark_mc_task_77292->ctx;
    uint64_t futhark_mc_segmap_task_77293_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77293_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77292->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77292->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77292->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77292->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77292->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77292->free_i_65392;
    bool x_65393 = futhark_mc_task_77292->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77292->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77292->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77292->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77292->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71142 = futhark_mc_task_77292->free_bytes_71142;
    int64_t bytes_71154 = futhark_mc_task_77292->free_bytes_71154;
    int64_t bytes_71193 = futhark_mc_task_77292->free_bytes_71193;
    struct memblock mem_71336 = {.desc ="mem_71336", .mem =
                                 futhark_mc_task_77292->free_mem_71336, .size =
                                 0, .references =NULL};
    struct memblock mem_71340 = {.desc ="mem_71340", .mem =
                                 futhark_mc_task_77292->free_mem_71340, .size =
                                 0, .references =NULL};
    int64_t iter_75047;
    struct futhark_mc_segmap_parloop_struct_77294
    futhark_mc_segmap_parloop_struct_77294;
    
    futhark_mc_segmap_parloop_struct_77294.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77294.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77294.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77294.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77294.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77294.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77294.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77294.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77294.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77294.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77294.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77294.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77294.free_bytes_71142 = bytes_71142;
    futhark_mc_segmap_parloop_struct_77294.free_bytes_71154 = bytes_71154;
    futhark_mc_segmap_parloop_struct_77294.free_bytes_71193 = bytes_71193;
    futhark_mc_segmap_parloop_struct_77294.free_mem_71336 = mem_71336.mem;
    futhark_mc_segmap_parloop_struct_77294.free_mem_71340 = mem_71340.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77295_task;
    
    futhark_mc_segmap_parloop_77295_task.name =
        "futhark_mc_segmap_parloop_77295";
    futhark_mc_segmap_parloop_77295_task.fn = futhark_mc_segmap_parloop_77295;
    futhark_mc_segmap_parloop_77295_task.args =
        &futhark_mc_segmap_parloop_struct_77294;
    futhark_mc_segmap_parloop_77295_task.iterations = iterations;
    futhark_mc_segmap_parloop_77295_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77295_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77295_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77295_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77295_task);
    
    if (futhark_mc_segmap_parloop_77295_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77295_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77295_total_end -
                 futhark_mc_segmap_parloop_77295_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77295_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77295_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77295_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77293_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77293_end -
                 futhark_mc_segmap_task_77293_start;
        
        ctx->futhark_mc_segmap_task_77293_runs[tid]++;
        ctx->futhark_mc_segmap_task_77293_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77293_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77306 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_71142;
    int64_t free_bytes_71154;
    int64_t free_bytes_71193;
    unsigned char *free_mem_71336;
    unsigned char *free_mem_71340;
};
struct futhark_mc_task_77315 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69071;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71143;
};
struct futhark_mc_scan_stage_1_parloop_struct_77318 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69071;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71143;
};
static int futhark_mc_scan_stage_1_parloop_77319(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_75262, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_1_parloop_struct_77318
    *futhark_mc_scan_stage_1_parloop_struct_77318 =
    (struct futhark_mc_scan_stage_1_parloop_struct_77318 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_1_parloop_struct_77318->ctx;
    uint64_t futhark_mc_scan_stage_1_parloop_77319_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77319_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_1_parloop_struct_77318->free_n_65378;
    int64_t gtid_69071 =
            futhark_mc_scan_stage_1_parloop_struct_77318->free_gtid_69071;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_1_parloop_struct_77318->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71143 = {.desc ="mem_71143", .mem =
                                 futhark_mc_scan_stage_1_parloop_struct_77318->free_mem_71143,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75601 = start;
    int64_t x_75264;
    int64_t x_75265;
    
    x_75264 = (int64_t) 0;
    for (; iter_75601 < end; iter_75601++) {
        int64_t gtid_75263 = iter_75601;
        
        // stage 1 scan body
        {
            double x_75267;
            
            x_75267 = ((double *) Y_mem_70603.mem)[gtid_69071 * n_65378 +
                                                   gtid_75263];
            
            bool isnan_res_75268;
            
            isnan_res_75268 = futrts_isnan64(x_75267);
            
            bool defunc_0_p_res_75269 = !isnan_res_75268;
            int64_t defunc_0_f_res_75270 = btoi_bool_i64(defunc_0_p_res_75269);
            
            // write mapped values results to memory
            { }
            x_75264 = x_75264;
            // Read next values
            {
                x_75265 = defunc_0_f_res_75270;
            }
            
            int64_t defunc_1_op_res_75266 = add64(x_75264, x_75265);
            
            ((int64_t *) mem_71143.mem)[gtid_75263] = defunc_1_op_res_75266;
            x_75264 = defunc_1_op_res_75266;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77319_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77319_end -
                 futhark_mc_scan_stage_1_parloop_77319_start;
        
        ctx->futhark_mc_scan_stage_1_parloop_77319_runs[tid]++;
        ctx->futhark_mc_scan_stage_1_parloop_77319_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_1_parloop_77319_iter[tid] += iterations;
    }
    return err;
}
struct futhark_mc_scan_stage_3_parloop_struct_77320 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69071;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71143;
};
static int futhark_mc_scan_stage_3_parloop_77321(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_75262, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_3_parloop_struct_77320
    *futhark_mc_scan_stage_3_parloop_struct_77320 =
    (struct futhark_mc_scan_stage_3_parloop_struct_77320 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_3_parloop_struct_77320->ctx;
    uint64_t futhark_mc_scan_stage_3_parloop_77321_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_3_parloop_77321_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_3_parloop_struct_77320->free_n_65378;
    int64_t gtid_69071 =
            futhark_mc_scan_stage_3_parloop_struct_77320->free_gtid_69071;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_3_parloop_struct_77320->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71143 = {.desc ="mem_71143", .mem =
                                 futhark_mc_scan_stage_3_parloop_struct_77320->free_mem_71143,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75613 = start;
    int64_t x_75610;
    int64_t x_75611;
    
    if (iter_75613 == (int64_t) 0) {
        x_75610 = (int64_t) 0;
    } else {
        x_75610 = ((int64_t *) mem_71143.mem)[iter_75613 - (int64_t) 1];
    }
    for (; iter_75613 < end; iter_75613++) {
        int64_t gtid_75263 = iter_75613;
        
        // stage 3 scan body
        {
            double x_75267;
            
            x_75267 = ((double *) Y_mem_70603.mem)[gtid_69071 * n_65378 +
                                                   gtid_75263];
            
            bool isnan_res_75268;
            
            isnan_res_75268 = futrts_isnan64(x_75267);
            
            bool defunc_0_p_res_75269 = !isnan_res_75268;
            int64_t defunc_0_f_res_75270 = btoi_bool_i64(defunc_0_p_res_75269);
            
            x_75610 = x_75610;
            x_75611 = defunc_0_f_res_75270;
            
            int64_t defunc_1_op_res_75612 = add64(x_75610, x_75611);
            
            ((int64_t *) mem_71143.mem)[gtid_75263] = defunc_1_op_res_75612;
            x_75610 = defunc_1_op_res_75612;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_3_parloop_77321_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77321_end -
                 futhark_mc_scan_stage_3_parloop_77321_start;
        
        ctx->futhark_mc_scan_stage_3_parloop_77321_runs[tid]++;
        ctx->futhark_mc_scan_stage_3_parloop_77321_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_3_parloop_77321_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segscan_task_77316(void *args, int64_t iterations, int tid,
                                  struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75262 = tid;
    int num_tasks_75600 = info.nsubtasks;
    struct futhark_mc_task_77315 *futhark_mc_task_77315 =
                                 (struct futhark_mc_task_77315 *) args;
    struct futhark_context *ctx = futhark_mc_task_77315->ctx;
    uint64_t futhark_mc_segscan_task_77316_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segscan_task_77316_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77315->free_n_65378;
    int64_t gtid_69071 = futhark_mc_task_77315->free_gtid_69071;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77315->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71143 = {.desc ="mem_71143", .mem =
                                 futhark_mc_task_77315->free_mem_71143, .size =
                                 0, .references =NULL};
    size_t scan_stage_2_accum_mem_75607_cached_sizze_77317 = 0;
    unsigned char *scan_stage_2_accum_mem_75607 = NULL;
    int64_t iter_75601;
    struct futhark_mc_scan_stage_1_parloop_struct_77318
    futhark_mc_scan_stage_1_parloop_struct_77318;
    
    futhark_mc_scan_stage_1_parloop_struct_77318.ctx = ctx;
    futhark_mc_scan_stage_1_parloop_struct_77318.free_n_65378 = n_65378;
    futhark_mc_scan_stage_1_parloop_struct_77318.free_gtid_69071 = gtid_69071;
    futhark_mc_scan_stage_1_parloop_struct_77318.free_Y_mem_70603 =
        Y_mem_70603.mem;
    futhark_mc_scan_stage_1_parloop_struct_77318.free_mem_71143 = mem_71143.mem;
    
    struct scheduler_parloop futhark_mc_scan_stage_1_parloop_77319_task;
    
    futhark_mc_scan_stage_1_parloop_77319_task.name =
        "futhark_mc_scan_stage_1_parloop_77319";
    futhark_mc_scan_stage_1_parloop_77319_task.fn =
        futhark_mc_scan_stage_1_parloop_77319;
    futhark_mc_scan_stage_1_parloop_77319_task.args =
        &futhark_mc_scan_stage_1_parloop_struct_77318;
    futhark_mc_scan_stage_1_parloop_77319_task.iterations = iterations;
    futhark_mc_scan_stage_1_parloop_77319_task.info = info;
    
    uint64_t futhark_mc_scan_stage_1_parloop_77319_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77319_total_start = get_wall_time();
    
    int futhark_mc_scan_stage_1_parloop_77319_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_scan_stage_1_parloop_77319_task);
    
    if (futhark_mc_scan_stage_1_parloop_77319_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77319_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77319_total_end -
                 futhark_mc_scan_stage_1_parloop_77319_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77319_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77319_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77319_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    if (slt32(1, num_tasks_75600)) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmentedScan stage 2");
        
        int64_t x_75602;
        int64_t x_75603;
        int64_t offset_75605 = (int64_t) 0;
        int64_t offset_index_75606 = (int64_t) 0;
        
        if (scan_stage_2_accum_mem_75607_cached_sizze_77317 <
            (size_t) (int64_t) 8) {
            scan_stage_2_accum_mem_75607 = realloc(scan_stage_2_accum_mem_75607,
                                                   (int64_t) 8);
            scan_stage_2_accum_mem_75607_cached_sizze_77317 = (int64_t) 8;
        }
        ((int64_t *) scan_stage_2_accum_mem_75607)[(int64_t) 0] = (int64_t) 0;
        for (int32_t i_75609 = 0; i_75609 < num_tasks_75600 - 1; i_75609++) {
            offset_75605 = squot64(n_65378, sext_i32_i64(num_tasks_75600));
            if (slt64(sext_i32_i64(i_75609), srem64(n_65378,
                                                    sext_i32_i64(num_tasks_75600)))) {
                offset_75605 += (int64_t) 1;
            }
            offset_index_75606 += offset_75605;
            
            int64_t gtid_75263 = offset_index_75606;
            double x_75267;
            
            x_75267 = ((double *) Y_mem_70603.mem)[gtid_69071 * n_65378 +
                                                   gtid_75263];
            
            bool isnan_res_75268;
            
            isnan_res_75268 = futrts_isnan64(x_75267);
            
            bool defunc_0_p_res_75269 = !isnan_res_75268;
            int64_t defunc_0_f_res_75270 = btoi_bool_i64(defunc_0_p_res_75269);
            
            // Read carry in
            {
                x_75602 =
                    ((int64_t *) scan_stage_2_accum_mem_75607)[(int64_t) 0];
            }
            // Read next values
            {
                x_75603 = ((int64_t *) mem_71143.mem)[offset_index_75606 -
                                                      (int64_t) 1];
            }
            
            int64_t defunc_1_op_res_75604 = add64(x_75602, x_75603);
            
            ((int64_t *) mem_71143.mem)[offset_index_75606 - (int64_t) 1] =
                defunc_1_op_res_75604;
            ((int64_t *) scan_stage_2_accum_mem_75607)[(int64_t) 0] =
                defunc_1_op_res_75604;
        }
        
        int64_t iter_75613 = (int64_t) 0;
        struct futhark_mc_scan_stage_3_parloop_struct_77320
        futhark_mc_scan_stage_3_parloop_struct_77320;
        
        futhark_mc_scan_stage_3_parloop_struct_77320.ctx = ctx;
        futhark_mc_scan_stage_3_parloop_struct_77320.free_n_65378 = n_65378;
        futhark_mc_scan_stage_3_parloop_struct_77320.free_gtid_69071 =
            gtid_69071;
        futhark_mc_scan_stage_3_parloop_struct_77320.free_Y_mem_70603 =
            Y_mem_70603.mem;
        futhark_mc_scan_stage_3_parloop_struct_77320.free_mem_71143 =
            mem_71143.mem;
        
        struct scheduler_parloop futhark_mc_scan_stage_3_parloop_77321_task;
        
        futhark_mc_scan_stage_3_parloop_77321_task.name =
            "futhark_mc_scan_stage_3_parloop_77321";
        futhark_mc_scan_stage_3_parloop_77321_task.fn =
            futhark_mc_scan_stage_3_parloop_77321;
        futhark_mc_scan_stage_3_parloop_77321_task.args =
            &futhark_mc_scan_stage_3_parloop_struct_77320;
        futhark_mc_scan_stage_3_parloop_77321_task.iterations = iterations;
        futhark_mc_scan_stage_3_parloop_77321_task.info = info;
        
        uint64_t futhark_mc_scan_stage_3_parloop_77321_total_start = 0;
        
        if (ctx->profiling && !ctx->profiling_paused)
            futhark_mc_scan_stage_3_parloop_77321_total_start = get_wall_time();
        
        int futhark_mc_scan_stage_3_parloop_77321_err =
            scheduler_execute_task(&ctx->scheduler,
                                   &futhark_mc_scan_stage_3_parloop_77321_task);
        
        if (futhark_mc_scan_stage_3_parloop_77321_err != 0) {
            err = 1;
            goto cleanup;
        }
        if (ctx->profiling && !ctx->profiling_paused) {
            uint64_t futhark_mc_scan_stage_3_parloop_77321_total_end =
                     get_wall_time();
            uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77321_total_end -
                     futhark_mc_scan_stage_3_parloop_77321_total_start;
            
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77321_total_runs,
                               1, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77321_total_total_runtime,
                               elapsed, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77321_total_iter,
                               iterations, __ATOMIC_RELAXED);
        }
    }
    
  cleanup:
    {
        free(scan_stage_2_accum_mem_75607);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segscan_task_77316_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segscan_task_77316_end -
                 futhark_mc_segscan_task_77316_start;
        
        ctx->futhark_mc_segscan_task_77316_runs[tid]++;
        ctx->futhark_mc_segscan_task_77316_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segscan_task_77316_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77322 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69071;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71143;
    unsigned char *free_mem_71146;
    unsigned char *free_mem_71149;
};
struct futhark_mc_segmap_parloop_struct_77324 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69071;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71143;
    unsigned char *free_mem_71146;
    unsigned char *free_mem_71149;
};
static int futhark_mc_segmap_parloop_77325(void *args, int64_t start,
                                           int64_t end, int flat_tid_75271,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77324
    *futhark_mc_segmap_parloop_struct_77324 =
    (struct futhark_mc_segmap_parloop_struct_77324 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77324->ctx;
    uint64_t futhark_mc_segmap_parloop_77325_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77325_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77324->free_n_65378;
    int64_t gtid_69071 =
            futhark_mc_segmap_parloop_struct_77324->free_gtid_69071;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77324->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71143 = {.desc ="mem_71143", .mem =
                                 futhark_mc_segmap_parloop_struct_77324->free_mem_71143,
                                 .size =0, .references =NULL};
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_segmap_parloop_struct_77324->free_mem_71146,
                                 .size =0, .references =NULL};
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_segmap_parloop_struct_77324->free_mem_71149,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75617 = start;
    
    for (; iter_75617 < end; iter_75617++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75620 = n_65378;
        int64_t gtid_75272 = iter_75617;
        int64_t remnant_75621 = iter_75617 - gtid_75272;
        double x_75273;
        
        x_75273 = ((double *) Y_mem_70603.mem)[gtid_69071 * n_65378 +
                                               gtid_75272];
        
        bool isnan_res_75274;
        
        isnan_res_75274 = futrts_isnan64(x_75273);
        
        bool defunc_0_p_res_75275 = !isnan_res_75274;
        int64_t defunc_1_f_res_75276;
        
        if (defunc_0_p_res_75275) {
            int64_t x_75618;
            
            x_75618 = ((int64_t *) mem_71143.mem)[gtid_75272];
            
            int64_t defunc_1_f_res_t_res_75619 = sub64(x_75618, (int64_t) 1);
            
            defunc_1_f_res_75276 = defunc_1_f_res_t_res_75619;
        } else {
            defunc_1_f_res_75276 = (int64_t) -1;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_75276) &&
            slt64(defunc_1_f_res_75276, n_65378)) {
            ((int64_t *) mem_71149.mem)[defunc_1_f_res_75276] = gtid_75272;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_75276) &&
            slt64(defunc_1_f_res_75276, n_65378)) {
            ((double *) mem_71146.mem)[defunc_1_f_res_75276] = x_75273;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77325_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77325_end -
                 futhark_mc_segmap_parloop_77325_start;
        
        ctx->futhark_mc_segmap_parloop_77325_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77325_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77325_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77323(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75271 = tid;
    int num_tasks_75616 = info.nsubtasks;
    struct futhark_mc_task_77322 *futhark_mc_task_77322 =
                                 (struct futhark_mc_task_77322 *) args;
    struct futhark_context *ctx = futhark_mc_task_77322->ctx;
    uint64_t futhark_mc_segmap_task_77323_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77323_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77322->free_n_65378;
    int64_t gtid_69071 = futhark_mc_task_77322->free_gtid_69071;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77322->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71143 = {.desc ="mem_71143", .mem =
                                 futhark_mc_task_77322->free_mem_71143, .size =
                                 0, .references =NULL};
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_task_77322->free_mem_71146, .size =
                                 0, .references =NULL};
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_task_77322->free_mem_71149, .size =
                                 0, .references =NULL};
    int64_t iter_75617;
    struct futhark_mc_segmap_parloop_struct_77324
    futhark_mc_segmap_parloop_struct_77324;
    
    futhark_mc_segmap_parloop_struct_77324.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77324.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77324.free_gtid_69071 = gtid_69071;
    futhark_mc_segmap_parloop_struct_77324.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77324.free_mem_71143 = mem_71143.mem;
    futhark_mc_segmap_parloop_struct_77324.free_mem_71146 = mem_71146.mem;
    futhark_mc_segmap_parloop_struct_77324.free_mem_71149 = mem_71149.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77325_task;
    
    futhark_mc_segmap_parloop_77325_task.name =
        "futhark_mc_segmap_parloop_77325";
    futhark_mc_segmap_parloop_77325_task.fn = futhark_mc_segmap_parloop_77325;
    futhark_mc_segmap_parloop_77325_task.args =
        &futhark_mc_segmap_parloop_struct_77324;
    futhark_mc_segmap_parloop_77325_task.iterations = iterations;
    futhark_mc_segmap_parloop_77325_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77325_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77325_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77325_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77325_task);
    
    if (futhark_mc_segmap_parloop_77325_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77325_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77325_total_end -
                 futhark_mc_segmap_parloop_77325_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77325_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77325_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77325_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77323_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77323_end -
                 futhark_mc_segmap_task_77323_start;
        
        ctx->futhark_mc_segmap_task_77323_runs[tid]++;
        ctx->futhark_mc_segmap_task_77323_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77323_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77326 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71152;
};
struct futhark_mc_segmap_parloop_struct_77328 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71152;
};
static int futhark_mc_segmap_parloop_77329(void *args, int64_t start,
                                           int64_t end, int flat_tid_75279,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77328
    *futhark_mc_segmap_parloop_struct_77328 =
    (struct futhark_mc_segmap_parloop_struct_77328 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77328->ctx;
    uint64_t futhark_mc_segmap_parloop_77329_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77329_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77328->free_n_65378;
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_segmap_parloop_struct_77328->free_mem_71149,
                                 .size =0, .references =NULL};
    struct memblock mem_71152 = {.desc ="mem_71152", .mem =
                                 futhark_mc_segmap_parloop_struct_77328->free_mem_71152,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75623 = start;
    
    for (; iter_75623 < end; iter_75623++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75624 = n_65378;
        int64_t gtid_75280 = iter_75623;
        int64_t remnant_75625 = iter_75623 - gtid_75280;
        int64_t x_75281;
        
        x_75281 = ((int64_t *) mem_71149.mem)[gtid_75280];
        
        int64_t defunc_0_f_res_75282 = add64((int64_t) 1, x_75281);
        
        ((int64_t *) mem_71152.mem)[gtid_75280] = defunc_0_f_res_75282;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77329_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77329_end -
                 futhark_mc_segmap_parloop_77329_start;
        
        ctx->futhark_mc_segmap_parloop_77329_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77329_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77329_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77327(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75279 = tid;
    int num_tasks_75622 = info.nsubtasks;
    struct futhark_mc_task_77326 *futhark_mc_task_77326 =
                                 (struct futhark_mc_task_77326 *) args;
    struct futhark_context *ctx = futhark_mc_task_77326->ctx;
    uint64_t futhark_mc_segmap_task_77327_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77327_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77326->free_n_65378;
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_task_77326->free_mem_71149, .size =
                                 0, .references =NULL};
    struct memblock mem_71152 = {.desc ="mem_71152", .mem =
                                 futhark_mc_task_77326->free_mem_71152, .size =
                                 0, .references =NULL};
    int64_t iter_75623;
    struct futhark_mc_segmap_parloop_struct_77328
    futhark_mc_segmap_parloop_struct_77328;
    
    futhark_mc_segmap_parloop_struct_77328.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77328.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77328.free_mem_71149 = mem_71149.mem;
    futhark_mc_segmap_parloop_struct_77328.free_mem_71152 = mem_71152.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77329_task;
    
    futhark_mc_segmap_parloop_77329_task.name =
        "futhark_mc_segmap_parloop_77329";
    futhark_mc_segmap_parloop_77329_task.fn = futhark_mc_segmap_parloop_77329;
    futhark_mc_segmap_parloop_77329_task.args =
        &futhark_mc_segmap_parloop_struct_77328;
    futhark_mc_segmap_parloop_77329_task.iterations = iterations;
    futhark_mc_segmap_parloop_77329_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77329_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77329_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77329_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77329_task);
    
    if (futhark_mc_segmap_parloop_77329_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77329_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77329_total_end -
                 futhark_mc_segmap_parloop_77329_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77329_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77329_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77329_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77327_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77327_end -
                 futhark_mc_segmap_task_77327_start;
        
        ctx->futhark_mc_segmap_task_77327_runs[tid]++;
        ctx->futhark_mc_segmap_task_77327_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77327_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77330 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_69083;
    unsigned char *free_mem_71155;
};
struct futhark_mc_segmap_parloop_struct_77332 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_69083;
    unsigned char *free_mem_71155;
};
static int futhark_mc_segmap_parloop_77333(void *args, int64_t start,
                                           int64_t end, int flat_tid_75283,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77332
    *futhark_mc_segmap_parloop_struct_77332 =
    (struct futhark_mc_segmap_parloop_struct_77332 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77332->ctx;
    uint64_t futhark_mc_segmap_parloop_77333_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77333_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77332->free_q_65380;
    int64_t last_res_69083 =
            futhark_mc_segmap_parloop_struct_77332->free_last_res_69083;
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_segmap_parloop_struct_77332->free_mem_71155,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75627 = start;
    
    for (; iter_75627 < end; iter_75627++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75628 = q_65380;
        int64_t gtid_75284 = iter_75627;
        int64_t remnant_75629 = iter_75627 - gtid_75284;
        bool cond_75285 = sle64(last_res_69083, gtid_75284);
        double defunc_0_f_res_75286;
        
        if (cond_75285) {
            defunc_0_f_res_75286 = 0.0;
        } else {
            defunc_0_f_res_75286 = 1.0;
        }
        ((double *) mem_71155.mem)[gtid_75284] = defunc_0_f_res_75286;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77333_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77333_end -
                 futhark_mc_segmap_parloop_77333_start;
        
        ctx->futhark_mc_segmap_parloop_77333_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77333_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77333_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77331(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75283 = tid;
    int num_tasks_75626 = info.nsubtasks;
    struct futhark_mc_task_77330 *futhark_mc_task_77330 =
                                 (struct futhark_mc_task_77330 *) args;
    struct futhark_context *ctx = futhark_mc_task_77330->ctx;
    uint64_t futhark_mc_segmap_task_77331_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77331_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77330->free_q_65380;
    int64_t last_res_69083 = futhark_mc_task_77330->free_last_res_69083;
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_task_77330->free_mem_71155, .size =
                                 0, .references =NULL};
    int64_t iter_75627;
    struct futhark_mc_segmap_parloop_struct_77332
    futhark_mc_segmap_parloop_struct_77332;
    
    futhark_mc_segmap_parloop_struct_77332.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77332.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77332.free_last_res_69083 = last_res_69083;
    futhark_mc_segmap_parloop_struct_77332.free_mem_71155 = mem_71155.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77333_task;
    
    futhark_mc_segmap_parloop_77333_task.name =
        "futhark_mc_segmap_parloop_77333";
    futhark_mc_segmap_parloop_77333_task.fn = futhark_mc_segmap_parloop_77333;
    futhark_mc_segmap_parloop_77333_task.args =
        &futhark_mc_segmap_parloop_struct_77332;
    futhark_mc_segmap_parloop_77333_task.iterations = iterations;
    futhark_mc_segmap_parloop_77333_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77333_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77333_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77333_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77333_task);
    
    if (futhark_mc_segmap_parloop_77333_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77333_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77333_total_end -
                 futhark_mc_segmap_parloop_77333_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77333_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77333_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77333_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77331_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77331_end -
                 futhark_mc_segmap_task_77331_start;
        
        ctx->futhark_mc_segmap_task_77331_runs[tid]++;
        ctx->futhark_mc_segmap_task_77331_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77331_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77334 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_69083;
    int64_t free_min_arg_69102;
    int64_t free_min_arg_69103;
    int64_t free_min_res_69104;
    double free_max_res_69108;
    unsigned char *free_mem_71146;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71152;
    int64_t free_bytes_71154;
    unsigned char *free_mem_71155;
    unsigned char *free_mem_71194;
    unsigned char *free_mem_71197;
};
struct futhark_mc_segmap_parloop_struct_77336 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_69083;
    int64_t free_min_arg_69102;
    int64_t free_min_arg_69103;
    int64_t free_min_res_69104;
    double free_max_res_69108;
    unsigned char *free_mem_71146;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71152;
    int64_t free_bytes_71154;
    unsigned char *free_mem_71155;
    unsigned char *free_mem_71194;
    unsigned char *free_mem_71197;
};
static int futhark_mc_segmap_parloop_77337(void *args, int64_t start,
                                           int64_t end, int flat_tid_75443,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77336
    *futhark_mc_segmap_parloop_struct_77336 =
    (struct futhark_mc_segmap_parloop_struct_77336 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77336->ctx;
    uint64_t futhark_mc_segmap_parloop_77337_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77337_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77336->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77336->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77336->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77336->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77336->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77336->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77336->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77336->free_loop_cond_65403;
    int64_t last_res_69083 =
            futhark_mc_segmap_parloop_struct_77336->free_last_res_69083;
    int64_t min_arg_69102 =
            futhark_mc_segmap_parloop_struct_77336->free_min_arg_69102;
    int64_t min_arg_69103 =
            futhark_mc_segmap_parloop_struct_77336->free_min_arg_69103;
    int64_t min_res_69104 =
            futhark_mc_segmap_parloop_struct_77336->free_min_res_69104;
    double max_res_69108 =
           futhark_mc_segmap_parloop_struct_77336->free_max_res_69108;
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_segmap_parloop_struct_77336->free_mem_71146,
                                 .size =0, .references =NULL};
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_segmap_parloop_struct_77336->free_mem_71149,
                                 .size =0, .references =NULL};
    struct memblock mem_71152 = {.desc ="mem_71152", .mem =
                                 futhark_mc_segmap_parloop_struct_77336->free_mem_71152,
                                 .size =0, .references =NULL};
    int64_t bytes_71154 =
            futhark_mc_segmap_parloop_struct_77336->free_bytes_71154;
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_segmap_parloop_struct_77336->free_mem_71155,
                                 .size =0, .references =NULL};
    struct memblock mem_71194 = {.desc ="mem_71194", .mem =
                                 futhark_mc_segmap_parloop_struct_77336->free_mem_71194,
                                 .size =0, .references =NULL};
    struct memblock mem_71197 = {.desc ="mem_71197", .mem =
                                 futhark_mc_segmap_parloop_struct_77336->free_mem_71197,
                                 .size =0, .references =NULL};
    size_t mem_75531_cached_sizze_77338 = 0;
    unsigned char *mem_75531 = NULL;
    size_t mem_75533_cached_sizze_77339 = 0;
    unsigned char *mem_75533 = NULL;
    int64_t iterations = end - start;
    int64_t iter_75631 = start;
    
    if (mem_75531_cached_sizze_77338 < (size_t) bytes_71154) {
        mem_75531 = realloc(mem_75531, bytes_71154);
        mem_75531_cached_sizze_77338 = bytes_71154;
    }
    if (mem_75533_cached_sizze_77339 < (size_t) bytes_71154) {
        mem_75533 = realloc(mem_75533, bytes_71154);
        mem_75533_cached_sizze_77339 = bytes_71154;
    }
    for (; iter_75631 < end; iter_75631++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75735 = n_m_65386;
        int64_t gtid_75444 = iter_75631;
        int64_t remnant_75736 = iter_75631 - gtid_75444;
        int64_t min_arg_75445 = mul64(jump_65382, gtid_75444);
        int64_t min_res_75446 = smin64(i_65392, min_arg_75445);
        int64_t defunc_0_g_res_75447 = add64((int64_t) 1, min_res_75446);
        bool init_idx_75448;
        int64_t init_idx_75449;
        int64_t init_idx_75450;
        bool loop_while_75632;
        int64_t low_75633;
        int64_t high_75634;
        
        loop_while_75632 = x_65393;
        low_75633 = (int64_t) 0;
        high_75634 = i_65392;
        while (loop_while_75632) {
            int64_t x_75635 = add64(low_75633, high_75634);
            int64_t mid_75636 = sdiv64(x_75635, (int64_t) 2);
            bool x_75637 = sle64((int64_t) 0, mid_75636);
            bool y_75638 = slt64(mid_75636, n_65378);
            bool bounds_check_75639 = x_75637 && y_75638;
            bool index_certs_75640;
            
            if (!bounds_check_75639) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_75636,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_75641;
            
            mid_id_75641 = ((int64_t *) mem_71152.mem)[mid_75636];
            
            bool cond_75642 = slt64(mid_id_75641, (int64_t) 0);
            int64_t mid_idx_75643;
            
            if (cond_75642) {
                mid_idx_75643 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_75643 = mid_id_75641;
            }
            
            bool cond_75644 = sle64(defunc_0_g_res_75447, mid_idx_75643);
            int64_t loopres_75645;
            int64_t loopres_75646;
            
            if (cond_75644) {
                int64_t loopres_t_res_75647 = sub64(mid_75636, (int64_t) 1);
                
                loopres_75645 = low_75633;
                loopres_75646 = loopres_t_res_75647;
            } else {
                int64_t loopres_f_res_75648 = add64((int64_t) 1, mid_75636);
                
                loopres_75645 = loopres_f_res_75648;
                loopres_75646 = high_75634;
            }
            
            bool loop_cond_75649 = sle64(loopres_75645, loopres_75646);
            bool loop_while_tmp_75737 = loop_cond_75649;
            int64_t low_tmp_75738 = loopres_75645;
            int64_t high_tmp_75739 = loopres_75646;
            
            loop_while_75632 = loop_while_tmp_75737;
            low_75633 = low_tmp_75738;
            high_75634 = high_tmp_75739;
        }
        init_idx_75448 = loop_while_75632;
        init_idx_75449 = low_75633;
        init_idx_75450 = high_75634;
        
        bool idx_75469;
        int64_t idx_75470;
        int64_t idx_75471;
        int64_t idx_75472;
        bool loop_while_75650;
        int64_t l_idx_75651;
        int64_t r_idx_75652;
        int64_t span_75653;
        
        loop_while_75650 = loop_cond_65403;
        l_idx_75651 = init_idx_75449;
        r_idx_75652 = init_idx_75449;
        span_75653 = (int64_t) 1;
        while (loop_while_75650) {
            int64_t max_arg_75654 = sub64(l_idx_75651, (int64_t) 1);
            int64_t max_res_75655 = smax64((int64_t) 0, max_arg_75654);
            int64_t min_arg_75656 = add64((int64_t) 1, r_idx_75652);
            int64_t min_res_75657 = smin64(min_arg_69102, min_arg_75656);
            bool x_75658 = sle64((int64_t) 0, max_res_75655);
            bool y_75659 = slt64(max_res_75655, n_65378);
            bool bounds_check_75660 = x_75658 && y_75659;
            bool index_certs_75661;
            
            if (!bounds_check_75660) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_75655,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_75662;
            
            x_75662 = ((int64_t *) mem_71152.mem)[max_res_75655];
            
            int64_t abs_arg_75663 = sub64(x_75662, defunc_0_g_res_75447);
            int64_t abs_res_75664 = abs64(abs_arg_75663);
            bool x_75665 = sle64((int64_t) 0, min_res_75657);
            bool y_75666 = slt64(min_res_75657, n_65378);
            bool bounds_check_75667 = x_75665 && y_75666;
            bool index_certs_75668;
            
            if (!bounds_check_75667) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_75657,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_75669;
            
            x_75669 = ((int64_t *) mem_71152.mem)[min_res_75657];
            
            int64_t abs_arg_75670 = sub64(x_75669, defunc_0_g_res_75447);
            int64_t abs_res_75671 = abs64(abs_arg_75670);
            bool cond_75672 = max_res_75655 == l_idx_75651;
            int64_t loopres_75673;
            int64_t loopres_75674;
            int64_t loopres_75675;
            
            if (cond_75672) {
                loopres_75673 = l_idx_75651;
                loopres_75674 = r_idx_75652;
                loopres_75675 = min_res_65398;
            } else {
                bool cond_75676 = slt64(abs_res_75664, abs_res_75671);
                bool cond_f_res_75677 = min_res_75657 == r_idx_75652;
                bool x_75678 = !cond_75676;
                bool y_75679 = cond_f_res_75677 && x_75678;
                bool cond_75680 = cond_75676 || y_75679;
                int64_t loopres_f_res_75681;
                
                if (cond_75680) {
                    loopres_f_res_75681 = max_res_75655;
                } else {
                    loopres_f_res_75681 = l_idx_75651;
                }
                
                int64_t loopres_f_res_75682;
                
                if (cond_75680) {
                    loopres_f_res_75682 = r_idx_75652;
                } else {
                    loopres_f_res_75682 = min_res_75657;
                }
                
                int64_t loopres_f_res_75683;
                
                if (cond_75680) {
                    int64_t loopres_f_res_t_res_75684 = add64((int64_t) 1,
                                                              span_75653);
                    
                    loopres_f_res_75683 = loopres_f_res_t_res_75684;
                } else {
                    int64_t loopres_f_res_f_res_75685 = add64((int64_t) 1,
                                                              span_75653);
                    
                    loopres_f_res_75683 = loopres_f_res_f_res_75685;
                }
                loopres_75673 = loopres_f_res_75681;
                loopres_75674 = loopres_f_res_75682;
                loopres_75675 = loopres_f_res_75683;
            }
            
            bool loop_cond_75686 = slt64(loopres_75675, min_res_65398);
            bool loop_while_tmp_75740 = loop_cond_75686;
            int64_t l_idx_tmp_75741 = loopres_75673;
            int64_t r_idx_tmp_75742 = loopres_75674;
            int64_t span_tmp_75743 = loopres_75675;
            
            loop_while_75650 = loop_while_tmp_75740;
            l_idx_75651 = l_idx_tmp_75741;
            r_idx_75652 = r_idx_tmp_75742;
            span_75653 = span_tmp_75743;
        }
        idx_75469 = loop_while_75650;
        idx_75470 = l_idx_75651;
        idx_75471 = r_idx_75652;
        idx_75472 = span_75653;
        
        int64_t min_res_75510 = smin64(min_arg_69103, idx_75470);
        int64_t max_res_75511 = smax64((int64_t) 0, min_res_75510);
        int64_t x_75512 = add64(min_res_69104, max_res_75511);
        int64_t r_75513 = sub64(x_75512, (int64_t) 1);
        bool x_75514 = sle64((int64_t) 0, r_75513);
        bool y_75515 = slt64(r_75513, n_65378);
        bool bounds_check_75516 = x_75514 && y_75515;
        bool index_certs_75517;
        
        if (!bounds_check_75516) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_75513,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_75518;
        
        x_75518 = ((int64_t *) mem_71149.mem)[r_75513];
        
        int64_t abs_arg_75519 = sub64(x_75518, min_res_75446);
        int64_t abs_res_75520 = abs64(abs_arg_75519);
        bool x_75521 = sle64((int64_t) 0, max_res_75511);
        bool y_75522 = slt64(max_res_75511, n_65378);
        bool bounds_check_75523 = x_75521 && y_75522;
        bool index_certs_75524;
        
        if (!bounds_check_75523) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_75511,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_75525;
        
        x_75525 = ((int64_t *) mem_71149.mem)[max_res_75511];
        
        int64_t abs_arg_75526 = sub64(x_75525, min_res_75446);
        int64_t abs_res_75527 = abs64(abs_arg_75526);
        int64_t max_res_75528 = smax64(abs_res_75520, abs_res_75527);
        double defunc_0_f_res_75529 = sitofp_i64_f64(max_res_75528);
        double defunc_1_f_res_75530 = max_res_69108 + defunc_0_f_res_75529;
        double defunc_2_reduce_res_75535;
        double defunc_2_reduce_res_75536;
        double defunc_2_reduce_res_75537;
        double redout_75688;
        double redout_75689;
        double redout_75690;
        
        redout_75688 = 0.0;
        redout_75689 = 0.0;
        redout_75690 = 0.0;
        for (int64_t i_75687 = 0; i_75687 < q_65380; i_75687++) {
            double x_75693;
            
            x_75693 = ((double *) mem_71155.mem)[i_75687];
            
            bool cond_75694 = sle64(last_res_69083, i_75687);
            int64_t defunc_0_f_res_75695;
            
            if (cond_75694) {
                defunc_0_f_res_75695 = (int64_t) 0;
            } else {
                int64_t i_75696 = add64(max_res_75511, i_75687);
                int64_t defunc_0_add_arg_75697;
                
                defunc_0_add_arg_75697 = ((int64_t *) mem_71149.mem)[i_75696];
                
                int64_t defunc_1_add_res_75698 = add64((int64_t) 1,
                                                       defunc_0_add_arg_75697);
                
                defunc_0_f_res_75695 = defunc_1_add_res_75698;
            }
            
            int64_t binop_p_75699 = sub64(defunc_0_f_res_75695, min_res_75446);
            double defunc_0_f_res_75700 = sitofp_i64_f64(binop_p_75699);
            double abs_res_75701 = fabs(defunc_0_f_res_75700);
            double tmp1_75702 = abs_res_75701 / defunc_1_f_res_75530;
            double x_75703 = tmp1_75702 * tmp1_75702;
            double y_75704 = tmp1_75702 * x_75703;
            double tmp2_75705 = 1.0 - y_75704;
            double x_75706 = tmp2_75705 * tmp2_75705;
            double tmp3_75707 = tmp2_75705 * x_75706;
            double tmp4_75708 = x_75693 * tmp3_75707;
            double defunc_1_f_res_75709 = defunc_0_f_res_75700 * tmp4_75708;
            double defunc_1_f_res_75710 = defunc_0_f_res_75700 *
                   defunc_1_f_res_75709;
            double defunc_1_op_res_75711 = tmp4_75708 + redout_75688;
            double defunc_1_op_res_75712 = defunc_1_f_res_75709 + redout_75689;
            double defunc_1_op_res_75713 = defunc_1_f_res_75710 + redout_75690;
            
            ((double *) mem_75531)[i_75687] = defunc_1_f_res_75709;
            ((double *) mem_75533)[i_75687] = tmp4_75708;
            
            double redout_tmp_75744 = defunc_1_op_res_75711;
            double redout_tmp_75745 = defunc_1_op_res_75712;
            double redout_tmp_75746 = defunc_1_op_res_75713;
            
            redout_75688 = redout_tmp_75744;
            redout_75689 = redout_tmp_75745;
            redout_75690 = redout_tmp_75746;
        }
        defunc_2_reduce_res_75535 = redout_75688;
        defunc_2_reduce_res_75536 = redout_75689;
        defunc_2_reduce_res_75537 = redout_75690;
        
        double x_75569 = defunc_2_reduce_res_75535 * defunc_2_reduce_res_75537;
        double y_75570 = defunc_2_reduce_res_75536 * defunc_2_reduce_res_75536;
        double y_75571 = x_75569 - y_75570;
        double det1_75572 = 1.0 / y_75571;
        double a11_75573 = defunc_2_reduce_res_75537 * det1_75572;
        double x_75574 = 0.0 - defunc_2_reduce_res_75536;
        double b11_75575 = det1_75572 * x_75574;
        double c11_75576 = defunc_2_reduce_res_75535 * det1_75572;
        double defunc_2_reduce_res_75577;
        double defunc_2_reduce_res_75578;
        double redout_75717;
        double redout_75718;
        
        redout_75717 = 0.0;
        redout_75718 = 0.0;
        for (int64_t i_75716 = 0; i_75716 < q_65380; i_75716++) {
            double x_75719;
            
            x_75719 = ((double *) mem_75533)[i_75716];
            
            double x_75720;
            
            x_75720 = ((double *) mem_75531)[i_75716];
            
            bool cond_75721 = sle64(last_res_69083, i_75716);
            double defunc_0_f_res_75722;
            
            if (cond_75721) {
                defunc_0_f_res_75722 = 0.0;
            } else {
                int64_t i_75723 = add64(max_res_75511, i_75716);
                double defunc_0_add_arg_75724;
                
                defunc_0_add_arg_75724 = ((double *) mem_71146.mem)[i_75723];
                defunc_0_f_res_75722 = defunc_0_add_arg_75724;
            }
            
            double x_75725 = a11_75573 * x_75719;
            double y_75726 = b11_75575 * x_75720;
            double x_75727 = x_75725 + y_75726;
            double defunc_9_fit_fun_res_75728 = defunc_0_f_res_75722 * x_75727;
            double x_75729 = b11_75575 * x_75719;
            double y_75730 = c11_75576 * x_75720;
            double x_75731 = x_75729 + y_75730;
            double defunc_9_slope_fun_res_75732 = defunc_0_f_res_75722 *
                   x_75731;
            double defunc_1_op_res_75733 = defunc_9_fit_fun_res_75728 +
                   redout_75717;
            double defunc_1_op_res_75734 = defunc_9_slope_fun_res_75732 +
                   redout_75718;
            double redout_tmp_75749 = defunc_1_op_res_75733;
            double redout_tmp_75750 = defunc_1_op_res_75734;
            
            redout_75717 = redout_tmp_75749;
            redout_75718 = redout_tmp_75750;
        }
        defunc_2_reduce_res_75577 = redout_75717;
        defunc_2_reduce_res_75578 = redout_75718;
        ((double *) mem_71194.mem)[gtid_75444] = defunc_2_reduce_res_75577;
        ((double *) mem_71197.mem)[gtid_75444] = defunc_2_reduce_res_75578;
    }
    
  cleanup:
    { }
    free(mem_75531);
    free(mem_75533);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77337_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77337_end -
                 futhark_mc_segmap_parloop_77337_start;
        
        ctx->futhark_mc_segmap_parloop_77337_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77337_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77337_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77335(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75443 = tid;
    int num_tasks_75630 = info.nsubtasks;
    struct futhark_mc_task_77334 *futhark_mc_task_77334 =
                                 (struct futhark_mc_task_77334 *) args;
    struct futhark_context *ctx = futhark_mc_task_77334->ctx;
    uint64_t futhark_mc_segmap_task_77335_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77335_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77334->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77334->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77334->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77334->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77334->free_i_65392;
    bool x_65393 = futhark_mc_task_77334->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77334->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77334->free_loop_cond_65403;
    int64_t last_res_69083 = futhark_mc_task_77334->free_last_res_69083;
    int64_t min_arg_69102 = futhark_mc_task_77334->free_min_arg_69102;
    int64_t min_arg_69103 = futhark_mc_task_77334->free_min_arg_69103;
    int64_t min_res_69104 = futhark_mc_task_77334->free_min_res_69104;
    double max_res_69108 = futhark_mc_task_77334->free_max_res_69108;
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_task_77334->free_mem_71146, .size =
                                 0, .references =NULL};
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_task_77334->free_mem_71149, .size =
                                 0, .references =NULL};
    struct memblock mem_71152 = {.desc ="mem_71152", .mem =
                                 futhark_mc_task_77334->free_mem_71152, .size =
                                 0, .references =NULL};
    int64_t bytes_71154 = futhark_mc_task_77334->free_bytes_71154;
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_task_77334->free_mem_71155, .size =
                                 0, .references =NULL};
    struct memblock mem_71194 = {.desc ="mem_71194", .mem =
                                 futhark_mc_task_77334->free_mem_71194, .size =
                                 0, .references =NULL};
    struct memblock mem_71197 = {.desc ="mem_71197", .mem =
                                 futhark_mc_task_77334->free_mem_71197, .size =
                                 0, .references =NULL};
    int64_t iter_75631;
    struct futhark_mc_segmap_parloop_struct_77336
    futhark_mc_segmap_parloop_struct_77336;
    
    futhark_mc_segmap_parloop_struct_77336.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77336.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77336.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77336.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77336.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77336.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77336.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77336.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77336.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77336.free_last_res_69083 = last_res_69083;
    futhark_mc_segmap_parloop_struct_77336.free_min_arg_69102 = min_arg_69102;
    futhark_mc_segmap_parloop_struct_77336.free_min_arg_69103 = min_arg_69103;
    futhark_mc_segmap_parloop_struct_77336.free_min_res_69104 = min_res_69104;
    futhark_mc_segmap_parloop_struct_77336.free_max_res_69108 = max_res_69108;
    futhark_mc_segmap_parloop_struct_77336.free_mem_71146 = mem_71146.mem;
    futhark_mc_segmap_parloop_struct_77336.free_mem_71149 = mem_71149.mem;
    futhark_mc_segmap_parloop_struct_77336.free_mem_71152 = mem_71152.mem;
    futhark_mc_segmap_parloop_struct_77336.free_bytes_71154 = bytes_71154;
    futhark_mc_segmap_parloop_struct_77336.free_mem_71155 = mem_71155.mem;
    futhark_mc_segmap_parloop_struct_77336.free_mem_71194 = mem_71194.mem;
    futhark_mc_segmap_parloop_struct_77336.free_mem_71197 = mem_71197.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77337_task;
    
    futhark_mc_segmap_parloop_77337_task.name =
        "futhark_mc_segmap_parloop_77337";
    futhark_mc_segmap_parloop_77337_task.fn = futhark_mc_segmap_parloop_77337;
    futhark_mc_segmap_parloop_77337_task.args =
        &futhark_mc_segmap_parloop_struct_77336;
    futhark_mc_segmap_parloop_77337_task.iterations = iterations;
    futhark_mc_segmap_parloop_77337_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77337_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77337_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77337_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77337_task);
    
    if (futhark_mc_segmap_parloop_77337_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77337_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77337_total_end -
                 futhark_mc_segmap_parloop_77337_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77337_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77337_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77337_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77335_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77335_end -
                 futhark_mc_segmap_task_77335_start;
        
        ctx->futhark_mc_segmap_task_77335_runs[tid]++;
        ctx->futhark_mc_segmap_task_77335_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77335_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77341 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_69083;
    int64_t free_min_arg_69102;
    int64_t free_min_arg_69103;
    int64_t free_min_res_69104;
    double free_max_res_69108;
    unsigned char *free_mem_71146;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71152;
    int64_t free_bytes_71154;
    unsigned char *free_mem_71155;
    unsigned char *free_mem_71194;
    unsigned char *free_mem_71197;
};
struct futhark_mc_task_77345 {
    struct futhark_context *ctx;
    int64_t free_last_res_69083;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71155;
    int64_t free_min_res_75290;
    int64_t free_max_res_75355;
    double free_defunc_1_f_res_75374;
    double *retval_defunc_2_reduce_res_75377;
    double *retval_defunc_2_reduce_res_75378;
    double *retval_defunc_2_reduce_res_75379;
    unsigned char *retval_mem_75375;
    unsigned char *retval_mem_75376;
};
struct futhark_mc_segred_stage_1_parloop_struct_77350 {
    struct futhark_context *ctx;
    int64_t free_last_res_69083;
    unsigned char *free_mem_71149;
    unsigned char *free_mem_71155;
    int64_t free_min_res_75290;
    int64_t free_max_res_75355;
    double free_defunc_1_f_res_75374;
    unsigned char *free_mem_75375;
    unsigned char *free_mem_75376;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75868;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75870;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75872;
};
static int futhark_mc_segred_stage_1_parloop_77351(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_75807, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77350
    *futhark_mc_segred_stage_1_parloop_struct_77350 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77350 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77350->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77351_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77351_start = get_wall_time();
    
    int64_t last_res_69083 =
            futhark_mc_segred_stage_1_parloop_struct_77350->free_last_res_69083;
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77350->free_mem_71149,
                                 .size =0, .references =NULL};
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77350->free_mem_71155,
                                 .size =0, .references =NULL};
    int64_t min_res_75290 =
            futhark_mc_segred_stage_1_parloop_struct_77350->free_min_res_75290;
    int64_t max_res_75355 =
            futhark_mc_segred_stage_1_parloop_struct_77350->free_max_res_75355;
    double defunc_1_f_res_75374 =
           futhark_mc_segred_stage_1_parloop_struct_77350->free_defunc_1_f_res_75374;
    struct memblock mem_75375 = {.desc ="mem_75375", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77350->free_mem_75375,
                                 .size =0, .references =NULL};
    struct memblock mem_75376 = {.desc ="mem_75376", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77350->free_mem_75376,
                                 .size =0, .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_75868 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75868",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77350->free_reduce_stage_1_tid_res_arr_mem_75868,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_75870 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75870",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77350->free_reduce_stage_1_tid_res_arr_mem_75870,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_75872 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75872",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77350->free_reduce_stage_1_tid_res_arr_mem_75872,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75874 = start;
    double x_75809;
    double x_75810;
    double x_75812;
    double x_75813;
    double x_75815;
    double x_75816;
    double local_acc_75875 = 0.0;
    double local_acc_75876 = 0.0;
    double local_acc_75877 = 0.0;
    
    for (; iter_75874 < end; iter_75874++) {
        int64_t gtid_75808 = iter_75874;
        double x_75818;
        
        x_75818 = ((double *) mem_71155.mem)[gtid_75808];
        
        bool cond_75819 = sle64(last_res_69083, gtid_75808);
        int64_t defunc_0_f_res_75820;
        
        if (cond_75819) {
            defunc_0_f_res_75820 = (int64_t) 0;
        } else {
            int64_t i_75821 = add64(max_res_75355, gtid_75808);
            int64_t defunc_0_add_arg_75822;
            
            defunc_0_add_arg_75822 = ((int64_t *) mem_71149.mem)[i_75821];
            
            int64_t defunc_1_add_res_75823 = add64((int64_t) 1,
                                                   defunc_0_add_arg_75822);
            
            defunc_0_f_res_75820 = defunc_1_add_res_75823;
        }
        
        int64_t binop_p_75824 = sub64(defunc_0_f_res_75820, min_res_75290);
        double defunc_0_f_res_75825 = sitofp_i64_f64(binop_p_75824);
        double abs_res_75826 = fabs(defunc_0_f_res_75825);
        double tmp1_75827 = abs_res_75826 / defunc_1_f_res_75374;
        double x_75828 = tmp1_75827 * tmp1_75827;
        double y_75829 = tmp1_75827 * x_75828;
        double tmp2_75830 = 1.0 - y_75829;
        double x_75831 = tmp2_75830 * tmp2_75830;
        double tmp3_75832 = tmp2_75830 * x_75831;
        double tmp4_75833 = x_75818 * tmp3_75832;
        double defunc_1_f_res_75834 = defunc_0_f_res_75825 * tmp4_75833;
        double defunc_1_f_res_75835 = defunc_0_f_res_75825 *
               defunc_1_f_res_75834;
        
        // save map-out results
        {
            ((double *) mem_75375.mem)[gtid_75808] = defunc_1_f_res_75834;
            ((double *) mem_75376.mem)[gtid_75808] = tmp4_75833;
        }
        // Load accum params
        {
            x_75809 = local_acc_75875;
        }
        // Load next params
        {
            x_75810 = tmp4_75833;
        }
        // Red body
        {
            double defunc_1_op_res_75811 = x_75809 + x_75810;
            
            local_acc_75875 = defunc_1_op_res_75811;
        }
        // Load accum params
        {
            x_75812 = local_acc_75876;
        }
        // Load next params
        {
            x_75813 = defunc_1_f_res_75834;
        }
        // Red body
        {
            double defunc_1_op_res_75814 = x_75812 + x_75813;
            
            local_acc_75876 = defunc_1_op_res_75814;
        }
        // Load accum params
        {
            x_75815 = local_acc_75877;
        }
        // Load next params
        {
            x_75816 = defunc_1_f_res_75835;
        }
        // Red body
        {
            double defunc_1_op_res_75817 = x_75815 + x_75816;
            
            local_acc_75877 = defunc_1_op_res_75817;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_75868.mem)[flat_tid_75807] =
        local_acc_75875;
    ((double *) reduce_stage_1_tid_res_arr_mem_75870.mem)[flat_tid_75807] =
        local_acc_75876;
    ((double *) reduce_stage_1_tid_res_arr_mem_75872.mem)[flat_tid_75807] =
        local_acc_75877;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77351_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77351_end -
                 futhark_mc_segred_stage_1_parloop_77351_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77351_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77351_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77351_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77346(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75807 = tid;
    int num_tasks_75867 = info.nsubtasks;
    struct futhark_mc_task_77345 *futhark_mc_task_77345 =
                                 (struct futhark_mc_task_77345 *) args;
    struct futhark_context *ctx = futhark_mc_task_77345->ctx;
    uint64_t futhark_mc_segred_task_77346_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77346_start = get_wall_time();
    
    int64_t last_res_69083 = futhark_mc_task_77345->free_last_res_69083;
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_task_77345->free_mem_71149, .size =
                                 0, .references =NULL};
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_task_77345->free_mem_71155, .size =
                                 0, .references =NULL};
    int64_t min_res_75290 = futhark_mc_task_77345->free_min_res_75290;
    int64_t max_res_75355 = futhark_mc_task_77345->free_max_res_75355;
    double defunc_1_f_res_75374 =
           futhark_mc_task_77345->free_defunc_1_f_res_75374;
    double defunc_2_reduce_res_75377 =
           *futhark_mc_task_77345->retval_defunc_2_reduce_res_75377;
    double defunc_2_reduce_res_75378 =
           *futhark_mc_task_77345->retval_defunc_2_reduce_res_75378;
    double defunc_2_reduce_res_75379 =
           *futhark_mc_task_77345->retval_defunc_2_reduce_res_75379;
    struct memblock mem_75375 = {.desc ="mem_75375", .mem =
                                 futhark_mc_task_77345->retval_mem_75375,
                                 .size =0, .references =NULL};
    struct memblock mem_75376 = {.desc ="mem_75376", .mem =
                                 futhark_mc_task_77345->retval_mem_75376,
                                 .size =0, .references =NULL};
    size_t reduce_stage_1_tid_res_arr_mem_75868_cached_sizze_77347 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75868 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_75870_cached_sizze_77348 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75870 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_75872_cached_sizze_77349 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75872 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_75868_cached_sizze_77347 <
        (size_t) ((int64_t) 8 * num_tasks_75867)) {
        reduce_stage_1_tid_res_arr_mem_75868 =
            realloc(reduce_stage_1_tid_res_arr_mem_75868, (int64_t) 8 *
                    num_tasks_75867);
        reduce_stage_1_tid_res_arr_mem_75868_cached_sizze_77347 = (int64_t) 8 *
            num_tasks_75867;
    }
    if (reduce_stage_1_tid_res_arr_mem_75870_cached_sizze_77348 <
        (size_t) ((int64_t) 8 * num_tasks_75867)) {
        reduce_stage_1_tid_res_arr_mem_75870 =
            realloc(reduce_stage_1_tid_res_arr_mem_75870, (int64_t) 8 *
                    num_tasks_75867);
        reduce_stage_1_tid_res_arr_mem_75870_cached_sizze_77348 = (int64_t) 8 *
            num_tasks_75867;
    }
    if (reduce_stage_1_tid_res_arr_mem_75872_cached_sizze_77349 <
        (size_t) ((int64_t) 8 * num_tasks_75867)) {
        reduce_stage_1_tid_res_arr_mem_75872 =
            realloc(reduce_stage_1_tid_res_arr_mem_75872, (int64_t) 8 *
                    num_tasks_75867);
        reduce_stage_1_tid_res_arr_mem_75872_cached_sizze_77349 = (int64_t) 8 *
            num_tasks_75867;
    }
    
    int64_t iter_75874;
    struct futhark_mc_segred_stage_1_parloop_struct_77350
    futhark_mc_segred_stage_1_parloop_struct_77350;
    
    futhark_mc_segred_stage_1_parloop_struct_77350.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_last_res_69083 =
        last_res_69083;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_mem_71149 =
        mem_71149.mem;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_mem_71155 =
        mem_71155.mem;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_min_res_75290 =
        min_res_75290;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_max_res_75355 =
        max_res_75355;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_defunc_1_f_res_75374 =
        defunc_1_f_res_75374;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_mem_75375 =
        mem_75375.mem;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_mem_75376 =
        mem_75376.mem;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_reduce_stage_1_tid_res_arr_mem_75868 =
        reduce_stage_1_tid_res_arr_mem_75868;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_reduce_stage_1_tid_res_arr_mem_75870 =
        reduce_stage_1_tid_res_arr_mem_75870;
    futhark_mc_segred_stage_1_parloop_struct_77350.free_reduce_stage_1_tid_res_arr_mem_75872 =
        reduce_stage_1_tid_res_arr_mem_75872;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77351_task;
    
    futhark_mc_segred_stage_1_parloop_77351_task.name =
        "futhark_mc_segred_stage_1_parloop_77351";
    futhark_mc_segred_stage_1_parloop_77351_task.fn =
        futhark_mc_segred_stage_1_parloop_77351;
    futhark_mc_segred_stage_1_parloop_77351_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77350;
    futhark_mc_segred_stage_1_parloop_77351_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77351_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77351_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77351_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77351_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77351_task);
    
    if (futhark_mc_segred_stage_1_parloop_77351_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77351_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77351_total_end -
                 futhark_mc_segred_stage_1_parloop_77351_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77351_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77351_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77351_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_75377 = 0.0;
        defunc_2_reduce_res_75378 = 0.0;
        defunc_2_reduce_res_75379 = 0.0;
    }
    
    double x_75878;
    double x_75879;
    double x_75881;
    double x_75882;
    double x_75884;
    double x_75885;
    
    for (int32_t i_75887 = 0; i_75887 < num_tasks_75867; i_75887++) {
        flat_tid_75807 = i_75887;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_75878 = defunc_2_reduce_res_75377;
            }
            // load next params
            {
                x_75879 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75868)[flat_tid_75807];
            }
            // red body
            {
                double defunc_1_op_res_75880 = x_75878 + x_75879;
                
                defunc_2_reduce_res_75377 = defunc_1_op_res_75880;
            }
            // load acc params
            {
                x_75881 = defunc_2_reduce_res_75378;
            }
            // load next params
            {
                x_75882 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75870)[flat_tid_75807];
            }
            // red body
            {
                double defunc_1_op_res_75883 = x_75881 + x_75882;
                
                defunc_2_reduce_res_75378 = defunc_1_op_res_75883;
            }
            // load acc params
            {
                x_75884 = defunc_2_reduce_res_75379;
            }
            // load next params
            {
                x_75885 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75872)[flat_tid_75807];
            }
            // red body
            {
                double defunc_1_op_res_75886 = x_75884 + x_75885;
                
                defunc_2_reduce_res_75379 = defunc_1_op_res_75886;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_75868);
        free(reduce_stage_1_tid_res_arr_mem_75870);
        free(reduce_stage_1_tid_res_arr_mem_75872);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77346_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77346_end -
                 futhark_mc_segred_task_77346_start;
        
        ctx->futhark_mc_segred_task_77346_runs[tid]++;
        ctx->futhark_mc_segred_task_77346_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77346_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77345->retval_defunc_2_reduce_res_75377 =
            defunc_2_reduce_res_75377;
        *futhark_mc_task_77345->retval_defunc_2_reduce_res_75378 =
            defunc_2_reduce_res_75378;
        *futhark_mc_task_77345->retval_defunc_2_reduce_res_75379 =
            defunc_2_reduce_res_75379;
        futhark_mc_task_77345->retval_mem_75375 = mem_75375.mem;
        futhark_mc_task_77345->retval_mem_75376 = mem_75376.mem;
    }
    return err;
}
struct futhark_mc_task_77352 {
    struct futhark_context *ctx;
    int64_t free_last_res_69083;
    unsigned char *free_mem_71146;
    int64_t free_max_res_75355;
    unsigned char *free_mem_75375;
    unsigned char *free_mem_75376;
    double free_a11_75415;
    double free_b11_75417;
    double free_c11_75418;
    double *retval_defunc_2_reduce_res_75419;
    double *retval_defunc_2_reduce_res_75420;
};
struct futhark_mc_segred_stage_1_parloop_struct_77356 {
    struct futhark_context *ctx;
    int64_t free_last_res_69083;
    unsigned char *free_mem_71146;
    int64_t free_max_res_75355;
    unsigned char *free_mem_75375;
    unsigned char *free_mem_75376;
    double free_a11_75415;
    double free_b11_75417;
    double free_c11_75418;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75889;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_75891;
};
static int futhark_mc_segred_stage_1_parloop_77357(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_75836, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77356
    *futhark_mc_segred_stage_1_parloop_struct_77356 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77356 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77356->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77357_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77357_start = get_wall_time();
    
    int64_t last_res_69083 =
            futhark_mc_segred_stage_1_parloop_struct_77356->free_last_res_69083;
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77356->free_mem_71146,
                                 .size =0, .references =NULL};
    int64_t max_res_75355 =
            futhark_mc_segred_stage_1_parloop_struct_77356->free_max_res_75355;
    struct memblock mem_75375 = {.desc ="mem_75375", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77356->free_mem_75375,
                                 .size =0, .references =NULL};
    struct memblock mem_75376 = {.desc ="mem_75376", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77356->free_mem_75376,
                                 .size =0, .references =NULL};
    double a11_75415 =
           futhark_mc_segred_stage_1_parloop_struct_77356->free_a11_75415;
    double b11_75417 =
           futhark_mc_segred_stage_1_parloop_struct_77356->free_b11_75417;
    double c11_75418 =
           futhark_mc_segred_stage_1_parloop_struct_77356->free_c11_75418;
    struct memblock reduce_stage_1_tid_res_arr_mem_75889 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75889",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77356->free_reduce_stage_1_tid_res_arr_mem_75889,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_75891 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_75891",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77356->free_reduce_stage_1_tid_res_arr_mem_75891,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_75893 = start;
    double x_75838;
    double x_75839;
    double x_75841;
    double x_75842;
    double local_acc_75894 = 0.0;
    double local_acc_75895 = 0.0;
    
    for (; iter_75893 < end; iter_75893++) {
        int64_t gtid_75837 = iter_75893;
        double x_75844;
        
        x_75844 = ((double *) mem_75376.mem)[gtid_75837];
        
        double x_75845;
        
        x_75845 = ((double *) mem_75375.mem)[gtid_75837];
        
        bool cond_75846 = sle64(last_res_69083, gtid_75837);
        double defunc_0_f_res_75847;
        
        if (cond_75846) {
            defunc_0_f_res_75847 = 0.0;
        } else {
            int64_t i_75848 = add64(max_res_75355, gtid_75837);
            double defunc_0_add_arg_75849;
            
            defunc_0_add_arg_75849 = ((double *) mem_71146.mem)[i_75848];
            defunc_0_f_res_75847 = defunc_0_add_arg_75849;
        }
        
        double x_75850 = a11_75415 * x_75844;
        double y_75851 = b11_75417 * x_75845;
        double x_75852 = x_75850 + y_75851;
        double defunc_9_fit_fun_res_75853 = defunc_0_f_res_75847 * x_75852;
        double x_75854 = b11_75417 * x_75844;
        double y_75855 = c11_75418 * x_75845;
        double x_75856 = x_75854 + y_75855;
        double defunc_9_slope_fun_res_75857 = defunc_0_f_res_75847 * x_75856;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_75838 = local_acc_75894;
        }
        // Load next params
        {
            x_75839 = defunc_9_fit_fun_res_75853;
        }
        // Red body
        {
            double defunc_1_op_res_75840 = x_75838 + x_75839;
            
            local_acc_75894 = defunc_1_op_res_75840;
        }
        // Load accum params
        {
            x_75841 = local_acc_75895;
        }
        // Load next params
        {
            x_75842 = defunc_9_slope_fun_res_75857;
        }
        // Red body
        {
            double defunc_1_op_res_75843 = x_75841 + x_75842;
            
            local_acc_75895 = defunc_1_op_res_75843;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_75889.mem)[flat_tid_75836] =
        local_acc_75894;
    ((double *) reduce_stage_1_tid_res_arr_mem_75891.mem)[flat_tid_75836] =
        local_acc_75895;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77357_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77357_end -
                 futhark_mc_segred_stage_1_parloop_77357_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77357_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77357_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77357_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77353(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75836 = tid;
    int num_tasks_75888 = info.nsubtasks;
    struct futhark_mc_task_77352 *futhark_mc_task_77352 =
                                 (struct futhark_mc_task_77352 *) args;
    struct futhark_context *ctx = futhark_mc_task_77352->ctx;
    uint64_t futhark_mc_segred_task_77353_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77353_start = get_wall_time();
    
    int64_t last_res_69083 = futhark_mc_task_77352->free_last_res_69083;
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_task_77352->free_mem_71146, .size =
                                 0, .references =NULL};
    int64_t max_res_75355 = futhark_mc_task_77352->free_max_res_75355;
    struct memblock mem_75375 = {.desc ="mem_75375", .mem =
                                 futhark_mc_task_77352->free_mem_75375, .size =
                                 0, .references =NULL};
    struct memblock mem_75376 = {.desc ="mem_75376", .mem =
                                 futhark_mc_task_77352->free_mem_75376, .size =
                                 0, .references =NULL};
    double a11_75415 = futhark_mc_task_77352->free_a11_75415;
    double b11_75417 = futhark_mc_task_77352->free_b11_75417;
    double c11_75418 = futhark_mc_task_77352->free_c11_75418;
    double defunc_2_reduce_res_75419 =
           *futhark_mc_task_77352->retval_defunc_2_reduce_res_75419;
    double defunc_2_reduce_res_75420 =
           *futhark_mc_task_77352->retval_defunc_2_reduce_res_75420;
    size_t reduce_stage_1_tid_res_arr_mem_75889_cached_sizze_77354 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75889 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_75891_cached_sizze_77355 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_75891 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_75889_cached_sizze_77354 <
        (size_t) ((int64_t) 8 * num_tasks_75888)) {
        reduce_stage_1_tid_res_arr_mem_75889 =
            realloc(reduce_stage_1_tid_res_arr_mem_75889, (int64_t) 8 *
                    num_tasks_75888);
        reduce_stage_1_tid_res_arr_mem_75889_cached_sizze_77354 = (int64_t) 8 *
            num_tasks_75888;
    }
    if (reduce_stage_1_tid_res_arr_mem_75891_cached_sizze_77355 <
        (size_t) ((int64_t) 8 * num_tasks_75888)) {
        reduce_stage_1_tid_res_arr_mem_75891 =
            realloc(reduce_stage_1_tid_res_arr_mem_75891, (int64_t) 8 *
                    num_tasks_75888);
        reduce_stage_1_tid_res_arr_mem_75891_cached_sizze_77355 = (int64_t) 8 *
            num_tasks_75888;
    }
    
    int64_t iter_75893;
    struct futhark_mc_segred_stage_1_parloop_struct_77356
    futhark_mc_segred_stage_1_parloop_struct_77356;
    
    futhark_mc_segred_stage_1_parloop_struct_77356.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_last_res_69083 =
        last_res_69083;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_mem_71146 =
        mem_71146.mem;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_max_res_75355 =
        max_res_75355;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_mem_75375 =
        mem_75375.mem;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_mem_75376 =
        mem_75376.mem;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_a11_75415 = a11_75415;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_b11_75417 = b11_75417;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_c11_75418 = c11_75418;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_reduce_stage_1_tid_res_arr_mem_75889 =
        reduce_stage_1_tid_res_arr_mem_75889;
    futhark_mc_segred_stage_1_parloop_struct_77356.free_reduce_stage_1_tid_res_arr_mem_75891 =
        reduce_stage_1_tid_res_arr_mem_75891;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77357_task;
    
    futhark_mc_segred_stage_1_parloop_77357_task.name =
        "futhark_mc_segred_stage_1_parloop_77357";
    futhark_mc_segred_stage_1_parloop_77357_task.fn =
        futhark_mc_segred_stage_1_parloop_77357;
    futhark_mc_segred_stage_1_parloop_77357_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77356;
    futhark_mc_segred_stage_1_parloop_77357_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77357_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77357_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77357_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77357_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77357_task);
    
    if (futhark_mc_segred_stage_1_parloop_77357_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77357_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77357_total_end -
                 futhark_mc_segred_stage_1_parloop_77357_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77357_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77357_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77357_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_75419 = 0.0;
        defunc_2_reduce_res_75420 = 0.0;
    }
    
    double x_75896;
    double x_75897;
    double x_75899;
    double x_75900;
    
    for (int32_t i_75902 = 0; i_75902 < num_tasks_75888; i_75902++) {
        flat_tid_75836 = i_75902;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_75896 = defunc_2_reduce_res_75419;
            }
            // load next params
            {
                x_75897 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75889)[flat_tid_75836];
            }
            // red body
            {
                double defunc_1_op_res_75898 = x_75896 + x_75897;
                
                defunc_2_reduce_res_75419 = defunc_1_op_res_75898;
            }
            // load acc params
            {
                x_75899 = defunc_2_reduce_res_75420;
            }
            // load next params
            {
                x_75900 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_75891)[flat_tid_75836];
            }
            // red body
            {
                double defunc_1_op_res_75901 = x_75899 + x_75900;
                
                defunc_2_reduce_res_75420 = defunc_1_op_res_75901;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_75889);
        free(reduce_stage_1_tid_res_arr_mem_75891);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77353_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77353_end -
                 futhark_mc_segred_task_77353_start;
        
        ctx->futhark_mc_segred_task_77353_runs[tid]++;
        ctx->futhark_mc_segred_task_77353_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77353_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77352->retval_defunc_2_reduce_res_75419 =
            defunc_2_reduce_res_75419;
        *futhark_mc_task_77352->retval_defunc_2_reduce_res_75420 =
            defunc_2_reduce_res_75420;
    }
    return err;
}
static int futhark_mc_segmap_parloop_77342(void *args, int64_t start,
                                           int64_t end, int flat_tid_75287,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77341
    *futhark_mc_segmap_parloop_struct_77341 =
    (struct futhark_mc_segmap_parloop_struct_77341 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77341->ctx;
    uint64_t futhark_mc_segmap_parloop_77342_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77342_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77341->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77341->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77341->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77341->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77341->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77341->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77341->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77341->free_loop_cond_65403;
    int64_t last_res_69083 =
            futhark_mc_segmap_parloop_struct_77341->free_last_res_69083;
    int64_t min_arg_69102 =
            futhark_mc_segmap_parloop_struct_77341->free_min_arg_69102;
    int64_t min_arg_69103 =
            futhark_mc_segmap_parloop_struct_77341->free_min_arg_69103;
    int64_t min_res_69104 =
            futhark_mc_segmap_parloop_struct_77341->free_min_res_69104;
    double max_res_69108 =
           futhark_mc_segmap_parloop_struct_77341->free_max_res_69108;
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_segmap_parloop_struct_77341->free_mem_71146,
                                 .size =0, .references =NULL};
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_segmap_parloop_struct_77341->free_mem_71149,
                                 .size =0, .references =NULL};
    struct memblock mem_71152 = {.desc ="mem_71152", .mem =
                                 futhark_mc_segmap_parloop_struct_77341->free_mem_71152,
                                 .size =0, .references =NULL};
    int64_t bytes_71154 =
            futhark_mc_segmap_parloop_struct_77341->free_bytes_71154;
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_segmap_parloop_struct_77341->free_mem_71155,
                                 .size =0, .references =NULL};
    struct memblock mem_71194 = {.desc ="mem_71194", .mem =
                                 futhark_mc_segmap_parloop_struct_77341->free_mem_71194,
                                 .size =0, .references =NULL};
    struct memblock mem_71197 = {.desc ="mem_71197", .mem =
                                 futhark_mc_segmap_parloop_struct_77341->free_mem_71197,
                                 .size =0, .references =NULL};
    size_t mem_75375_cached_sizze_77343 = 0;
    unsigned char *mem_75375 = NULL;
    size_t mem_75376_cached_sizze_77344 = 0;
    unsigned char *mem_75376 = NULL;
    int64_t iterations = end - start;
    int64_t iter_75751 = start;
    
    if (mem_75375_cached_sizze_77343 < (size_t) bytes_71154) {
        mem_75375 = realloc(mem_75375, bytes_71154);
        mem_75375_cached_sizze_77343 = bytes_71154;
    }
    if (mem_75376_cached_sizze_77344 < (size_t) bytes_71154) {
        mem_75376 = realloc(mem_75376, bytes_71154);
        mem_75376_cached_sizze_77344 = bytes_71154;
    }
    for (; iter_75751 < end; iter_75751++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75858 = n_m_65386;
        int64_t gtid_75288 = iter_75751;
        int64_t remnant_75859 = iter_75751 - gtid_75288;
        int64_t min_arg_75289 = mul64(jump_65382, gtid_75288);
        int64_t min_res_75290 = smin64(i_65392, min_arg_75289);
        int64_t defunc_0_g_res_75291 = add64((int64_t) 1, min_res_75290);
        bool init_idx_75292;
        int64_t init_idx_75293;
        int64_t init_idx_75294;
        bool loop_while_75752;
        int64_t low_75753;
        int64_t high_75754;
        
        loop_while_75752 = x_65393;
        low_75753 = (int64_t) 0;
        high_75754 = i_65392;
        while (loop_while_75752) {
            int64_t x_75755 = add64(low_75753, high_75754);
            int64_t mid_75756 = sdiv64(x_75755, (int64_t) 2);
            bool x_75757 = sle64((int64_t) 0, mid_75756);
            bool y_75758 = slt64(mid_75756, n_65378);
            bool bounds_check_75759 = x_75757 && y_75758;
            bool index_certs_75760;
            
            if (!bounds_check_75759) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_75756,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_75761;
            
            mid_id_75761 = ((int64_t *) mem_71152.mem)[mid_75756];
            
            bool cond_75762 = slt64(mid_id_75761, (int64_t) 0);
            int64_t mid_idx_75763;
            
            if (cond_75762) {
                mid_idx_75763 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_75763 = mid_id_75761;
            }
            
            bool cond_75764 = sle64(defunc_0_g_res_75291, mid_idx_75763);
            int64_t loopres_75765;
            int64_t loopres_75766;
            
            if (cond_75764) {
                int64_t loopres_t_res_75767 = sub64(mid_75756, (int64_t) 1);
                
                loopres_75765 = low_75753;
                loopres_75766 = loopres_t_res_75767;
            } else {
                int64_t loopres_f_res_75768 = add64((int64_t) 1, mid_75756);
                
                loopres_75765 = loopres_f_res_75768;
                loopres_75766 = high_75754;
            }
            
            bool loop_cond_75769 = sle64(loopres_75765, loopres_75766);
            bool loop_while_tmp_75860 = loop_cond_75769;
            int64_t low_tmp_75861 = loopres_75765;
            int64_t high_tmp_75862 = loopres_75766;
            
            loop_while_75752 = loop_while_tmp_75860;
            low_75753 = low_tmp_75861;
            high_75754 = high_tmp_75862;
        }
        init_idx_75292 = loop_while_75752;
        init_idx_75293 = low_75753;
        init_idx_75294 = high_75754;
        
        bool idx_75313;
        int64_t idx_75314;
        int64_t idx_75315;
        int64_t idx_75316;
        bool loop_while_75770;
        int64_t l_idx_75771;
        int64_t r_idx_75772;
        int64_t span_75773;
        
        loop_while_75770 = loop_cond_65403;
        l_idx_75771 = init_idx_75293;
        r_idx_75772 = init_idx_75293;
        span_75773 = (int64_t) 1;
        while (loop_while_75770) {
            int64_t max_arg_75774 = sub64(l_idx_75771, (int64_t) 1);
            int64_t max_res_75775 = smax64((int64_t) 0, max_arg_75774);
            int64_t min_arg_75776 = add64((int64_t) 1, r_idx_75772);
            int64_t min_res_75777 = smin64(min_arg_69102, min_arg_75776);
            bool x_75778 = sle64((int64_t) 0, max_res_75775);
            bool y_75779 = slt64(max_res_75775, n_65378);
            bool bounds_check_75780 = x_75778 && y_75779;
            bool index_certs_75781;
            
            if (!bounds_check_75780) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_75775,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_75782;
            
            x_75782 = ((int64_t *) mem_71152.mem)[max_res_75775];
            
            int64_t abs_arg_75783 = sub64(x_75782, defunc_0_g_res_75291);
            int64_t abs_res_75784 = abs64(abs_arg_75783);
            bool x_75785 = sle64((int64_t) 0, min_res_75777);
            bool y_75786 = slt64(min_res_75777, n_65378);
            bool bounds_check_75787 = x_75785 && y_75786;
            bool index_certs_75788;
            
            if (!bounds_check_75787) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_75777,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_75789;
            
            x_75789 = ((int64_t *) mem_71152.mem)[min_res_75777];
            
            int64_t abs_arg_75790 = sub64(x_75789, defunc_0_g_res_75291);
            int64_t abs_res_75791 = abs64(abs_arg_75790);
            bool cond_75792 = max_res_75775 == l_idx_75771;
            int64_t loopres_75793;
            int64_t loopres_75794;
            int64_t loopres_75795;
            
            if (cond_75792) {
                loopres_75793 = l_idx_75771;
                loopres_75794 = r_idx_75772;
                loopres_75795 = min_res_65398;
            } else {
                bool cond_75796 = slt64(abs_res_75784, abs_res_75791);
                bool cond_f_res_75797 = min_res_75777 == r_idx_75772;
                bool x_75798 = !cond_75796;
                bool y_75799 = cond_f_res_75797 && x_75798;
                bool cond_75800 = cond_75796 || y_75799;
                int64_t loopres_f_res_75801;
                
                if (cond_75800) {
                    loopres_f_res_75801 = max_res_75775;
                } else {
                    loopres_f_res_75801 = l_idx_75771;
                }
                
                int64_t loopres_f_res_75802;
                
                if (cond_75800) {
                    loopres_f_res_75802 = r_idx_75772;
                } else {
                    loopres_f_res_75802 = min_res_75777;
                }
                
                int64_t loopres_f_res_75803;
                
                if (cond_75800) {
                    int64_t loopres_f_res_t_res_75804 = add64((int64_t) 1,
                                                              span_75773);
                    
                    loopres_f_res_75803 = loopres_f_res_t_res_75804;
                } else {
                    int64_t loopres_f_res_f_res_75805 = add64((int64_t) 1,
                                                              span_75773);
                    
                    loopres_f_res_75803 = loopres_f_res_f_res_75805;
                }
                loopres_75793 = loopres_f_res_75801;
                loopres_75794 = loopres_f_res_75802;
                loopres_75795 = loopres_f_res_75803;
            }
            
            bool loop_cond_75806 = slt64(loopres_75795, min_res_65398);
            bool loop_while_tmp_75863 = loop_cond_75806;
            int64_t l_idx_tmp_75864 = loopres_75793;
            int64_t r_idx_tmp_75865 = loopres_75794;
            int64_t span_tmp_75866 = loopres_75795;
            
            loop_while_75770 = loop_while_tmp_75863;
            l_idx_75771 = l_idx_tmp_75864;
            r_idx_75772 = r_idx_tmp_75865;
            span_75773 = span_tmp_75866;
        }
        idx_75313 = loop_while_75770;
        idx_75314 = l_idx_75771;
        idx_75315 = r_idx_75772;
        idx_75316 = span_75773;
        
        int64_t min_res_75354 = smin64(min_arg_69103, idx_75314);
        int64_t max_res_75355 = smax64((int64_t) 0, min_res_75354);
        int64_t x_75356 = add64(min_res_69104, max_res_75355);
        int64_t r_75357 = sub64(x_75356, (int64_t) 1);
        bool x_75358 = sle64((int64_t) 0, r_75357);
        bool y_75359 = slt64(r_75357, n_65378);
        bool bounds_check_75360 = x_75358 && y_75359;
        bool index_certs_75361;
        
        if (!bounds_check_75360) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_75357,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_75362;
        
        x_75362 = ((int64_t *) mem_71149.mem)[r_75357];
        
        int64_t abs_arg_75363 = sub64(x_75362, min_res_75290);
        int64_t abs_res_75364 = abs64(abs_arg_75363);
        bool x_75365 = sle64((int64_t) 0, max_res_75355);
        bool y_75366 = slt64(max_res_75355, n_65378);
        bool bounds_check_75367 = x_75365 && y_75366;
        bool index_certs_75368;
        
        if (!bounds_check_75367) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_75355,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_75369;
        
        x_75369 = ((int64_t *) mem_71149.mem)[max_res_75355];
        
        int64_t abs_arg_75370 = sub64(x_75369, min_res_75290);
        int64_t abs_res_75371 = abs64(abs_arg_75370);
        int64_t max_res_75372 = smax64(abs_res_75364, abs_res_75371);
        double defunc_0_f_res_75373 = sitofp_i64_f64(max_res_75372);
        double defunc_1_f_res_75374 = max_res_69108 + defunc_0_f_res_75373;
        double defunc_2_reduce_res_75377;
        double defunc_2_reduce_res_75378;
        double defunc_2_reduce_res_75379;
        int64_t flat_tid_75807 = (int64_t) 0;
        int32_t num_tasks_75867;
        
        defunc_2_reduce_res_75377 = 0.0;
        defunc_2_reduce_res_75378 = 0.0;
        defunc_2_reduce_res_75379 = 0.0;
        
        struct futhark_mc_task_77345 futhark_mc_task_77345;
        
        futhark_mc_task_77345.ctx = ctx;
        futhark_mc_task_77345.free_last_res_69083 = last_res_69083;
        futhark_mc_task_77345.free_mem_71149 = mem_71149.mem;
        futhark_mc_task_77345.free_mem_71155 = mem_71155.mem;
        futhark_mc_task_77345.free_min_res_75290 = min_res_75290;
        futhark_mc_task_77345.free_max_res_75355 = max_res_75355;
        futhark_mc_task_77345.free_defunc_1_f_res_75374 = defunc_1_f_res_75374;
        futhark_mc_task_77345.retval_defunc_2_reduce_res_75377 =
            &defunc_2_reduce_res_75377;
        futhark_mc_task_77345.retval_defunc_2_reduce_res_75378 =
            &defunc_2_reduce_res_75378;
        futhark_mc_task_77345.retval_defunc_2_reduce_res_75379 =
            &defunc_2_reduce_res_75379;
        futhark_mc_task_77345.retval_mem_75375 = mem_75375;
        futhark_mc_task_77345.retval_mem_75376 = mem_75376;
        
        struct scheduler_segop futhark_mc_task_77345_task;
        
        futhark_mc_task_77345_task.args = &futhark_mc_task_77345;
        futhark_mc_task_77345_task.top_level_fn = futhark_mc_segred_task_77346;
        futhark_mc_task_77345_task.name = "futhark_mc_segred_task_77346";
        futhark_mc_task_77345_task.iterations = q_65380;
        futhark_mc_task_77345_task.task_time =
            &ctx->futhark_mc_segred_task_77346_total_time;
        futhark_mc_task_77345_task.task_iter =
            &ctx->futhark_mc_segred_task_77346_total_iter;
        futhark_mc_task_77345_task.sched = STATIC;
        futhark_mc_task_77345_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77346_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77345_task);
        
        if (futhark_mc_segred_task_77346_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double x_75411 = defunc_2_reduce_res_75377 * defunc_2_reduce_res_75379;
        double y_75412 = defunc_2_reduce_res_75378 * defunc_2_reduce_res_75378;
        double y_75413 = x_75411 - y_75412;
        double det1_75414 = 1.0 / y_75413;
        double a11_75415 = defunc_2_reduce_res_75379 * det1_75414;
        double x_75416 = 0.0 - defunc_2_reduce_res_75378;
        double b11_75417 = det1_75414 * x_75416;
        double c11_75418 = defunc_2_reduce_res_75377 * det1_75414;
        double defunc_2_reduce_res_75419;
        double defunc_2_reduce_res_75420;
        int64_t flat_tid_75836 = (int64_t) 0;
        int32_t num_tasks_75888;
        
        defunc_2_reduce_res_75419 = 0.0;
        defunc_2_reduce_res_75420 = 0.0;
        
        struct futhark_mc_task_77352 futhark_mc_task_77352;
        
        futhark_mc_task_77352.ctx = ctx;
        futhark_mc_task_77352.free_last_res_69083 = last_res_69083;
        futhark_mc_task_77352.free_mem_71146 = mem_71146.mem;
        futhark_mc_task_77352.free_max_res_75355 = max_res_75355;
        futhark_mc_task_77352.free_mem_75375 = mem_75375;
        futhark_mc_task_77352.free_mem_75376 = mem_75376;
        futhark_mc_task_77352.free_a11_75415 = a11_75415;
        futhark_mc_task_77352.free_b11_75417 = b11_75417;
        futhark_mc_task_77352.free_c11_75418 = c11_75418;
        futhark_mc_task_77352.retval_defunc_2_reduce_res_75419 =
            &defunc_2_reduce_res_75419;
        futhark_mc_task_77352.retval_defunc_2_reduce_res_75420 =
            &defunc_2_reduce_res_75420;
        
        struct scheduler_segop futhark_mc_task_77352_task;
        
        futhark_mc_task_77352_task.args = &futhark_mc_task_77352;
        futhark_mc_task_77352_task.top_level_fn = futhark_mc_segred_task_77353;
        futhark_mc_task_77352_task.name = "futhark_mc_segred_task_77353";
        futhark_mc_task_77352_task.iterations = q_65380;
        futhark_mc_task_77352_task.task_time =
            &ctx->futhark_mc_segred_task_77353_total_time;
        futhark_mc_task_77352_task.task_iter =
            &ctx->futhark_mc_segred_task_77353_total_iter;
        futhark_mc_task_77352_task.sched = STATIC;
        futhark_mc_task_77352_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77353_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77352_task);
        
        if (futhark_mc_segred_task_77353_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        ((double *) mem_71194.mem)[gtid_75288] = defunc_2_reduce_res_75419;
        ((double *) mem_71197.mem)[gtid_75288] = defunc_2_reduce_res_75420;
    }
    
  cleanup:
    { }
    free(mem_75375);
    free(mem_75376);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77342_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77342_end -
                 futhark_mc_segmap_parloop_77342_start;
        
        ctx->futhark_mc_segmap_parloop_77342_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77342_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77342_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77340(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_75287 = tid;
    int num_tasks_75630 = info.nsubtasks;
    struct futhark_mc_task_77334 *futhark_mc_task_77334 =
                                 (struct futhark_mc_task_77334 *) args;
    struct futhark_context *ctx = futhark_mc_task_77334->ctx;
    uint64_t futhark_mc_segmap_nested_task_77340_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77340_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77334->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77334->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77334->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77334->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77334->free_i_65392;
    bool x_65393 = futhark_mc_task_77334->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77334->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77334->free_loop_cond_65403;
    int64_t last_res_69083 = futhark_mc_task_77334->free_last_res_69083;
    int64_t min_arg_69102 = futhark_mc_task_77334->free_min_arg_69102;
    int64_t min_arg_69103 = futhark_mc_task_77334->free_min_arg_69103;
    int64_t min_res_69104 = futhark_mc_task_77334->free_min_res_69104;
    double max_res_69108 = futhark_mc_task_77334->free_max_res_69108;
    struct memblock mem_71146 = {.desc ="mem_71146", .mem =
                                 futhark_mc_task_77334->free_mem_71146, .size =
                                 0, .references =NULL};
    struct memblock mem_71149 = {.desc ="mem_71149", .mem =
                                 futhark_mc_task_77334->free_mem_71149, .size =
                                 0, .references =NULL};
    struct memblock mem_71152 = {.desc ="mem_71152", .mem =
                                 futhark_mc_task_77334->free_mem_71152, .size =
                                 0, .references =NULL};
    int64_t bytes_71154 = futhark_mc_task_77334->free_bytes_71154;
    struct memblock mem_71155 = {.desc ="mem_71155", .mem =
                                 futhark_mc_task_77334->free_mem_71155, .size =
                                 0, .references =NULL};
    struct memblock mem_71194 = {.desc ="mem_71194", .mem =
                                 futhark_mc_task_77334->free_mem_71194, .size =
                                 0, .references =NULL};
    struct memblock mem_71197 = {.desc ="mem_71197", .mem =
                                 futhark_mc_task_77334->free_mem_71197, .size =
                                 0, .references =NULL};
    int64_t iter_75751;
    struct futhark_mc_segmap_parloop_struct_77341
    futhark_mc_segmap_parloop_struct_77341;
    
    futhark_mc_segmap_parloop_struct_77341.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77341.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77341.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77341.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77341.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77341.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77341.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77341.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77341.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77341.free_last_res_69083 = last_res_69083;
    futhark_mc_segmap_parloop_struct_77341.free_min_arg_69102 = min_arg_69102;
    futhark_mc_segmap_parloop_struct_77341.free_min_arg_69103 = min_arg_69103;
    futhark_mc_segmap_parloop_struct_77341.free_min_res_69104 = min_res_69104;
    futhark_mc_segmap_parloop_struct_77341.free_max_res_69108 = max_res_69108;
    futhark_mc_segmap_parloop_struct_77341.free_mem_71146 = mem_71146.mem;
    futhark_mc_segmap_parloop_struct_77341.free_mem_71149 = mem_71149.mem;
    futhark_mc_segmap_parloop_struct_77341.free_mem_71152 = mem_71152.mem;
    futhark_mc_segmap_parloop_struct_77341.free_bytes_71154 = bytes_71154;
    futhark_mc_segmap_parloop_struct_77341.free_mem_71155 = mem_71155.mem;
    futhark_mc_segmap_parloop_struct_77341.free_mem_71194 = mem_71194.mem;
    futhark_mc_segmap_parloop_struct_77341.free_mem_71197 = mem_71197.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77342_task;
    
    futhark_mc_segmap_parloop_77342_task.name =
        "futhark_mc_segmap_parloop_77342";
    futhark_mc_segmap_parloop_77342_task.fn = futhark_mc_segmap_parloop_77342;
    futhark_mc_segmap_parloop_77342_task.args =
        &futhark_mc_segmap_parloop_struct_77341;
    futhark_mc_segmap_parloop_77342_task.iterations = iterations;
    futhark_mc_segmap_parloop_77342_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77342_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77342_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77342_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77342_task);
    
    if (futhark_mc_segmap_parloop_77342_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77342_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77342_total_end -
                 futhark_mc_segmap_parloop_77342_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77342_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77342_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77342_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77340_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77340_end -
                 futhark_mc_segmap_nested_task_77340_start;
        
        ctx->futhark_mc_segmap_nested_task_77340_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77340_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77340_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77307(void *args, int64_t start,
                                           int64_t end, int flat_tid_69070,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77306
    *futhark_mc_segmap_parloop_struct_77306 =
    (struct futhark_mc_segmap_parloop_struct_77306 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77306->ctx;
    uint64_t futhark_mc_segmap_parloop_77307_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77307_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77306->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77306->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77306->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77306->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77306->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77306->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77306->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77306->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77306->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77306->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77306->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71142 =
            futhark_mc_segmap_parloop_struct_77306->free_bytes_71142;
    int64_t bytes_71154 =
            futhark_mc_segmap_parloop_struct_77306->free_bytes_71154;
    int64_t bytes_71193 =
            futhark_mc_segmap_parloop_struct_77306->free_bytes_71193;
    struct memblock mem_71336 = {.desc ="mem_71336", .mem =
                                 futhark_mc_segmap_parloop_struct_77306->free_mem_71336,
                                 .size =0, .references =NULL};
    struct memblock mem_71340 = {.desc ="mem_71340", .mem =
                                 futhark_mc_segmap_parloop_struct_77306->free_mem_71340,
                                 .size =0, .references =NULL};
    size_t mem_71143_cached_sizze_77308 = 0;
    unsigned char *mem_71143 = NULL;
    size_t mem_71146_cached_sizze_77309 = 0;
    unsigned char *mem_71146 = NULL;
    size_t mem_71149_cached_sizze_77310 = 0;
    unsigned char *mem_71149 = NULL;
    size_t mem_71152_cached_sizze_77311 = 0;
    unsigned char *mem_71152 = NULL;
    size_t mem_71155_cached_sizze_77312 = 0;
    unsigned char *mem_71155 = NULL;
    size_t mem_71194_cached_sizze_77313 = 0;
    unsigned char *mem_71194 = NULL;
    size_t mem_71197_cached_sizze_77314 = 0;
    unsigned char *mem_71197 = NULL;
    int64_t iterations = end - start;
    int64_t iter_75261 = start;
    
    if (mem_71143_cached_sizze_77308 < (size_t) bytes_71142) {
        mem_71143 = realloc(mem_71143, bytes_71142);
        mem_71143_cached_sizze_77308 = bytes_71142;
    }
    if (mem_71146_cached_sizze_77309 < (size_t) bytes_71142) {
        mem_71146 = realloc(mem_71146, bytes_71142);
        mem_71146_cached_sizze_77309 = bytes_71142;
    }
    if (mem_71149_cached_sizze_77310 < (size_t) bytes_71142) {
        mem_71149 = realloc(mem_71149, bytes_71142);
        mem_71149_cached_sizze_77310 = bytes_71142;
    }
    if (mem_71152_cached_sizze_77311 < (size_t) bytes_71142) {
        mem_71152 = realloc(mem_71152, bytes_71142);
        mem_71152_cached_sizze_77311 = bytes_71142;
    }
    if (mem_71155_cached_sizze_77312 < (size_t) bytes_71154) {
        mem_71155 = realloc(mem_71155, bytes_71154);
        mem_71155_cached_sizze_77312 = bytes_71154;
    }
    if (mem_71194_cached_sizze_77313 < (size_t) bytes_71193) {
        mem_71194 = realloc(mem_71194, bytes_71193);
        mem_71194_cached_sizze_77313 = bytes_71193;
    }
    if (mem_71197_cached_sizze_77314 < (size_t) bytes_71193) {
        mem_71197 = realloc(mem_71197, bytes_71193);
        mem_71197_cached_sizze_77314 = bytes_71193;
    }
    for (; iter_75261 < end; iter_75261++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_75598 = m_65377;
        int64_t gtid_69071 = iter_75261;
        int64_t remnant_75599 = iter_75261 - gtid_69071;
        int64_t flat_tid_75262 = (int64_t) 0;
        int32_t num_tasks_75600;
        
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmented segScan");
        
        struct futhark_mc_task_77315 futhark_mc_task_77315;
        
        futhark_mc_task_77315.ctx = ctx;
        futhark_mc_task_77315.free_n_65378 = n_65378;
        futhark_mc_task_77315.free_gtid_69071 = gtid_69071;
        futhark_mc_task_77315.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77315.free_mem_71143 = mem_71143;
        
        struct scheduler_segop futhark_mc_task_77315_task;
        
        futhark_mc_task_77315_task.args = &futhark_mc_task_77315;
        futhark_mc_task_77315_task.top_level_fn = futhark_mc_segscan_task_77316;
        futhark_mc_task_77315_task.name = "futhark_mc_segscan_task_77316";
        futhark_mc_task_77315_task.iterations = n_65378;
        futhark_mc_task_77315_task.task_time =
            &ctx->futhark_mc_segscan_task_77316_total_time;
        futhark_mc_task_77315_task.task_iter =
            &ctx->futhark_mc_segscan_task_77316_total_iter;
        futhark_mc_task_77315_task.sched = STATIC;
        futhark_mc_task_77315_task.nested_fn = NULL;
        
        int futhark_mc_segscan_task_77316_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77315_task);
        
        if (futhark_mc_segscan_task_77316_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t last_res_69083;
        
        last_res_69083 = ((int64_t *) mem_71143)[i_65392];
        for (int64_t i_75614 = 0; i_75614 < n_65378; i_75614++) {
            ((double *) mem_71146)[i_75614] = 0.0;
        }
        for (int64_t i_75615 = 0; i_75615 < n_65378; i_75615++) {
            ((int64_t *) mem_71149)[i_75615] = (int64_t) -1;
        }
        
        int64_t flat_tid_75271 = (int64_t) 0;
        int32_t num_tasks_75616;
        struct futhark_mc_task_77322 futhark_mc_task_77322;
        
        futhark_mc_task_77322.ctx = ctx;
        futhark_mc_task_77322.free_n_65378 = n_65378;
        futhark_mc_task_77322.free_gtid_69071 = gtid_69071;
        futhark_mc_task_77322.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77322.free_mem_71143 = mem_71143;
        futhark_mc_task_77322.free_mem_71146 = mem_71146;
        futhark_mc_task_77322.free_mem_71149 = mem_71149;
        
        struct scheduler_segop futhark_mc_task_77322_task;
        
        futhark_mc_task_77322_task.args = &futhark_mc_task_77322;
        futhark_mc_task_77322_task.top_level_fn = futhark_mc_segmap_task_77323;
        futhark_mc_task_77322_task.name = "futhark_mc_segmap_task_77323";
        futhark_mc_task_77322_task.iterations = n_65378;
        futhark_mc_task_77322_task.task_time =
            &ctx->futhark_mc_segmap_task_77323_total_time;
        futhark_mc_task_77322_task.task_iter =
            &ctx->futhark_mc_segmap_task_77323_total_iter;
        futhark_mc_task_77322_task.sched = STATIC;
        futhark_mc_task_77322_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77323_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77322_task);
        
        if (futhark_mc_segmap_task_77323_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_75279 = (int64_t) 0;
        int32_t num_tasks_75622;
        struct futhark_mc_task_77326 futhark_mc_task_77326;
        
        futhark_mc_task_77326.ctx = ctx;
        futhark_mc_task_77326.free_n_65378 = n_65378;
        futhark_mc_task_77326.free_mem_71149 = mem_71149;
        futhark_mc_task_77326.free_mem_71152 = mem_71152;
        
        struct scheduler_segop futhark_mc_task_77326_task;
        
        futhark_mc_task_77326_task.args = &futhark_mc_task_77326;
        futhark_mc_task_77326_task.top_level_fn = futhark_mc_segmap_task_77327;
        futhark_mc_task_77326_task.name = "futhark_mc_segmap_task_77327";
        futhark_mc_task_77326_task.iterations = n_65378;
        futhark_mc_task_77326_task.task_time =
            &ctx->futhark_mc_segmap_task_77327_total_time;
        futhark_mc_task_77326_task.task_iter =
            &ctx->futhark_mc_segmap_task_77327_total_iter;
        futhark_mc_task_77326_task.sched = STATIC;
        futhark_mc_task_77326_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77327_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77326_task);
        
        if (futhark_mc_segmap_task_77327_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t min_arg_69102 = sub64(last_res_69083, (int64_t) 1);
        int64_t min_arg_69103 = sub64(last_res_69083, min_res_65398);
        int64_t min_res_69104 = smin64(q_65380, last_res_69083);
        double i64_res_69105 = sitofp_i64_f64(last_res_69083);
        double x_69106 = i64_res_65404 - i64_res_69105;
        double max_arg_69107 = x_69106 / 2.0;
        double max_res_69108 = fmax64(0.0, max_arg_69107);
        int64_t flat_tid_75283 = (int64_t) 0;
        int32_t num_tasks_75626;
        struct futhark_mc_task_77330 futhark_mc_task_77330;
        
        futhark_mc_task_77330.ctx = ctx;
        futhark_mc_task_77330.free_q_65380 = q_65380;
        futhark_mc_task_77330.free_last_res_69083 = last_res_69083;
        futhark_mc_task_77330.free_mem_71155 = mem_71155;
        
        struct scheduler_segop futhark_mc_task_77330_task;
        
        futhark_mc_task_77330_task.args = &futhark_mc_task_77330;
        futhark_mc_task_77330_task.top_level_fn = futhark_mc_segmap_task_77331;
        futhark_mc_task_77330_task.name = "futhark_mc_segmap_task_77331";
        futhark_mc_task_77330_task.iterations = q_65380;
        futhark_mc_task_77330_task.task_time =
            &ctx->futhark_mc_segmap_task_77331_total_time;
        futhark_mc_task_77330_task.task_iter =
            &ctx->futhark_mc_segmap_task_77331_total_iter;
        futhark_mc_task_77330_task.sched = STATIC;
        futhark_mc_task_77330_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77331_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77330_task);
        
        if (futhark_mc_segmap_task_77331_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_75443 = (int64_t) 0;
        int32_t num_tasks_75630;
        int64_t flat_tid_75287 = (int64_t) 0;
        struct futhark_mc_task_77334 futhark_mc_task_77334;
        
        futhark_mc_task_77334.ctx = ctx;
        futhark_mc_task_77334.free_n_65378 = n_65378;
        futhark_mc_task_77334.free_q_65380 = q_65380;
        futhark_mc_task_77334.free_jump_65382 = jump_65382;
        futhark_mc_task_77334.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77334.free_i_65392 = i_65392;
        futhark_mc_task_77334.free_x_65393 = x_65393;
        futhark_mc_task_77334.free_min_res_65398 = min_res_65398;
        futhark_mc_task_77334.free_loop_cond_65403 = loop_cond_65403;
        futhark_mc_task_77334.free_last_res_69083 = last_res_69083;
        futhark_mc_task_77334.free_min_arg_69102 = min_arg_69102;
        futhark_mc_task_77334.free_min_arg_69103 = min_arg_69103;
        futhark_mc_task_77334.free_min_res_69104 = min_res_69104;
        futhark_mc_task_77334.free_max_res_69108 = max_res_69108;
        futhark_mc_task_77334.free_mem_71146 = mem_71146;
        futhark_mc_task_77334.free_mem_71149 = mem_71149;
        futhark_mc_task_77334.free_mem_71152 = mem_71152;
        futhark_mc_task_77334.free_bytes_71154 = bytes_71154;
        futhark_mc_task_77334.free_mem_71155 = mem_71155;
        futhark_mc_task_77334.free_mem_71194 = mem_71194;
        futhark_mc_task_77334.free_mem_71197 = mem_71197;
        
        struct scheduler_segop futhark_mc_task_77334_task;
        
        futhark_mc_task_77334_task.args = &futhark_mc_task_77334;
        futhark_mc_task_77334_task.top_level_fn = futhark_mc_segmap_task_77335;
        futhark_mc_task_77334_task.name = "futhark_mc_segmap_task_77335";
        futhark_mc_task_77334_task.iterations = n_m_65386;
        futhark_mc_task_77334_task.task_time =
            &ctx->futhark_mc_segmap_task_77335_total_time;
        futhark_mc_task_77334_task.task_iter =
            &ctx->futhark_mc_segmap_task_77335_total_iter;
        futhark_mc_task_77334_task.sched = DYNAMIC;
        futhark_mc_task_77334_task.nested_fn =
            futhark_mc_segmap_nested_task_77340;
        
        int futhark_mc_segmap_task_77335_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77334_task);
        
        if (futhark_mc_segmap_task_77335_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71336.mem + gtid_69071 * n_m_65386 * (int64_t) 8,
                    mem_71194 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71340.mem + gtid_69071 * n_m_65386 * (int64_t) 8,
                    mem_71197 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71143);
    free(mem_71146);
    free(mem_71149);
    free(mem_71152);
    free(mem_71155);
    free(mem_71194);
    free(mem_71197);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77307_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77307_end -
                 futhark_mc_segmap_parloop_77307_start;
        
        ctx->futhark_mc_segmap_parloop_77307_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77307_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77307_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77305(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_69070 = tid;
    int num_tasks_75046 = info.nsubtasks;
    struct futhark_mc_task_77292 *futhark_mc_task_77292 =
                                 (struct futhark_mc_task_77292 *) args;
    struct futhark_context *ctx = futhark_mc_task_77292->ctx;
    uint64_t futhark_mc_segmap_nested_task_77305_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77305_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77292->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77292->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77292->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77292->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77292->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77292->free_i_65392;
    bool x_65393 = futhark_mc_task_77292->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77292->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77292->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77292->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77292->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71142 = futhark_mc_task_77292->free_bytes_71142;
    int64_t bytes_71154 = futhark_mc_task_77292->free_bytes_71154;
    int64_t bytes_71193 = futhark_mc_task_77292->free_bytes_71193;
    struct memblock mem_71336 = {.desc ="mem_71336", .mem =
                                 futhark_mc_task_77292->free_mem_71336, .size =
                                 0, .references =NULL};
    struct memblock mem_71340 = {.desc ="mem_71340", .mem =
                                 futhark_mc_task_77292->free_mem_71340, .size =
                                 0, .references =NULL};
    int64_t iter_75261;
    struct futhark_mc_segmap_parloop_struct_77306
    futhark_mc_segmap_parloop_struct_77306;
    
    futhark_mc_segmap_parloop_struct_77306.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77306.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77306.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77306.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77306.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77306.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77306.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77306.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77306.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77306.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77306.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77306.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77306.free_bytes_71142 = bytes_71142;
    futhark_mc_segmap_parloop_struct_77306.free_bytes_71154 = bytes_71154;
    futhark_mc_segmap_parloop_struct_77306.free_bytes_71193 = bytes_71193;
    futhark_mc_segmap_parloop_struct_77306.free_mem_71336 = mem_71336.mem;
    futhark_mc_segmap_parloop_struct_77306.free_mem_71340 = mem_71340.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77307_task;
    
    futhark_mc_segmap_parloop_77307_task.name =
        "futhark_mc_segmap_parloop_77307";
    futhark_mc_segmap_parloop_77307_task.fn = futhark_mc_segmap_parloop_77307;
    futhark_mc_segmap_parloop_77307_task.args =
        &futhark_mc_segmap_parloop_struct_77306;
    futhark_mc_segmap_parloop_77307_task.iterations = iterations;
    futhark_mc_segmap_parloop_77307_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77307_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77307_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77307_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77307_task);
    
    if (futhark_mc_segmap_parloop_77307_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77307_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77307_total_end -
                 futhark_mc_segmap_parloop_77307_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77307_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77307_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77307_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77305_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77305_end -
                 futhark_mc_segmap_nested_task_77305_start;
        
        ctx->futhark_mc_segmap_nested_task_77305_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77305_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77305_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77358 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_71342;
    int64_t free_bytes_71354;
    int64_t free_bytes_71429;
    unsigned char *free_mem_71602;
    unsigned char *free_mem_71606;
};
struct futhark_mc_segmap_parloop_struct_77360 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_71342;
    int64_t free_bytes_71354;
    int64_t free_bytes_71429;
    unsigned char *free_mem_71602;
    unsigned char *free_mem_71606;
};
static int futhark_mc_segmap_parloop_77361(void *args, int64_t start,
                                           int64_t end, int flat_tid_69427,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77360
    *futhark_mc_segmap_parloop_struct_77360 =
    (struct futhark_mc_segmap_parloop_struct_77360 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77360->ctx;
    uint64_t futhark_mc_segmap_parloop_77361_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77361_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77360->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77360->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77360->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77360->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77360->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77360->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77360->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77360->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77360->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77360->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77360->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71342 =
            futhark_mc_segmap_parloop_struct_77360->free_bytes_71342;
    int64_t bytes_71354 =
            futhark_mc_segmap_parloop_struct_77360->free_bytes_71354;
    int64_t bytes_71429 =
            futhark_mc_segmap_parloop_struct_77360->free_bytes_71429;
    struct memblock mem_71602 = {.desc ="mem_71602", .mem =
                                 futhark_mc_segmap_parloop_struct_77360->free_mem_71602,
                                 .size =0, .references =NULL};
    struct memblock mem_71606 = {.desc ="mem_71606", .mem =
                                 futhark_mc_segmap_parloop_struct_77360->free_mem_71606,
                                 .size =0, .references =NULL};
    size_t mem_71436_cached_sizze_77362 = 0;
    unsigned char *mem_71436 = NULL;
    size_t mem_71451_cached_sizze_77363 = 0;
    unsigned char *mem_71451 = NULL;
    size_t mem_71454_cached_sizze_77364 = 0;
    unsigned char *mem_71454 = NULL;
    size_t mem_71481_cached_sizze_77365 = 0;
    unsigned char *mem_71481 = NULL;
    size_t mem_71496_cached_sizze_77366 = 0;
    unsigned char *mem_71496 = NULL;
    size_t mem_71511_cached_sizze_77367 = 0;
    unsigned char *mem_71511 = NULL;
    size_t mem_71514_cached_sizze_77368 = 0;
    unsigned char *mem_71514 = NULL;
    size_t mem_71531_cached_sizze_77369 = 0;
    unsigned char *mem_71531 = NULL;
    size_t mem_71534_cached_sizze_77370 = 0;
    unsigned char *mem_71534 = NULL;
    size_t mem_71561_cached_sizze_77371 = 0;
    unsigned char *mem_71561 = NULL;
    size_t mem_71564_cached_sizze_77372 = 0;
    unsigned char *mem_71564 = NULL;
    int64_t iterations = end - start;
    int64_t iter_75904 = start;
    
    if (mem_71436_cached_sizze_77362 < (size_t) bytes_71342) {
        mem_71436 = realloc(mem_71436, bytes_71342);
        mem_71436_cached_sizze_77362 = bytes_71342;
    }
    if (mem_71451_cached_sizze_77363 < (size_t) bytes_71342) {
        mem_71451 = realloc(mem_71451, bytes_71342);
        mem_71451_cached_sizze_77363 = bytes_71342;
    }
    if (mem_71454_cached_sizze_77364 < (size_t) bytes_71342) {
        mem_71454 = realloc(mem_71454, bytes_71342);
        mem_71454_cached_sizze_77364 = bytes_71342;
    }
    if (mem_71481_cached_sizze_77365 < (size_t) bytes_71342) {
        mem_71481 = realloc(mem_71481, bytes_71342);
        mem_71481_cached_sizze_77365 = bytes_71342;
    }
    if (mem_71496_cached_sizze_77366 < (size_t) bytes_71354) {
        mem_71496 = realloc(mem_71496, bytes_71354);
        mem_71496_cached_sizze_77366 = bytes_71354;
    }
    if (mem_71511_cached_sizze_77367 < (size_t) bytes_71429) {
        mem_71511 = realloc(mem_71511, bytes_71429);
        mem_71511_cached_sizze_77367 = bytes_71429;
    }
    if (mem_71514_cached_sizze_77368 < (size_t) bytes_71429) {
        mem_71514 = realloc(mem_71514, bytes_71429);
        mem_71514_cached_sizze_77368 = bytes_71429;
    }
    if (mem_71531_cached_sizze_77369 < (size_t) bytes_71354) {
        mem_71531 = realloc(mem_71531, bytes_71354);
        mem_71531_cached_sizze_77369 = bytes_71354;
    }
    if (mem_71534_cached_sizze_77370 < (size_t) bytes_71354) {
        mem_71534 = realloc(mem_71534, bytes_71354);
        mem_71534_cached_sizze_77370 = bytes_71354;
    }
    if (mem_71561_cached_sizze_77371 < (size_t) bytes_71354) {
        mem_71561 = realloc(mem_71561, bytes_71354);
        mem_71561_cached_sizze_77371 = bytes_71354;
    }
    if (mem_71564_cached_sizze_77372 < (size_t) bytes_71354) {
        mem_71564 = realloc(mem_71564, bytes_71354);
        mem_71564_cached_sizze_77372 = bytes_71354;
    }
    for (; iter_75904 < end; iter_75904++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76133 = m_65377;
        int64_t gtid_69428 = iter_75904;
        int64_t remnant_76134 = iter_75904 - gtid_69428;
        int64_t discard_70455;
        int64_t scanacc_75906 = (int64_t) 0;
        
        for (int64_t i_75905 = 0; i_75905 < n_65378; i_75905++) {
            double x_75908;
            
            x_75908 = ((double *) Y_mem_70603.mem)[gtid_69428 * n_65378 +
                                                   i_75905];
            
            bool isnan_res_75909;
            
            isnan_res_75909 = futrts_isnan64(x_75908);
            
            bool defunc_0_p_res_75910 = !isnan_res_75909;
            int64_t defunc_0_f_res_75911 = btoi_bool_i64(defunc_0_p_res_75910);
            int64_t defunc_1_op_res_75912 = add64(defunc_0_f_res_75911,
                                                  scanacc_75906);
            
            ((int64_t *) mem_71436)[i_75905] = defunc_1_op_res_75912;
            
            int64_t scanacc_tmp_76135 = defunc_1_op_res_75912;
            
            scanacc_75906 = scanacc_tmp_76135;
        }
        discard_70455 = scanacc_75906;
        
        int64_t last_res_66436;
        
        last_res_66436 = ((int64_t *) mem_71436)[i_65392];
        for (int64_t i_76137 = 0; i_76137 < n_65378; i_76137++) {
            ((double *) mem_71451)[i_76137] = 0.0;
        }
        for (int64_t i_76138 = 0; i_76138 < n_65378; i_76138++) {
            ((int64_t *) mem_71454)[i_76138] = (int64_t) -1;
        }
        for (int64_t write_iter_75914 = 0; write_iter_75914 < n_65378;
             write_iter_75914++) {
            double write_iv_75917;
            
            write_iv_75917 = ((double *) Y_mem_70603.mem)[gtid_69428 * n_65378 +
                                                          write_iter_75914];
            
            bool isnan_res_75918;
            
            isnan_res_75918 = futrts_isnan64(write_iv_75917);
            
            bool defunc_0_p_res_75919 = !isnan_res_75918;
            int64_t defunc_1_f_res_75920;
            
            if (defunc_0_p_res_75919) {
                int64_t write_iv_75921;
                
                write_iv_75921 = ((int64_t *) mem_71436)[write_iter_75914];
                
                int64_t defunc_1_f_res_t_res_75922 = sub64(write_iv_75921,
                                                           (int64_t) 1);
                
                defunc_1_f_res_75920 = defunc_1_f_res_t_res_75922;
            } else {
                defunc_1_f_res_75920 = (int64_t) -1;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_75920) &&
                slt64(defunc_1_f_res_75920, n_65378)) {
                ((int64_t *) mem_71454)[defunc_1_f_res_75920] =
                    write_iter_75914;
            }
            if (sle64((int64_t) 0, defunc_1_f_res_75920) &&
                slt64(defunc_1_f_res_75920, n_65378)) {
                if ((int64_t) 8 > 0)
                    memmove(mem_71451 + defunc_1_f_res_75920 * (int64_t) 8,
                            Y_mem_70603.mem + (gtid_69428 * n_65378 +
                                               write_iter_75914) * (int64_t) 8,
                            (int64_t) 8);
            }
        }
        for (int64_t i_75926 = 0; i_75926 < n_65378; i_75926++) {
            int64_t x_75928;
            
            x_75928 = ((int64_t *) mem_71454)[i_75926];
            
            int64_t defunc_0_f_res_75929 = add64((int64_t) 1, x_75928);
            
            ((int64_t *) mem_71481)[i_75926] = defunc_0_f_res_75929;
        }
        
        int64_t min_arg_66451 = sub64(last_res_66436, (int64_t) 1);
        int64_t min_arg_66452 = sub64(last_res_66436, min_res_65398);
        int64_t min_res_66453 = smin64(q_65380, last_res_66436);
        double i64_res_66454 = sitofp_i64_f64(last_res_66436);
        double x_66455 = i64_res_65404 - i64_res_66454;
        double max_arg_66456 = x_66455 / 2.0;
        double max_res_66457 = fmax64(0.0, max_arg_66456);
        
        for (int64_t i_75931 = 0; i_75931 < q_65380; i_75931++) {
            bool cond_75933 = sle64(last_res_66436, i_75931);
            double defunc_0_f_res_75934;
            
            if (cond_75933) {
                defunc_0_f_res_75934 = 0.0;
            } else {
                defunc_0_f_res_75934 = 1.0;
            }
            ((double *) mem_71496)[i_75931] = defunc_0_f_res_75934;
        }
        for (int64_t i_75936 = 0; i_75936 < n_m_65386; i_75936++) {
            int64_t min_arg_75939 = mul64(jump_65382, i_75936);
            int64_t min_res_75940 = smin64(i_65392, min_arg_75939);
            int64_t defunc_0_g_res_75941 = add64((int64_t) 1, min_res_75940);
            bool init_idx_75942;
            int64_t init_idx_75943;
            int64_t init_idx_75944;
            bool loop_while_75945;
            int64_t low_75946;
            int64_t high_75947;
            
            loop_while_75945 = x_65393;
            low_75946 = (int64_t) 0;
            high_75947 = i_65392;
            while (loop_while_75945) {
                int64_t x_75948 = add64(low_75946, high_75947);
                int64_t mid_75949 = sdiv64(x_75948, (int64_t) 2);
                bool x_75950 = sle64((int64_t) 0, mid_75949);
                bool y_75951 = slt64(mid_75949, n_65378);
                bool bounds_check_75952 = x_75950 && y_75951;
                bool index_certs_75953;
                
                if (!bounds_check_75952) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) mid_75949,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t mid_id_75954;
                
                mid_id_75954 = ((int64_t *) mem_71481)[mid_75949];
                
                bool cond_75955 = slt64(mid_id_75954, (int64_t) 0);
                int64_t mid_idx_75956;
                
                if (cond_75955) {
                    mid_idx_75956 = (int64_t) 9223372036854775807;
                } else {
                    mid_idx_75956 = mid_id_75954;
                }
                
                bool cond_75957 = sle64(defunc_0_g_res_75941, mid_idx_75956);
                int64_t loopres_75958;
                int64_t loopres_75959;
                
                if (cond_75957) {
                    int64_t loopres_t_res_75960 = sub64(mid_75949, (int64_t) 1);
                    
                    loopres_75958 = low_75946;
                    loopres_75959 = loopres_t_res_75960;
                } else {
                    int64_t loopres_f_res_75961 = add64((int64_t) 1, mid_75949);
                    
                    loopres_75958 = loopres_f_res_75961;
                    loopres_75959 = high_75947;
                }
                
                bool loop_cond_75962 = sle64(loopres_75958, loopres_75959);
                bool loop_while_tmp_76145 = loop_cond_75962;
                int64_t low_tmp_76146 = loopres_75958;
                int64_t high_tmp_76147 = loopres_75959;
                
                loop_while_75945 = loop_while_tmp_76145;
                low_75946 = low_tmp_76146;
                high_75947 = high_tmp_76147;
            }
            init_idx_75942 = loop_while_75945;
            init_idx_75943 = low_75946;
            init_idx_75944 = high_75947;
            
            bool idx_75963;
            int64_t idx_75964;
            int64_t idx_75965;
            int64_t idx_75966;
            bool loop_while_75967;
            int64_t l_idx_75968;
            int64_t r_idx_75969;
            int64_t span_75970;
            
            loop_while_75967 = loop_cond_65403;
            l_idx_75968 = init_idx_75943;
            r_idx_75969 = init_idx_75943;
            span_75970 = (int64_t) 1;
            while (loop_while_75967) {
                int64_t max_arg_75971 = sub64(l_idx_75968, (int64_t) 1);
                int64_t max_res_75972 = smax64((int64_t) 0, max_arg_75971);
                int64_t min_arg_75973 = add64((int64_t) 1, r_idx_75969);
                int64_t min_res_75974 = smin64(min_arg_66451, min_arg_75973);
                bool x_75975 = sle64((int64_t) 0, max_res_75972);
                bool y_75976 = slt64(max_res_75972, n_65378);
                bool bounds_check_75977 = x_75975 && y_75976;
                bool index_certs_75978;
                
                if (!bounds_check_75977) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) max_res_75972,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_75979;
                
                x_75979 = ((int64_t *) mem_71481)[max_res_75972];
                
                int64_t abs_arg_75980 = sub64(x_75979, defunc_0_g_res_75941);
                int64_t abs_res_75981 = abs64(abs_arg_75980);
                bool x_75982 = sle64((int64_t) 0, min_res_75974);
                bool y_75983 = slt64(min_res_75974, n_65378);
                bool bounds_check_75984 = x_75982 && y_75983;
                bool index_certs_75985;
                
                if (!bounds_check_75984) {
                    ctx->error =
                        msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                  "Index [", (long long) min_res_75974,
                                  "] out of bounds for array of shape [",
                                  (long long) n_65378, "].",
                                  "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                    err = 1;
                    goto cleanup;
                }
                
                int64_t x_75986;
                
                x_75986 = ((int64_t *) mem_71481)[min_res_75974];
                
                int64_t abs_arg_75987 = sub64(x_75986, defunc_0_g_res_75941);
                int64_t abs_res_75988 = abs64(abs_arg_75987);
                bool cond_75989 = max_res_75972 == l_idx_75968;
                int64_t loopres_75990;
                int64_t loopres_75991;
                int64_t loopres_75992;
                
                if (cond_75989) {
                    loopres_75990 = l_idx_75968;
                    loopres_75991 = r_idx_75969;
                    loopres_75992 = min_res_65398;
                } else {
                    bool cond_75993 = slt64(abs_res_75981, abs_res_75988);
                    bool cond_f_res_75994 = min_res_75974 == r_idx_75969;
                    bool x_75995 = !cond_75993;
                    bool y_75996 = cond_f_res_75994 && x_75995;
                    bool cond_75997 = cond_75993 || y_75996;
                    int64_t loopres_f_res_75998;
                    
                    if (cond_75997) {
                        loopres_f_res_75998 = max_res_75972;
                    } else {
                        loopres_f_res_75998 = l_idx_75968;
                    }
                    
                    int64_t loopres_f_res_75999;
                    
                    if (cond_75997) {
                        loopres_f_res_75999 = r_idx_75969;
                    } else {
                        loopres_f_res_75999 = min_res_75974;
                    }
                    
                    int64_t loopres_f_res_76000;
                    
                    if (cond_75997) {
                        int64_t loopres_f_res_t_res_76001 = add64((int64_t) 1,
                                                                  span_75970);
                        
                        loopres_f_res_76000 = loopres_f_res_t_res_76001;
                    } else {
                        int64_t loopres_f_res_f_res_76002 = add64((int64_t) 1,
                                                                  span_75970);
                        
                        loopres_f_res_76000 = loopres_f_res_f_res_76002;
                    }
                    loopres_75990 = loopres_f_res_75998;
                    loopres_75991 = loopres_f_res_75999;
                    loopres_75992 = loopres_f_res_76000;
                }
                
                bool loop_cond_76003 = slt64(loopres_75992, min_res_65398);
                bool loop_while_tmp_76148 = loop_cond_76003;
                int64_t l_idx_tmp_76149 = loopres_75990;
                int64_t r_idx_tmp_76150 = loopres_75991;
                int64_t span_tmp_76151 = loopres_75992;
                
                loop_while_75967 = loop_while_tmp_76148;
                l_idx_75968 = l_idx_tmp_76149;
                r_idx_75969 = r_idx_tmp_76150;
                span_75970 = span_tmp_76151;
            }
            idx_75963 = loop_while_75967;
            idx_75964 = l_idx_75968;
            idx_75965 = r_idx_75969;
            idx_75966 = span_75970;
            
            int64_t min_res_76004 = smin64(min_arg_66452, idx_75964);
            int64_t max_res_76005 = smax64((int64_t) 0, min_res_76004);
            int64_t x_76006 = add64(min_res_66453, max_res_76005);
            int64_t r_76007 = sub64(x_76006, (int64_t) 1);
            bool x_76008 = sle64((int64_t) 0, r_76007);
            bool y_76009 = slt64(r_76007, n_65378);
            bool bounds_check_76010 = x_76008 && y_76009;
            bool index_certs_76011;
            
            if (!bounds_check_76010) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) r_76007,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_76012;
            
            x_76012 = ((int64_t *) mem_71454)[r_76007];
            
            int64_t abs_arg_76013 = sub64(x_76012, min_res_75940);
            int64_t abs_res_76014 = abs64(abs_arg_76013);
            bool x_76015 = sle64((int64_t) 0, max_res_76005);
            bool y_76016 = slt64(max_res_76005, n_65378);
            bool bounds_check_76017 = x_76015 && y_76016;
            bool index_certs_76018;
            
            if (!bounds_check_76017) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_76005,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_76019;
            
            x_76019 = ((int64_t *) mem_71454)[max_res_76005];
            
            int64_t abs_arg_76020 = sub64(x_76019, min_res_75940);
            int64_t abs_res_76021 = abs64(abs_arg_76020);
            int64_t max_res_76022 = smax64(abs_res_76014, abs_res_76021);
            double defunc_0_f_res_76023 = sitofp_i64_f64(max_res_76022);
            double defunc_1_f_res_76024 = max_res_66457 + defunc_0_f_res_76023;
            
            for (int64_t i_76029 = 0; i_76029 < q_65380; i_76029++) {
                double x_76032;
                
                x_76032 = ((double *) mem_71496)[i_76029];
                
                bool cond_76033 = sle64(last_res_66436, i_76029);
                int64_t defunc_0_f_res_76034;
                
                if (cond_76033) {
                    defunc_0_f_res_76034 = (int64_t) 0;
                } else {
                    int64_t i_76035 = add64(max_res_76005, i_76029);
                    int64_t defunc_0_add_arg_76036;
                    
                    defunc_0_add_arg_76036 = ((int64_t *) mem_71454)[i_76035];
                    
                    int64_t defunc_1_add_res_76037 = add64((int64_t) 1,
                                                           defunc_0_add_arg_76036);
                    
                    defunc_0_f_res_76034 = defunc_1_add_res_76037;
                }
                
                int64_t binop_p_76038 = sub64(defunc_0_f_res_76034,
                                              min_res_75940);
                double defunc_0_f_res_76039 = sitofp_i64_f64(binop_p_76038);
                double abs_res_76040 = fabs(defunc_0_f_res_76039);
                double tmp1_76041 = abs_res_76040 / defunc_1_f_res_76024;
                double x_76042 = tmp1_76041 * tmp1_76041;
                double y_76043 = tmp1_76041 * x_76042;
                double tmp2_76044 = 1.0 - y_76043;
                double x_76045 = tmp2_76044 * tmp2_76044;
                double tmp3_76046 = tmp2_76044 * x_76045;
                double tmp4_76047 = x_76032 * tmp3_76046;
                
                ((double *) mem_71531)[i_76029] = defunc_0_f_res_76039;
                ((double *) mem_71534)[i_76029] = tmp4_76047;
            }
            
            double defunc_2_reduce_res_76052;
            double defunc_2_reduce_res_76053;
            double defunc_2_reduce_res_76054;
            double defunc_2_reduce_res_76055;
            double defunc_2_reduce_res_76056;
            double redout_76060;
            double redout_76061;
            double redout_76062;
            double redout_76063;
            double redout_76064;
            
            redout_76060 = 0.0;
            redout_76061 = 0.0;
            redout_76062 = 0.0;
            redout_76063 = 0.0;
            redout_76064 = 0.0;
            for (int64_t i_76059 = 0; i_76059 < q_65380; i_76059++) {
                double x_76067;
                
                x_76067 = ((double *) mem_71531)[i_76059];
                
                double x_76068;
                
                x_76068 = ((double *) mem_71534)[i_76059];
                
                double defunc_1_f_res_76069 = x_76067 * x_76068;
                double defunc_1_f_res_76070 = x_76067 * defunc_1_f_res_76069;
                double defunc_1_f_res_76071 = x_76067 * defunc_1_f_res_76070;
                double defunc_1_f_res_76072 = x_76067 * defunc_1_f_res_76071;
                double defunc_1_op_res_76073 = x_76068 + redout_76060;
                double defunc_1_op_res_76074 = defunc_1_f_res_76069 +
                       redout_76061;
                double defunc_1_op_res_76075 = defunc_1_f_res_76070 +
                       redout_76062;
                double defunc_1_op_res_76076 = defunc_1_f_res_76071 +
                       redout_76063;
                double defunc_1_op_res_76077 = defunc_1_f_res_76072 +
                       redout_76064;
                
                ((double *) mem_71561)[i_76059] = defunc_1_f_res_76070;
                ((double *) mem_71564)[i_76059] = defunc_1_f_res_76069;
                
                double redout_tmp_76154 = defunc_1_op_res_76073;
                double redout_tmp_76155 = defunc_1_op_res_76074;
                double redout_tmp_76156 = defunc_1_op_res_76075;
                double redout_tmp_76157 = defunc_1_op_res_76076;
                double redout_tmp_76158 = defunc_1_op_res_76077;
                
                redout_76060 = redout_tmp_76154;
                redout_76061 = redout_tmp_76155;
                redout_76062 = redout_tmp_76156;
                redout_76063 = redout_tmp_76157;
                redout_76064 = redout_tmp_76158;
            }
            defunc_2_reduce_res_76052 = redout_76060;
            defunc_2_reduce_res_76053 = redout_76061;
            defunc_2_reduce_res_76054 = redout_76062;
            defunc_2_reduce_res_76055 = redout_76063;
            defunc_2_reduce_res_76056 = redout_76064;
            
            double x_76080 = defunc_2_reduce_res_76054 *
                   defunc_2_reduce_res_76056;
            double y_76081 = defunc_2_reduce_res_76055 *
                   defunc_2_reduce_res_76055;
            double a12_76082 = x_76080 - y_76081;
            double x_76083 = defunc_2_reduce_res_76054 *
                   defunc_2_reduce_res_76055;
            double y_76084 = defunc_2_reduce_res_76053 *
                   defunc_2_reduce_res_76056;
            double b12_76085 = x_76083 - y_76084;
            double x_76086 = defunc_2_reduce_res_76053 *
                   defunc_2_reduce_res_76055;
            double y_76087 = defunc_2_reduce_res_76054 *
                   defunc_2_reduce_res_76054;
            double c12_76088 = x_76086 - y_76087;
            double x_76089 = defunc_2_reduce_res_76052 *
                   defunc_2_reduce_res_76056;
            double b2_76090 = x_76089 - y_76087;
            double x_76091 = defunc_2_reduce_res_76053 *
                   defunc_2_reduce_res_76054;
            double y_76092 = defunc_2_reduce_res_76052 *
                   defunc_2_reduce_res_76055;
            double c2_76093 = x_76091 - y_76092;
            double x_76094 = defunc_2_reduce_res_76052 * a12_76082;
            double y_76095 = defunc_2_reduce_res_76053 * b12_76085;
            double x_76096 = x_76094 + y_76095;
            double y_76097 = defunc_2_reduce_res_76054 * c12_76088;
            double y_76098 = x_76096 + y_76097;
            double det_76099 = 1.0 / y_76098;
            double a12_76100 = a12_76082 * det_76099;
            double b12_76101 = b12_76085 * det_76099;
            double c12_76102 = c12_76088 * det_76099;
            double b2_76103 = b2_76090 * det_76099;
            double c2_76104 = c2_76093 * det_76099;
            double defunc_2_reduce_res_76105;
            double defunc_2_reduce_res_76106;
            double redout_76108;
            double redout_76109;
            
            redout_76108 = 0.0;
            redout_76109 = 0.0;
            for (int64_t i_76107 = 0; i_76107 < q_65380; i_76107++) {
                double x_76110;
                
                x_76110 = ((double *) mem_71534)[i_76107];
                
                double x_76111;
                
                x_76111 = ((double *) mem_71564)[i_76107];
                
                double x_76112;
                
                x_76112 = ((double *) mem_71561)[i_76107];
                
                bool cond_76113 = sle64(last_res_66436, i_76107);
                double defunc_0_f_res_76114;
                
                if (cond_76113) {
                    defunc_0_f_res_76114 = 0.0;
                } else {
                    int64_t i_76115 = add64(max_res_76005, i_76107);
                    double defunc_0_add_arg_76116;
                    
                    defunc_0_add_arg_76116 = ((double *) mem_71451)[i_76115];
                    defunc_0_f_res_76114 = defunc_0_add_arg_76116;
                }
                
                double x_76117 = a12_76100 * x_76110;
                double y_76118 = b12_76101 * x_76111;
                double x_76119 = x_76117 + y_76118;
                double y_76120 = c12_76102 * x_76112;
                double x_76121 = x_76119 + y_76120;
                double defunc_9_fit_fun_res_76122 = defunc_0_f_res_76114 *
                       x_76121;
                double x_76123 = b12_76101 * x_76110;
                double y_76124 = b2_76103 * x_76111;
                double x_76125 = x_76123 + y_76124;
                double y_76126 = c2_76104 * x_76112;
                double x_76127 = x_76125 + y_76126;
                double defunc_9_slope_fun_res_76128 = defunc_0_f_res_76114 *
                       x_76127;
                double defunc_1_op_res_76129 = defunc_9_fit_fun_res_76122 +
                       redout_76108;
                double defunc_1_op_res_76130 = defunc_9_slope_fun_res_76128 +
                       redout_76109;
                double redout_tmp_76161 = defunc_1_op_res_76129;
                double redout_tmp_76162 = defunc_1_op_res_76130;
                
                redout_76108 = redout_tmp_76161;
                redout_76109 = redout_tmp_76162;
            }
            defunc_2_reduce_res_76105 = redout_76108;
            defunc_2_reduce_res_76106 = redout_76109;
            ((double *) mem_71511)[i_75936] = defunc_2_reduce_res_76105;
            ((double *) mem_71514)[i_75936] = defunc_2_reduce_res_76106;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71602.mem + gtid_69428 * n_m_65386 * (int64_t) 8,
                    mem_71511 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71606.mem + gtid_69428 * n_m_65386 * (int64_t) 8,
                    mem_71514 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71436);
    free(mem_71451);
    free(mem_71454);
    free(mem_71481);
    free(mem_71496);
    free(mem_71511);
    free(mem_71514);
    free(mem_71531);
    free(mem_71534);
    free(mem_71561);
    free(mem_71564);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77361_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77361_end -
                 futhark_mc_segmap_parloop_77361_start;
        
        ctx->futhark_mc_segmap_parloop_77361_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77361_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77361_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77359(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_69427 = tid;
    int num_tasks_75903 = info.nsubtasks;
    struct futhark_mc_task_77358 *futhark_mc_task_77358 =
                                 (struct futhark_mc_task_77358 *) args;
    struct futhark_context *ctx = futhark_mc_task_77358->ctx;
    uint64_t futhark_mc_segmap_task_77359_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77359_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77358->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77358->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77358->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77358->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77358->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77358->free_i_65392;
    bool x_65393 = futhark_mc_task_77358->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77358->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77358->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77358->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77358->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71342 = futhark_mc_task_77358->free_bytes_71342;
    int64_t bytes_71354 = futhark_mc_task_77358->free_bytes_71354;
    int64_t bytes_71429 = futhark_mc_task_77358->free_bytes_71429;
    struct memblock mem_71602 = {.desc ="mem_71602", .mem =
                                 futhark_mc_task_77358->free_mem_71602, .size =
                                 0, .references =NULL};
    struct memblock mem_71606 = {.desc ="mem_71606", .mem =
                                 futhark_mc_task_77358->free_mem_71606, .size =
                                 0, .references =NULL};
    int64_t iter_75904;
    struct futhark_mc_segmap_parloop_struct_77360
    futhark_mc_segmap_parloop_struct_77360;
    
    futhark_mc_segmap_parloop_struct_77360.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77360.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77360.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77360.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77360.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77360.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77360.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77360.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77360.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77360.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77360.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77360.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77360.free_bytes_71342 = bytes_71342;
    futhark_mc_segmap_parloop_struct_77360.free_bytes_71354 = bytes_71354;
    futhark_mc_segmap_parloop_struct_77360.free_bytes_71429 = bytes_71429;
    futhark_mc_segmap_parloop_struct_77360.free_mem_71602 = mem_71602.mem;
    futhark_mc_segmap_parloop_struct_77360.free_mem_71606 = mem_71606.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77361_task;
    
    futhark_mc_segmap_parloop_77361_task.name =
        "futhark_mc_segmap_parloop_77361";
    futhark_mc_segmap_parloop_77361_task.fn = futhark_mc_segmap_parloop_77361;
    futhark_mc_segmap_parloop_77361_task.args =
        &futhark_mc_segmap_parloop_struct_77360;
    futhark_mc_segmap_parloop_77361_task.iterations = iterations;
    futhark_mc_segmap_parloop_77361_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77361_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77361_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77361_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77361_task);
    
    if (futhark_mc_segmap_parloop_77361_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77361_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77361_total_end -
                 futhark_mc_segmap_parloop_77361_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77361_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77361_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77361_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77359_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77359_end -
                 futhark_mc_segmap_task_77359_start;
        
        ctx->futhark_mc_segmap_task_77359_runs[tid]++;
        ctx->futhark_mc_segmap_task_77359_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77359_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77374 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    double free_i64_res_65404;
    unsigned char *free_Y_mem_70603;
    int64_t free_bytes_71342;
    int64_t free_bytes_71354;
    int64_t free_bytes_71429;
    unsigned char *free_mem_71602;
    unsigned char *free_mem_71606;
};
struct futhark_mc_task_77383 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69645;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71343;
};
struct futhark_mc_scan_stage_1_parloop_struct_77386 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69645;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71343;
};
static int futhark_mc_scan_stage_1_parloop_77387(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_76164, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_1_parloop_struct_77386
    *futhark_mc_scan_stage_1_parloop_struct_77386 =
    (struct futhark_mc_scan_stage_1_parloop_struct_77386 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_1_parloop_struct_77386->ctx;
    uint64_t futhark_mc_scan_stage_1_parloop_77387_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77387_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_1_parloop_struct_77386->free_n_65378;
    int64_t gtid_69645 =
            futhark_mc_scan_stage_1_parloop_struct_77386->free_gtid_69645;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_1_parloop_struct_77386->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71343 = {.desc ="mem_71343", .mem =
                                 futhark_mc_scan_stage_1_parloop_struct_77386->free_mem_71343,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76586 = start;
    int64_t x_76166;
    int64_t x_76167;
    
    x_76166 = (int64_t) 0;
    for (; iter_76586 < end; iter_76586++) {
        int64_t gtid_76165 = iter_76586;
        
        // stage 1 scan body
        {
            double x_76169;
            
            x_76169 = ((double *) Y_mem_70603.mem)[gtid_69645 * n_65378 +
                                                   gtid_76165];
            
            bool isnan_res_76170;
            
            isnan_res_76170 = futrts_isnan64(x_76169);
            
            bool defunc_0_p_res_76171 = !isnan_res_76170;
            int64_t defunc_0_f_res_76172 = btoi_bool_i64(defunc_0_p_res_76171);
            
            // write mapped values results to memory
            { }
            x_76166 = x_76166;
            // Read next values
            {
                x_76167 = defunc_0_f_res_76172;
            }
            
            int64_t defunc_1_op_res_76168 = add64(x_76166, x_76167);
            
            ((int64_t *) mem_71343.mem)[gtid_76165] = defunc_1_op_res_76168;
            x_76166 = defunc_1_op_res_76168;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77387_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77387_end -
                 futhark_mc_scan_stage_1_parloop_77387_start;
        
        ctx->futhark_mc_scan_stage_1_parloop_77387_runs[tid]++;
        ctx->futhark_mc_scan_stage_1_parloop_77387_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_1_parloop_77387_iter[tid] += iterations;
    }
    return err;
}
struct futhark_mc_scan_stage_3_parloop_struct_77388 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69645;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71343;
};
static int futhark_mc_scan_stage_3_parloop_77389(void *args, int64_t start,
                                                 int64_t end,
                                                 int flat_tid_76164, int tid)
{
    int err = 0;
    struct futhark_mc_scan_stage_3_parloop_struct_77388
    *futhark_mc_scan_stage_3_parloop_struct_77388 =
    (struct futhark_mc_scan_stage_3_parloop_struct_77388 *) args;
    struct futhark_context *ctx =
                           futhark_mc_scan_stage_3_parloop_struct_77388->ctx;
    uint64_t futhark_mc_scan_stage_3_parloop_77389_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_3_parloop_77389_start = get_wall_time();
    
    int64_t n_65378 =
            futhark_mc_scan_stage_3_parloop_struct_77388->free_n_65378;
    int64_t gtid_69645 =
            futhark_mc_scan_stage_3_parloop_struct_77388->free_gtid_69645;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_scan_stage_3_parloop_struct_77388->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71343 = {.desc ="mem_71343", .mem =
                                 futhark_mc_scan_stage_3_parloop_struct_77388->free_mem_71343,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76598 = start;
    int64_t x_76595;
    int64_t x_76596;
    
    if (iter_76598 == (int64_t) 0) {
        x_76595 = (int64_t) 0;
    } else {
        x_76595 = ((int64_t *) mem_71343.mem)[iter_76598 - (int64_t) 1];
    }
    for (; iter_76598 < end; iter_76598++) {
        int64_t gtid_76165 = iter_76598;
        
        // stage 3 scan body
        {
            double x_76169;
            
            x_76169 = ((double *) Y_mem_70603.mem)[gtid_69645 * n_65378 +
                                                   gtid_76165];
            
            bool isnan_res_76170;
            
            isnan_res_76170 = futrts_isnan64(x_76169);
            
            bool defunc_0_p_res_76171 = !isnan_res_76170;
            int64_t defunc_0_f_res_76172 = btoi_bool_i64(defunc_0_p_res_76171);
            
            x_76595 = x_76595;
            x_76596 = defunc_0_f_res_76172;
            
            int64_t defunc_1_op_res_76597 = add64(x_76595, x_76596);
            
            ((int64_t *) mem_71343.mem)[gtid_76165] = defunc_1_op_res_76597;
            x_76595 = defunc_1_op_res_76597;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_3_parloop_77389_end = get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77389_end -
                 futhark_mc_scan_stage_3_parloop_77389_start;
        
        ctx->futhark_mc_scan_stage_3_parloop_77389_runs[tid]++;
        ctx->futhark_mc_scan_stage_3_parloop_77389_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_scan_stage_3_parloop_77389_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segscan_task_77384(void *args, int64_t iterations, int tid,
                                  struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76164 = tid;
    int num_tasks_76585 = info.nsubtasks;
    struct futhark_mc_task_77383 *futhark_mc_task_77383 =
                                 (struct futhark_mc_task_77383 *) args;
    struct futhark_context *ctx = futhark_mc_task_77383->ctx;
    uint64_t futhark_mc_segscan_task_77384_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segscan_task_77384_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77383->free_n_65378;
    int64_t gtid_69645 = futhark_mc_task_77383->free_gtid_69645;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77383->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71343 = {.desc ="mem_71343", .mem =
                                 futhark_mc_task_77383->free_mem_71343, .size =
                                 0, .references =NULL};
    size_t scan_stage_2_accum_mem_76592_cached_sizze_77385 = 0;
    unsigned char *scan_stage_2_accum_mem_76592 = NULL;
    int64_t iter_76586;
    struct futhark_mc_scan_stage_1_parloop_struct_77386
    futhark_mc_scan_stage_1_parloop_struct_77386;
    
    futhark_mc_scan_stage_1_parloop_struct_77386.ctx = ctx;
    futhark_mc_scan_stage_1_parloop_struct_77386.free_n_65378 = n_65378;
    futhark_mc_scan_stage_1_parloop_struct_77386.free_gtid_69645 = gtid_69645;
    futhark_mc_scan_stage_1_parloop_struct_77386.free_Y_mem_70603 =
        Y_mem_70603.mem;
    futhark_mc_scan_stage_1_parloop_struct_77386.free_mem_71343 = mem_71343.mem;
    
    struct scheduler_parloop futhark_mc_scan_stage_1_parloop_77387_task;
    
    futhark_mc_scan_stage_1_parloop_77387_task.name =
        "futhark_mc_scan_stage_1_parloop_77387";
    futhark_mc_scan_stage_1_parloop_77387_task.fn =
        futhark_mc_scan_stage_1_parloop_77387;
    futhark_mc_scan_stage_1_parloop_77387_task.args =
        &futhark_mc_scan_stage_1_parloop_struct_77386;
    futhark_mc_scan_stage_1_parloop_77387_task.iterations = iterations;
    futhark_mc_scan_stage_1_parloop_77387_task.info = info;
    
    uint64_t futhark_mc_scan_stage_1_parloop_77387_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_scan_stage_1_parloop_77387_total_start = get_wall_time();
    
    int futhark_mc_scan_stage_1_parloop_77387_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_scan_stage_1_parloop_77387_task);
    
    if (futhark_mc_scan_stage_1_parloop_77387_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_scan_stage_1_parloop_77387_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_scan_stage_1_parloop_77387_total_end -
                 futhark_mc_scan_stage_1_parloop_77387_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77387_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77387_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_scan_stage_1_parloop_77387_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    if (slt32(1, num_tasks_76585)) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmentedScan stage 2");
        
        int64_t x_76587;
        int64_t x_76588;
        int64_t offset_76590 = (int64_t) 0;
        int64_t offset_index_76591 = (int64_t) 0;
        
        if (scan_stage_2_accum_mem_76592_cached_sizze_77385 <
            (size_t) (int64_t) 8) {
            scan_stage_2_accum_mem_76592 = realloc(scan_stage_2_accum_mem_76592,
                                                   (int64_t) 8);
            scan_stage_2_accum_mem_76592_cached_sizze_77385 = (int64_t) 8;
        }
        ((int64_t *) scan_stage_2_accum_mem_76592)[(int64_t) 0] = (int64_t) 0;
        for (int32_t i_76594 = 0; i_76594 < num_tasks_76585 - 1; i_76594++) {
            offset_76590 = squot64(n_65378, sext_i32_i64(num_tasks_76585));
            if (slt64(sext_i32_i64(i_76594), srem64(n_65378,
                                                    sext_i32_i64(num_tasks_76585)))) {
                offset_76590 += (int64_t) 1;
            }
            offset_index_76591 += offset_76590;
            
            int64_t gtid_76165 = offset_index_76591;
            double x_76169;
            
            x_76169 = ((double *) Y_mem_70603.mem)[gtid_69645 * n_65378 +
                                                   gtid_76165];
            
            bool isnan_res_76170;
            
            isnan_res_76170 = futrts_isnan64(x_76169);
            
            bool defunc_0_p_res_76171 = !isnan_res_76170;
            int64_t defunc_0_f_res_76172 = btoi_bool_i64(defunc_0_p_res_76171);
            
            // Read carry in
            {
                x_76587 =
                    ((int64_t *) scan_stage_2_accum_mem_76592)[(int64_t) 0];
            }
            // Read next values
            {
                x_76588 = ((int64_t *) mem_71343.mem)[offset_index_76591 -
                                                      (int64_t) 1];
            }
            
            int64_t defunc_1_op_res_76589 = add64(x_76587, x_76588);
            
            ((int64_t *) mem_71343.mem)[offset_index_76591 - (int64_t) 1] =
                defunc_1_op_res_76589;
            ((int64_t *) scan_stage_2_accum_mem_76592)[(int64_t) 0] =
                defunc_1_op_res_76589;
        }
        
        int64_t iter_76598 = (int64_t) 0;
        struct futhark_mc_scan_stage_3_parloop_struct_77388
        futhark_mc_scan_stage_3_parloop_struct_77388;
        
        futhark_mc_scan_stage_3_parloop_struct_77388.ctx = ctx;
        futhark_mc_scan_stage_3_parloop_struct_77388.free_n_65378 = n_65378;
        futhark_mc_scan_stage_3_parloop_struct_77388.free_gtid_69645 =
            gtid_69645;
        futhark_mc_scan_stage_3_parloop_struct_77388.free_Y_mem_70603 =
            Y_mem_70603.mem;
        futhark_mc_scan_stage_3_parloop_struct_77388.free_mem_71343 =
            mem_71343.mem;
        
        struct scheduler_parloop futhark_mc_scan_stage_3_parloop_77389_task;
        
        futhark_mc_scan_stage_3_parloop_77389_task.name =
            "futhark_mc_scan_stage_3_parloop_77389";
        futhark_mc_scan_stage_3_parloop_77389_task.fn =
            futhark_mc_scan_stage_3_parloop_77389;
        futhark_mc_scan_stage_3_parloop_77389_task.args =
            &futhark_mc_scan_stage_3_parloop_struct_77388;
        futhark_mc_scan_stage_3_parloop_77389_task.iterations = iterations;
        futhark_mc_scan_stage_3_parloop_77389_task.info = info;
        
        uint64_t futhark_mc_scan_stage_3_parloop_77389_total_start = 0;
        
        if (ctx->profiling && !ctx->profiling_paused)
            futhark_mc_scan_stage_3_parloop_77389_total_start = get_wall_time();
        
        int futhark_mc_scan_stage_3_parloop_77389_err =
            scheduler_execute_task(&ctx->scheduler,
                                   &futhark_mc_scan_stage_3_parloop_77389_task);
        
        if (futhark_mc_scan_stage_3_parloop_77389_err != 0) {
            err = 1;
            goto cleanup;
        }
        if (ctx->profiling && !ctx->profiling_paused) {
            uint64_t futhark_mc_scan_stage_3_parloop_77389_total_end =
                     get_wall_time();
            uint64_t elapsed = futhark_mc_scan_stage_3_parloop_77389_total_end -
                     futhark_mc_scan_stage_3_parloop_77389_total_start;
            
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77389_total_runs,
                               1, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77389_total_total_runtime,
                               elapsed, __ATOMIC_RELAXED);
            __atomic_fetch_add(&ctx->futhark_mc_scan_stage_3_parloop_77389_total_iter,
                               iterations, __ATOMIC_RELAXED);
        }
    }
    
  cleanup:
    {
        free(scan_stage_2_accum_mem_76592);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segscan_task_77384_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segscan_task_77384_end -
                 futhark_mc_segscan_task_77384_start;
        
        ctx->futhark_mc_segscan_task_77384_runs[tid]++;
        ctx->futhark_mc_segscan_task_77384_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segscan_task_77384_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77390 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69645;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71343;
    unsigned char *free_mem_71346;
    unsigned char *free_mem_71349;
};
struct futhark_mc_segmap_parloop_struct_77392 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_gtid_69645;
    unsigned char *free_Y_mem_70603;
    unsigned char *free_mem_71343;
    unsigned char *free_mem_71346;
    unsigned char *free_mem_71349;
};
static int futhark_mc_segmap_parloop_77393(void *args, int64_t start,
                                           int64_t end, int flat_tid_76173,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77392
    *futhark_mc_segmap_parloop_struct_77392 =
    (struct futhark_mc_segmap_parloop_struct_77392 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77392->ctx;
    uint64_t futhark_mc_segmap_parloop_77393_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77393_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77392->free_n_65378;
    int64_t gtid_69645 =
            futhark_mc_segmap_parloop_struct_77392->free_gtid_69645;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77392->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71343 = {.desc ="mem_71343", .mem =
                                 futhark_mc_segmap_parloop_struct_77392->free_mem_71343,
                                 .size =0, .references =NULL};
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_segmap_parloop_struct_77392->free_mem_71346,
                                 .size =0, .references =NULL};
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_segmap_parloop_struct_77392->free_mem_71349,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76602 = start;
    
    for (; iter_76602 < end; iter_76602++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76605 = n_65378;
        int64_t gtid_76174 = iter_76602;
        int64_t remnant_76606 = iter_76602 - gtid_76174;
        double x_76175;
        
        x_76175 = ((double *) Y_mem_70603.mem)[gtid_69645 * n_65378 +
                                               gtid_76174];
        
        bool isnan_res_76176;
        
        isnan_res_76176 = futrts_isnan64(x_76175);
        
        bool defunc_0_p_res_76177 = !isnan_res_76176;
        int64_t defunc_1_f_res_76178;
        
        if (defunc_0_p_res_76177) {
            int64_t x_76603;
            
            x_76603 = ((int64_t *) mem_71343.mem)[gtid_76174];
            
            int64_t defunc_1_f_res_t_res_76604 = sub64(x_76603, (int64_t) 1);
            
            defunc_1_f_res_76178 = defunc_1_f_res_t_res_76604;
        } else {
            defunc_1_f_res_76178 = (int64_t) -1;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_76178) &&
            slt64(defunc_1_f_res_76178, n_65378)) {
            ((int64_t *) mem_71349.mem)[defunc_1_f_res_76178] = gtid_76174;
        }
        if (sle64((int64_t) 0, defunc_1_f_res_76178) &&
            slt64(defunc_1_f_res_76178, n_65378)) {
            ((double *) mem_71346.mem)[defunc_1_f_res_76178] = x_76175;
        }
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77393_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77393_end -
                 futhark_mc_segmap_parloop_77393_start;
        
        ctx->futhark_mc_segmap_parloop_77393_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77393_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77393_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77391(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76173 = tid;
    int num_tasks_76601 = info.nsubtasks;
    struct futhark_mc_task_77390 *futhark_mc_task_77390 =
                                 (struct futhark_mc_task_77390 *) args;
    struct futhark_context *ctx = futhark_mc_task_77390->ctx;
    uint64_t futhark_mc_segmap_task_77391_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77391_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77390->free_n_65378;
    int64_t gtid_69645 = futhark_mc_task_77390->free_gtid_69645;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77390->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    struct memblock mem_71343 = {.desc ="mem_71343", .mem =
                                 futhark_mc_task_77390->free_mem_71343, .size =
                                 0, .references =NULL};
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_task_77390->free_mem_71346, .size =
                                 0, .references =NULL};
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_task_77390->free_mem_71349, .size =
                                 0, .references =NULL};
    int64_t iter_76602;
    struct futhark_mc_segmap_parloop_struct_77392
    futhark_mc_segmap_parloop_struct_77392;
    
    futhark_mc_segmap_parloop_struct_77392.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77392.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77392.free_gtid_69645 = gtid_69645;
    futhark_mc_segmap_parloop_struct_77392.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77392.free_mem_71343 = mem_71343.mem;
    futhark_mc_segmap_parloop_struct_77392.free_mem_71346 = mem_71346.mem;
    futhark_mc_segmap_parloop_struct_77392.free_mem_71349 = mem_71349.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77393_task;
    
    futhark_mc_segmap_parloop_77393_task.name =
        "futhark_mc_segmap_parloop_77393";
    futhark_mc_segmap_parloop_77393_task.fn = futhark_mc_segmap_parloop_77393;
    futhark_mc_segmap_parloop_77393_task.args =
        &futhark_mc_segmap_parloop_struct_77392;
    futhark_mc_segmap_parloop_77393_task.iterations = iterations;
    futhark_mc_segmap_parloop_77393_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77393_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77393_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77393_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77393_task);
    
    if (futhark_mc_segmap_parloop_77393_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77393_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77393_total_end -
                 futhark_mc_segmap_parloop_77393_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77393_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77393_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77393_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77391_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77391_end -
                 futhark_mc_segmap_task_77391_start;
        
        ctx->futhark_mc_segmap_task_77391_runs[tid]++;
        ctx->futhark_mc_segmap_task_77391_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77391_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77394 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71352;
};
struct futhark_mc_segmap_parloop_struct_77396 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71352;
};
static int futhark_mc_segmap_parloop_77397(void *args, int64_t start,
                                           int64_t end, int flat_tid_76181,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77396
    *futhark_mc_segmap_parloop_struct_77396 =
    (struct futhark_mc_segmap_parloop_struct_77396 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77396->ctx;
    uint64_t futhark_mc_segmap_parloop_77397_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77397_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77396->free_n_65378;
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_segmap_parloop_struct_77396->free_mem_71349,
                                 .size =0, .references =NULL};
    struct memblock mem_71352 = {.desc ="mem_71352", .mem =
                                 futhark_mc_segmap_parloop_struct_77396->free_mem_71352,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76608 = start;
    
    for (; iter_76608 < end; iter_76608++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76609 = n_65378;
        int64_t gtid_76182 = iter_76608;
        int64_t remnant_76610 = iter_76608 - gtid_76182;
        int64_t x_76183;
        
        x_76183 = ((int64_t *) mem_71349.mem)[gtid_76182];
        
        int64_t defunc_0_f_res_76184 = add64((int64_t) 1, x_76183);
        
        ((int64_t *) mem_71352.mem)[gtid_76182] = defunc_0_f_res_76184;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77397_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77397_end -
                 futhark_mc_segmap_parloop_77397_start;
        
        ctx->futhark_mc_segmap_parloop_77397_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77397_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77397_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77395(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76181 = tid;
    int num_tasks_76607 = info.nsubtasks;
    struct futhark_mc_task_77394 *futhark_mc_task_77394 =
                                 (struct futhark_mc_task_77394 *) args;
    struct futhark_context *ctx = futhark_mc_task_77394->ctx;
    uint64_t futhark_mc_segmap_task_77395_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77395_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77394->free_n_65378;
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_task_77394->free_mem_71349, .size =
                                 0, .references =NULL};
    struct memblock mem_71352 = {.desc ="mem_71352", .mem =
                                 futhark_mc_task_77394->free_mem_71352, .size =
                                 0, .references =NULL};
    int64_t iter_76608;
    struct futhark_mc_segmap_parloop_struct_77396
    futhark_mc_segmap_parloop_struct_77396;
    
    futhark_mc_segmap_parloop_struct_77396.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77396.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77396.free_mem_71349 = mem_71349.mem;
    futhark_mc_segmap_parloop_struct_77396.free_mem_71352 = mem_71352.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77397_task;
    
    futhark_mc_segmap_parloop_77397_task.name =
        "futhark_mc_segmap_parloop_77397";
    futhark_mc_segmap_parloop_77397_task.fn = futhark_mc_segmap_parloop_77397;
    futhark_mc_segmap_parloop_77397_task.args =
        &futhark_mc_segmap_parloop_struct_77396;
    futhark_mc_segmap_parloop_77397_task.iterations = iterations;
    futhark_mc_segmap_parloop_77397_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77397_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77397_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77397_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77397_task);
    
    if (futhark_mc_segmap_parloop_77397_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77397_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77397_total_end -
                 futhark_mc_segmap_parloop_77397_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77397_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77397_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77397_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77395_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77395_end -
                 futhark_mc_segmap_task_77395_start;
        
        ctx->futhark_mc_segmap_task_77395_runs[tid]++;
        ctx->futhark_mc_segmap_task_77395_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77395_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77398 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_69657;
    unsigned char *free_mem_71355;
};
struct futhark_mc_segmap_parloop_struct_77400 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_69657;
    unsigned char *free_mem_71355;
};
static int futhark_mc_segmap_parloop_77401(void *args, int64_t start,
                                           int64_t end, int flat_tid_76185,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77400
    *futhark_mc_segmap_parloop_struct_77400 =
    (struct futhark_mc_segmap_parloop_struct_77400 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77400->ctx;
    uint64_t futhark_mc_segmap_parloop_77401_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77401_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77400->free_q_65380;
    int64_t last_res_69657 =
            futhark_mc_segmap_parloop_struct_77400->free_last_res_69657;
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_segmap_parloop_struct_77400->free_mem_71355,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76612 = start;
    
    for (; iter_76612 < end; iter_76612++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76613 = q_65380;
        int64_t gtid_76186 = iter_76612;
        int64_t remnant_76614 = iter_76612 - gtid_76186;
        bool cond_76187 = sle64(last_res_69657, gtid_76186);
        double defunc_0_f_res_76188;
        
        if (cond_76187) {
            defunc_0_f_res_76188 = 0.0;
        } else {
            defunc_0_f_res_76188 = 1.0;
        }
        ((double *) mem_71355.mem)[gtid_76186] = defunc_0_f_res_76188;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77401_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77401_end -
                 futhark_mc_segmap_parloop_77401_start;
        
        ctx->futhark_mc_segmap_parloop_77401_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77401_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77401_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77399(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76185 = tid;
    int num_tasks_76611 = info.nsubtasks;
    struct futhark_mc_task_77398 *futhark_mc_task_77398 =
                                 (struct futhark_mc_task_77398 *) args;
    struct futhark_context *ctx = futhark_mc_task_77398->ctx;
    uint64_t futhark_mc_segmap_task_77399_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77399_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77398->free_q_65380;
    int64_t last_res_69657 = futhark_mc_task_77398->free_last_res_69657;
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_task_77398->free_mem_71355, .size =
                                 0, .references =NULL};
    int64_t iter_76612;
    struct futhark_mc_segmap_parloop_struct_77400
    futhark_mc_segmap_parloop_struct_77400;
    
    futhark_mc_segmap_parloop_struct_77400.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77400.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77400.free_last_res_69657 = last_res_69657;
    futhark_mc_segmap_parloop_struct_77400.free_mem_71355 = mem_71355.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77401_task;
    
    futhark_mc_segmap_parloop_77401_task.name =
        "futhark_mc_segmap_parloop_77401";
    futhark_mc_segmap_parloop_77401_task.fn = futhark_mc_segmap_parloop_77401;
    futhark_mc_segmap_parloop_77401_task.args =
        &futhark_mc_segmap_parloop_struct_77400;
    futhark_mc_segmap_parloop_77401_task.iterations = iterations;
    futhark_mc_segmap_parloop_77401_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77401_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77401_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77401_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77401_task);
    
    if (futhark_mc_segmap_parloop_77401_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77401_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77401_total_end -
                 futhark_mc_segmap_parloop_77401_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77401_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77401_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77401_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77399_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77399_end -
                 futhark_mc_segmap_task_77399_start;
        
        ctx->futhark_mc_segmap_task_77399_runs[tid]++;
        ctx->futhark_mc_segmap_task_77399_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77399_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77402 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_69657;
    int64_t free_min_arg_69676;
    int64_t free_min_arg_69677;
    int64_t free_min_res_69678;
    double free_max_res_69682;
    unsigned char *free_mem_71346;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71352;
    int64_t free_bytes_71354;
    unsigned char *free_mem_71355;
    unsigned char *free_mem_71430;
    unsigned char *free_mem_71433;
};
struct futhark_mc_segmap_parloop_struct_77404 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_69657;
    int64_t free_min_arg_69676;
    int64_t free_min_arg_69677;
    int64_t free_min_res_69678;
    double free_max_res_69682;
    unsigned char *free_mem_71346;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71352;
    int64_t free_bytes_71354;
    unsigned char *free_mem_71355;
    unsigned char *free_mem_71430;
    unsigned char *free_mem_71433;
};
static int futhark_mc_segmap_parloop_77405(void *args, int64_t start,
                                           int64_t end, int flat_tid_76385,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77404
    *futhark_mc_segmap_parloop_struct_77404 =
    (struct futhark_mc_segmap_parloop_struct_77404 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77404->ctx;
    uint64_t futhark_mc_segmap_parloop_77405_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77405_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77404->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77404->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77404->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77404->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77404->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77404->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77404->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77404->free_loop_cond_65403;
    int64_t last_res_69657 =
            futhark_mc_segmap_parloop_struct_77404->free_last_res_69657;
    int64_t min_arg_69676 =
            futhark_mc_segmap_parloop_struct_77404->free_min_arg_69676;
    int64_t min_arg_69677 =
            futhark_mc_segmap_parloop_struct_77404->free_min_arg_69677;
    int64_t min_res_69678 =
            futhark_mc_segmap_parloop_struct_77404->free_min_res_69678;
    double max_res_69682 =
           futhark_mc_segmap_parloop_struct_77404->free_max_res_69682;
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_segmap_parloop_struct_77404->free_mem_71346,
                                 .size =0, .references =NULL};
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_segmap_parloop_struct_77404->free_mem_71349,
                                 .size =0, .references =NULL};
    struct memblock mem_71352 = {.desc ="mem_71352", .mem =
                                 futhark_mc_segmap_parloop_struct_77404->free_mem_71352,
                                 .size =0, .references =NULL};
    int64_t bytes_71354 =
            futhark_mc_segmap_parloop_struct_77404->free_bytes_71354;
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_segmap_parloop_struct_77404->free_mem_71355,
                                 .size =0, .references =NULL};
    struct memblock mem_71430 = {.desc ="mem_71430", .mem =
                                 futhark_mc_segmap_parloop_struct_77404->free_mem_71430,
                                 .size =0, .references =NULL};
    struct memblock mem_71433 = {.desc ="mem_71433", .mem =
                                 futhark_mc_segmap_parloop_struct_77404->free_mem_71433,
                                 .size =0, .references =NULL};
    size_t mem_76473_cached_sizze_77406 = 0;
    unsigned char *mem_76473 = NULL;
    size_t mem_76475_cached_sizze_77407 = 0;
    unsigned char *mem_76475 = NULL;
    size_t mem_76500_cached_sizze_77408 = 0;
    unsigned char *mem_76500 = NULL;
    size_t mem_76502_cached_sizze_77409 = 0;
    unsigned char *mem_76502 = NULL;
    int64_t iterations = end - start;
    int64_t iter_76616 = start;
    
    if (mem_76473_cached_sizze_77406 < (size_t) bytes_71354) {
        mem_76473 = realloc(mem_76473, bytes_71354);
        mem_76473_cached_sizze_77406 = bytes_71354;
    }
    if (mem_76475_cached_sizze_77407 < (size_t) bytes_71354) {
        mem_76475 = realloc(mem_76475, bytes_71354);
        mem_76475_cached_sizze_77407 = bytes_71354;
    }
    if (mem_76500_cached_sizze_77408 < (size_t) bytes_71354) {
        mem_76500 = realloc(mem_76500, bytes_71354);
        mem_76500_cached_sizze_77408 = bytes_71354;
    }
    if (mem_76502_cached_sizze_77409 < (size_t) bytes_71354) {
        mem_76502 = realloc(mem_76502, bytes_71354);
        mem_76502_cached_sizze_77409 = bytes_71354;
    }
    for (; iter_76616 < end; iter_76616++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76738 = n_m_65386;
        int64_t gtid_76386 = iter_76616;
        int64_t remnant_76739 = iter_76616 - gtid_76386;
        int64_t min_arg_76387 = mul64(jump_65382, gtid_76386);
        int64_t min_res_76388 = smin64(i_65392, min_arg_76387);
        int64_t defunc_0_g_res_76389 = add64((int64_t) 1, min_res_76388);
        bool init_idx_76390;
        int64_t init_idx_76391;
        int64_t init_idx_76392;
        bool loop_while_76617;
        int64_t low_76618;
        int64_t high_76619;
        
        loop_while_76617 = x_65393;
        low_76618 = (int64_t) 0;
        high_76619 = i_65392;
        while (loop_while_76617) {
            int64_t x_76620 = add64(low_76618, high_76619);
            int64_t mid_76621 = sdiv64(x_76620, (int64_t) 2);
            bool x_76622 = sle64((int64_t) 0, mid_76621);
            bool y_76623 = slt64(mid_76621, n_65378);
            bool bounds_check_76624 = x_76622 && y_76623;
            bool index_certs_76625;
            
            if (!bounds_check_76624) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_76621,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_76626;
            
            mid_id_76626 = ((int64_t *) mem_71352.mem)[mid_76621];
            
            bool cond_76627 = slt64(mid_id_76626, (int64_t) 0);
            int64_t mid_idx_76628;
            
            if (cond_76627) {
                mid_idx_76628 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_76628 = mid_id_76626;
            }
            
            bool cond_76629 = sle64(defunc_0_g_res_76389, mid_idx_76628);
            int64_t loopres_76630;
            int64_t loopres_76631;
            
            if (cond_76629) {
                int64_t loopres_t_res_76632 = sub64(mid_76621, (int64_t) 1);
                
                loopres_76630 = low_76618;
                loopres_76631 = loopres_t_res_76632;
            } else {
                int64_t loopres_f_res_76633 = add64((int64_t) 1, mid_76621);
                
                loopres_76630 = loopres_f_res_76633;
                loopres_76631 = high_76619;
            }
            
            bool loop_cond_76634 = sle64(loopres_76630, loopres_76631);
            bool loop_while_tmp_76740 = loop_cond_76634;
            int64_t low_tmp_76741 = loopres_76630;
            int64_t high_tmp_76742 = loopres_76631;
            
            loop_while_76617 = loop_while_tmp_76740;
            low_76618 = low_tmp_76741;
            high_76619 = high_tmp_76742;
        }
        init_idx_76390 = loop_while_76617;
        init_idx_76391 = low_76618;
        init_idx_76392 = high_76619;
        
        bool idx_76411;
        int64_t idx_76412;
        int64_t idx_76413;
        int64_t idx_76414;
        bool loop_while_76635;
        int64_t l_idx_76636;
        int64_t r_idx_76637;
        int64_t span_76638;
        
        loop_while_76635 = loop_cond_65403;
        l_idx_76636 = init_idx_76391;
        r_idx_76637 = init_idx_76391;
        span_76638 = (int64_t) 1;
        while (loop_while_76635) {
            int64_t max_arg_76639 = sub64(l_idx_76636, (int64_t) 1);
            int64_t max_res_76640 = smax64((int64_t) 0, max_arg_76639);
            int64_t min_arg_76641 = add64((int64_t) 1, r_idx_76637);
            int64_t min_res_76642 = smin64(min_arg_69676, min_arg_76641);
            bool x_76643 = sle64((int64_t) 0, max_res_76640);
            bool y_76644 = slt64(max_res_76640, n_65378);
            bool bounds_check_76645 = x_76643 && y_76644;
            bool index_certs_76646;
            
            if (!bounds_check_76645) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_76640,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_76647;
            
            x_76647 = ((int64_t *) mem_71352.mem)[max_res_76640];
            
            int64_t abs_arg_76648 = sub64(x_76647, defunc_0_g_res_76389);
            int64_t abs_res_76649 = abs64(abs_arg_76648);
            bool x_76650 = sle64((int64_t) 0, min_res_76642);
            bool y_76651 = slt64(min_res_76642, n_65378);
            bool bounds_check_76652 = x_76650 && y_76651;
            bool index_certs_76653;
            
            if (!bounds_check_76652) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_76642,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_76654;
            
            x_76654 = ((int64_t *) mem_71352.mem)[min_res_76642];
            
            int64_t abs_arg_76655 = sub64(x_76654, defunc_0_g_res_76389);
            int64_t abs_res_76656 = abs64(abs_arg_76655);
            bool cond_76657 = max_res_76640 == l_idx_76636;
            int64_t loopres_76658;
            int64_t loopres_76659;
            int64_t loopres_76660;
            
            if (cond_76657) {
                loopres_76658 = l_idx_76636;
                loopres_76659 = r_idx_76637;
                loopres_76660 = min_res_65398;
            } else {
                bool cond_76661 = slt64(abs_res_76649, abs_res_76656);
                bool cond_f_res_76662 = min_res_76642 == r_idx_76637;
                bool x_76663 = !cond_76661;
                bool y_76664 = cond_f_res_76662 && x_76663;
                bool cond_76665 = cond_76661 || y_76664;
                int64_t loopres_f_res_76666;
                
                if (cond_76665) {
                    loopres_f_res_76666 = max_res_76640;
                } else {
                    loopres_f_res_76666 = l_idx_76636;
                }
                
                int64_t loopres_f_res_76667;
                
                if (cond_76665) {
                    loopres_f_res_76667 = r_idx_76637;
                } else {
                    loopres_f_res_76667 = min_res_76642;
                }
                
                int64_t loopres_f_res_76668;
                
                if (cond_76665) {
                    int64_t loopres_f_res_t_res_76669 = add64((int64_t) 1,
                                                              span_76638);
                    
                    loopres_f_res_76668 = loopres_f_res_t_res_76669;
                } else {
                    int64_t loopres_f_res_f_res_76670 = add64((int64_t) 1,
                                                              span_76638);
                    
                    loopres_f_res_76668 = loopres_f_res_f_res_76670;
                }
                loopres_76658 = loopres_f_res_76666;
                loopres_76659 = loopres_f_res_76667;
                loopres_76660 = loopres_f_res_76668;
            }
            
            bool loop_cond_76671 = slt64(loopres_76660, min_res_65398);
            bool loop_while_tmp_76743 = loop_cond_76671;
            int64_t l_idx_tmp_76744 = loopres_76658;
            int64_t r_idx_tmp_76745 = loopres_76659;
            int64_t span_tmp_76746 = loopres_76660;
            
            loop_while_76635 = loop_while_tmp_76743;
            l_idx_76636 = l_idx_tmp_76744;
            r_idx_76637 = r_idx_tmp_76745;
            span_76638 = span_tmp_76746;
        }
        idx_76411 = loop_while_76635;
        idx_76412 = l_idx_76636;
        idx_76413 = r_idx_76637;
        idx_76414 = span_76638;
        
        int64_t min_res_76452 = smin64(min_arg_69677, idx_76412);
        int64_t max_res_76453 = smax64((int64_t) 0, min_res_76452);
        int64_t x_76454 = add64(min_res_69678, max_res_76453);
        int64_t r_76455 = sub64(x_76454, (int64_t) 1);
        bool x_76456 = sle64((int64_t) 0, r_76455);
        bool y_76457 = slt64(r_76455, n_65378);
        bool bounds_check_76458 = x_76456 && y_76457;
        bool index_certs_76459;
        
        if (!bounds_check_76458) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_76455,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_76460;
        
        x_76460 = ((int64_t *) mem_71349.mem)[r_76455];
        
        int64_t abs_arg_76461 = sub64(x_76460, min_res_76388);
        int64_t abs_res_76462 = abs64(abs_arg_76461);
        bool x_76463 = sle64((int64_t) 0, max_res_76453);
        bool y_76464 = slt64(max_res_76453, n_65378);
        bool bounds_check_76465 = x_76463 && y_76464;
        bool index_certs_76466;
        
        if (!bounds_check_76465) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_76453,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_76467;
        
        x_76467 = ((int64_t *) mem_71349.mem)[max_res_76453];
        
        int64_t abs_arg_76468 = sub64(x_76467, min_res_76388);
        int64_t abs_res_76469 = abs64(abs_arg_76468);
        int64_t max_res_76470 = smax64(abs_res_76462, abs_res_76469);
        double defunc_0_f_res_76471 = sitofp_i64_f64(max_res_76470);
        double defunc_1_f_res_76472 = max_res_69682 + defunc_0_f_res_76471;
        
        for (int64_t i_76672 = 0; i_76672 < q_65380; i_76672++) {
            double x_76675;
            
            x_76675 = ((double *) mem_71355.mem)[i_76672];
            
            bool cond_76676 = sle64(last_res_69657, i_76672);
            int64_t defunc_0_f_res_76677;
            
            if (cond_76676) {
                defunc_0_f_res_76677 = (int64_t) 0;
            } else {
                int64_t i_76678 = add64(max_res_76453, i_76672);
                int64_t defunc_0_add_arg_76679;
                
                defunc_0_add_arg_76679 = ((int64_t *) mem_71349.mem)[i_76678];
                
                int64_t defunc_1_add_res_76680 = add64((int64_t) 1,
                                                       defunc_0_add_arg_76679);
                
                defunc_0_f_res_76677 = defunc_1_add_res_76680;
            }
            
            int64_t binop_p_76681 = sub64(defunc_0_f_res_76677, min_res_76388);
            double defunc_0_f_res_76682 = sitofp_i64_f64(binop_p_76681);
            double abs_res_76683 = fabs(defunc_0_f_res_76682);
            double tmp1_76684 = abs_res_76683 / defunc_1_f_res_76472;
            double x_76685 = tmp1_76684 * tmp1_76684;
            double y_76686 = tmp1_76684 * x_76685;
            double tmp2_76687 = 1.0 - y_76686;
            double x_76688 = tmp2_76687 * tmp2_76687;
            double tmp3_76689 = tmp2_76687 * x_76688;
            double tmp4_76690 = x_76675 * tmp3_76689;
            
            ((double *) mem_76473)[i_76672] = defunc_0_f_res_76682;
            ((double *) mem_76475)[i_76672] = tmp4_76690;
        }
        
        double defunc_2_reduce_res_76504;
        double defunc_2_reduce_res_76505;
        double defunc_2_reduce_res_76506;
        double defunc_2_reduce_res_76507;
        double defunc_2_reduce_res_76508;
        double redout_76694;
        double redout_76695;
        double redout_76696;
        double redout_76697;
        double redout_76698;
        
        redout_76694 = 0.0;
        redout_76695 = 0.0;
        redout_76696 = 0.0;
        redout_76697 = 0.0;
        redout_76698 = 0.0;
        for (int64_t i_76693 = 0; i_76693 < q_65380; i_76693++) {
            double x_76701;
            
            x_76701 = ((double *) mem_76473)[i_76693];
            
            double x_76702;
            
            x_76702 = ((double *) mem_76475)[i_76693];
            
            double defunc_1_f_res_76703 = x_76701 * x_76702;
            double defunc_1_f_res_76704 = x_76701 * defunc_1_f_res_76703;
            double defunc_1_f_res_76705 = x_76701 * defunc_1_f_res_76704;
            double defunc_1_f_res_76706 = x_76701 * defunc_1_f_res_76705;
            double defunc_1_op_res_76707 = x_76702 + redout_76694;
            double defunc_1_op_res_76708 = defunc_1_f_res_76703 + redout_76695;
            double defunc_1_op_res_76709 = defunc_1_f_res_76704 + redout_76696;
            double defunc_1_op_res_76710 = defunc_1_f_res_76705 + redout_76697;
            double defunc_1_op_res_76711 = defunc_1_f_res_76706 + redout_76698;
            
            ((double *) mem_76500)[i_76693] = defunc_1_f_res_76704;
            ((double *) mem_76502)[i_76693] = defunc_1_f_res_76703;
            
            double redout_tmp_76749 = defunc_1_op_res_76707;
            double redout_tmp_76750 = defunc_1_op_res_76708;
            double redout_tmp_76751 = defunc_1_op_res_76709;
            double redout_tmp_76752 = defunc_1_op_res_76710;
            double redout_tmp_76753 = defunc_1_op_res_76711;
            
            redout_76694 = redout_tmp_76749;
            redout_76695 = redout_tmp_76750;
            redout_76696 = redout_tmp_76751;
            redout_76697 = redout_tmp_76752;
            redout_76698 = redout_tmp_76753;
        }
        defunc_2_reduce_res_76504 = redout_76694;
        defunc_2_reduce_res_76505 = redout_76695;
        defunc_2_reduce_res_76506 = redout_76696;
        defunc_2_reduce_res_76507 = redout_76697;
        defunc_2_reduce_res_76508 = redout_76698;
        
        double x_76532 = defunc_2_reduce_res_76506 * defunc_2_reduce_res_76508;
        double y_76533 = defunc_2_reduce_res_76507 * defunc_2_reduce_res_76507;
        double a12_76534 = x_76532 - y_76533;
        double x_76535 = defunc_2_reduce_res_76506 * defunc_2_reduce_res_76507;
        double y_76536 = defunc_2_reduce_res_76505 * defunc_2_reduce_res_76508;
        double b12_76537 = x_76535 - y_76536;
        double x_76538 = defunc_2_reduce_res_76505 * defunc_2_reduce_res_76507;
        double y_76539 = defunc_2_reduce_res_76506 * defunc_2_reduce_res_76506;
        double c12_76540 = x_76538 - y_76539;
        double x_76541 = defunc_2_reduce_res_76504 * defunc_2_reduce_res_76508;
        double b2_76542 = x_76541 - y_76539;
        double x_76543 = defunc_2_reduce_res_76505 * defunc_2_reduce_res_76506;
        double y_76544 = defunc_2_reduce_res_76504 * defunc_2_reduce_res_76507;
        double c2_76545 = x_76543 - y_76544;
        double x_76546 = defunc_2_reduce_res_76504 * a12_76534;
        double y_76547 = defunc_2_reduce_res_76505 * b12_76537;
        double x_76548 = x_76546 + y_76547;
        double y_76549 = defunc_2_reduce_res_76506 * c12_76540;
        double y_76550 = x_76548 + y_76549;
        double det_76551 = 1.0 / y_76550;
        double a12_76552 = a12_76534 * det_76551;
        double b12_76553 = b12_76537 * det_76551;
        double c12_76554 = c12_76540 * det_76551;
        double b2_76555 = b2_76542 * det_76551;
        double c2_76556 = c2_76545 * det_76551;
        double defunc_2_reduce_res_76557;
        double defunc_2_reduce_res_76558;
        double redout_76715;
        double redout_76716;
        
        redout_76715 = 0.0;
        redout_76716 = 0.0;
        for (int64_t i_76714 = 0; i_76714 < q_65380; i_76714++) {
            double x_76717;
            
            x_76717 = ((double *) mem_76475)[i_76714];
            
            double x_76718;
            
            x_76718 = ((double *) mem_76502)[i_76714];
            
            double x_76719;
            
            x_76719 = ((double *) mem_76500)[i_76714];
            
            bool cond_76720 = sle64(last_res_69657, i_76714);
            double defunc_0_f_res_76721;
            
            if (cond_76720) {
                defunc_0_f_res_76721 = 0.0;
            } else {
                int64_t i_76722 = add64(max_res_76453, i_76714);
                double defunc_0_add_arg_76723;
                
                defunc_0_add_arg_76723 = ((double *) mem_71346.mem)[i_76722];
                defunc_0_f_res_76721 = defunc_0_add_arg_76723;
            }
            
            double x_76724 = a12_76552 * x_76717;
            double y_76725 = b12_76553 * x_76718;
            double x_76726 = x_76724 + y_76725;
            double y_76727 = c12_76554 * x_76719;
            double x_76728 = x_76726 + y_76727;
            double defunc_9_fit_fun_res_76729 = defunc_0_f_res_76721 * x_76728;
            double x_76730 = b12_76553 * x_76717;
            double y_76731 = b2_76555 * x_76718;
            double x_76732 = x_76730 + y_76731;
            double y_76733 = c2_76556 * x_76719;
            double x_76734 = x_76732 + y_76733;
            double defunc_9_slope_fun_res_76735 = defunc_0_f_res_76721 *
                   x_76734;
            double defunc_1_op_res_76736 = defunc_9_fit_fun_res_76729 +
                   redout_76715;
            double defunc_1_op_res_76737 = defunc_9_slope_fun_res_76735 +
                   redout_76716;
            double redout_tmp_76756 = defunc_1_op_res_76736;
            double redout_tmp_76757 = defunc_1_op_res_76737;
            
            redout_76715 = redout_tmp_76756;
            redout_76716 = redout_tmp_76757;
        }
        defunc_2_reduce_res_76557 = redout_76715;
        defunc_2_reduce_res_76558 = redout_76716;
        ((double *) mem_71430.mem)[gtid_76386] = defunc_2_reduce_res_76557;
        ((double *) mem_71433.mem)[gtid_76386] = defunc_2_reduce_res_76558;
    }
    
  cleanup:
    { }
    free(mem_76473);
    free(mem_76475);
    free(mem_76500);
    free(mem_76502);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77405_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77405_end -
                 futhark_mc_segmap_parloop_77405_start;
        
        ctx->futhark_mc_segmap_parloop_77405_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77405_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77405_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77403(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76385 = tid;
    int num_tasks_76615 = info.nsubtasks;
    struct futhark_mc_task_77402 *futhark_mc_task_77402 =
                                 (struct futhark_mc_task_77402 *) args;
    struct futhark_context *ctx = futhark_mc_task_77402->ctx;
    uint64_t futhark_mc_segmap_task_77403_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77403_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77402->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77402->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77402->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77402->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77402->free_i_65392;
    bool x_65393 = futhark_mc_task_77402->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77402->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77402->free_loop_cond_65403;
    int64_t last_res_69657 = futhark_mc_task_77402->free_last_res_69657;
    int64_t min_arg_69676 = futhark_mc_task_77402->free_min_arg_69676;
    int64_t min_arg_69677 = futhark_mc_task_77402->free_min_arg_69677;
    int64_t min_res_69678 = futhark_mc_task_77402->free_min_res_69678;
    double max_res_69682 = futhark_mc_task_77402->free_max_res_69682;
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_task_77402->free_mem_71346, .size =
                                 0, .references =NULL};
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_task_77402->free_mem_71349, .size =
                                 0, .references =NULL};
    struct memblock mem_71352 = {.desc ="mem_71352", .mem =
                                 futhark_mc_task_77402->free_mem_71352, .size =
                                 0, .references =NULL};
    int64_t bytes_71354 = futhark_mc_task_77402->free_bytes_71354;
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_task_77402->free_mem_71355, .size =
                                 0, .references =NULL};
    struct memblock mem_71430 = {.desc ="mem_71430", .mem =
                                 futhark_mc_task_77402->free_mem_71430, .size =
                                 0, .references =NULL};
    struct memblock mem_71433 = {.desc ="mem_71433", .mem =
                                 futhark_mc_task_77402->free_mem_71433, .size =
                                 0, .references =NULL};
    int64_t iter_76616;
    struct futhark_mc_segmap_parloop_struct_77404
    futhark_mc_segmap_parloop_struct_77404;
    
    futhark_mc_segmap_parloop_struct_77404.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77404.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77404.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77404.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77404.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77404.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77404.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77404.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77404.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77404.free_last_res_69657 = last_res_69657;
    futhark_mc_segmap_parloop_struct_77404.free_min_arg_69676 = min_arg_69676;
    futhark_mc_segmap_parloop_struct_77404.free_min_arg_69677 = min_arg_69677;
    futhark_mc_segmap_parloop_struct_77404.free_min_res_69678 = min_res_69678;
    futhark_mc_segmap_parloop_struct_77404.free_max_res_69682 = max_res_69682;
    futhark_mc_segmap_parloop_struct_77404.free_mem_71346 = mem_71346.mem;
    futhark_mc_segmap_parloop_struct_77404.free_mem_71349 = mem_71349.mem;
    futhark_mc_segmap_parloop_struct_77404.free_mem_71352 = mem_71352.mem;
    futhark_mc_segmap_parloop_struct_77404.free_bytes_71354 = bytes_71354;
    futhark_mc_segmap_parloop_struct_77404.free_mem_71355 = mem_71355.mem;
    futhark_mc_segmap_parloop_struct_77404.free_mem_71430 = mem_71430.mem;
    futhark_mc_segmap_parloop_struct_77404.free_mem_71433 = mem_71433.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77405_task;
    
    futhark_mc_segmap_parloop_77405_task.name =
        "futhark_mc_segmap_parloop_77405";
    futhark_mc_segmap_parloop_77405_task.fn = futhark_mc_segmap_parloop_77405;
    futhark_mc_segmap_parloop_77405_task.args =
        &futhark_mc_segmap_parloop_struct_77404;
    futhark_mc_segmap_parloop_77405_task.iterations = iterations;
    futhark_mc_segmap_parloop_77405_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77405_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77405_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77405_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77405_task);
    
    if (futhark_mc_segmap_parloop_77405_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77405_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77405_total_end -
                 futhark_mc_segmap_parloop_77405_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77405_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77405_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77405_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77403_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77403_end -
                 futhark_mc_segmap_task_77403_start;
        
        ctx->futhark_mc_segmap_task_77403_runs[tid]++;
        ctx->futhark_mc_segmap_task_77403_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77403_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77411 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_q_65380;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    bool free_x_65393;
    int64_t free_min_res_65398;
    bool free_loop_cond_65403;
    int64_t free_last_res_69657;
    int64_t free_min_arg_69676;
    int64_t free_min_arg_69677;
    int64_t free_min_res_69678;
    double free_max_res_69682;
    unsigned char *free_mem_71346;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71352;
    int64_t free_bytes_71354;
    unsigned char *free_mem_71355;
    unsigned char *free_mem_71430;
    unsigned char *free_mem_71433;
};
struct futhark_mc_task_77417 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_69657;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71355;
    int64_t free_min_res_76192;
    int64_t free_max_res_76257;
    double free_defunc_1_f_res_76276;
    unsigned char *free_mem_76277;
    unsigned char *free_mem_76278;
};
struct futhark_mc_segmap_parloop_struct_77419 {
    struct futhark_context *ctx;
    int64_t free_q_65380;
    int64_t free_last_res_69657;
    unsigned char *free_mem_71349;
    unsigned char *free_mem_71355;
    int64_t free_min_res_76192;
    int64_t free_max_res_76257;
    double free_defunc_1_f_res_76276;
    unsigned char *free_mem_76277;
    unsigned char *free_mem_76278;
};
static int futhark_mc_segmap_parloop_77420(void *args, int64_t start,
                                           int64_t end, int flat_tid_76814,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77419
    *futhark_mc_segmap_parloop_struct_77419 =
    (struct futhark_mc_segmap_parloop_struct_77419 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77419->ctx;
    uint64_t futhark_mc_segmap_parloop_77420_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77420_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77419->free_q_65380;
    int64_t last_res_69657 =
            futhark_mc_segmap_parloop_struct_77419->free_last_res_69657;
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_segmap_parloop_struct_77419->free_mem_71349,
                                 .size =0, .references =NULL};
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_segmap_parloop_struct_77419->free_mem_71355,
                                 .size =0, .references =NULL};
    int64_t min_res_76192 =
            futhark_mc_segmap_parloop_struct_77419->free_min_res_76192;
    int64_t max_res_76257 =
            futhark_mc_segmap_parloop_struct_77419->free_max_res_76257;
    double defunc_1_f_res_76276 =
           futhark_mc_segmap_parloop_struct_77419->free_defunc_1_f_res_76276;
    struct memblock mem_76277 = {.desc ="mem_76277", .mem =
                                 futhark_mc_segmap_parloop_struct_77419->free_mem_76277,
                                 .size =0, .references =NULL};
    struct memblock mem_76278 = {.desc ="mem_76278", .mem =
                                 futhark_mc_segmap_parloop_struct_77419->free_mem_76278,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76892 = start;
    
    for (; iter_76892 < end; iter_76892++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76896 = q_65380;
        int64_t gtid_76815 = iter_76892;
        int64_t remnant_76897 = iter_76892 - gtid_76815;
        double x_76816;
        
        x_76816 = ((double *) mem_71355.mem)[gtid_76815];
        
        bool cond_76817 = sle64(last_res_69657, gtid_76815);
        int64_t defunc_0_f_res_76818;
        
        if (cond_76817) {
            defunc_0_f_res_76818 = (int64_t) 0;
        } else {
            int64_t i_76893 = add64(max_res_76257, gtid_76815);
            int64_t defunc_0_add_arg_76894;
            
            defunc_0_add_arg_76894 = ((int64_t *) mem_71349.mem)[i_76893];
            
            int64_t defunc_1_add_res_76895 = add64((int64_t) 1,
                                                   defunc_0_add_arg_76894);
            
            defunc_0_f_res_76818 = defunc_1_add_res_76895;
        }
        
        int64_t binop_p_76822 = sub64(defunc_0_f_res_76818, min_res_76192);
        double defunc_0_f_res_76823 = sitofp_i64_f64(binop_p_76822);
        double abs_res_76824 = fabs(defunc_0_f_res_76823);
        double tmp1_76825 = abs_res_76824 / defunc_1_f_res_76276;
        double x_76826 = tmp1_76825 * tmp1_76825;
        double y_76827 = tmp1_76825 * x_76826;
        double tmp2_76828 = 1.0 - y_76827;
        double x_76829 = tmp2_76828 * tmp2_76828;
        double tmp3_76830 = tmp2_76828 * x_76829;
        double tmp4_76831 = x_76816 * tmp3_76830;
        
        ((double *) mem_76277.mem)[gtid_76815] = defunc_0_f_res_76823;
        ((double *) mem_76278.mem)[gtid_76815] = tmp4_76831;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77420_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77420_end -
                 futhark_mc_segmap_parloop_77420_start;
        
        ctx->futhark_mc_segmap_parloop_77420_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77420_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77420_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77418(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76814 = tid;
    int num_tasks_76891 = info.nsubtasks;
    struct futhark_mc_task_77417 *futhark_mc_task_77417 =
                                 (struct futhark_mc_task_77417 *) args;
    struct futhark_context *ctx = futhark_mc_task_77417->ctx;
    uint64_t futhark_mc_segmap_task_77418_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77418_start = get_wall_time();
    
    int64_t q_65380 = futhark_mc_task_77417->free_q_65380;
    int64_t last_res_69657 = futhark_mc_task_77417->free_last_res_69657;
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_task_77417->free_mem_71349, .size =
                                 0, .references =NULL};
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_task_77417->free_mem_71355, .size =
                                 0, .references =NULL};
    int64_t min_res_76192 = futhark_mc_task_77417->free_min_res_76192;
    int64_t max_res_76257 = futhark_mc_task_77417->free_max_res_76257;
    double defunc_1_f_res_76276 =
           futhark_mc_task_77417->free_defunc_1_f_res_76276;
    struct memblock mem_76277 = {.desc ="mem_76277", .mem =
                                 futhark_mc_task_77417->free_mem_76277, .size =
                                 0, .references =NULL};
    struct memblock mem_76278 = {.desc ="mem_76278", .mem =
                                 futhark_mc_task_77417->free_mem_76278, .size =
                                 0, .references =NULL};
    int64_t iter_76892;
    struct futhark_mc_segmap_parloop_struct_77419
    futhark_mc_segmap_parloop_struct_77419;
    
    futhark_mc_segmap_parloop_struct_77419.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77419.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77419.free_last_res_69657 = last_res_69657;
    futhark_mc_segmap_parloop_struct_77419.free_mem_71349 = mem_71349.mem;
    futhark_mc_segmap_parloop_struct_77419.free_mem_71355 = mem_71355.mem;
    futhark_mc_segmap_parloop_struct_77419.free_min_res_76192 = min_res_76192;
    futhark_mc_segmap_parloop_struct_77419.free_max_res_76257 = max_res_76257;
    futhark_mc_segmap_parloop_struct_77419.free_defunc_1_f_res_76276 =
        defunc_1_f_res_76276;
    futhark_mc_segmap_parloop_struct_77419.free_mem_76277 = mem_76277.mem;
    futhark_mc_segmap_parloop_struct_77419.free_mem_76278 = mem_76278.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77420_task;
    
    futhark_mc_segmap_parloop_77420_task.name =
        "futhark_mc_segmap_parloop_77420";
    futhark_mc_segmap_parloop_77420_task.fn = futhark_mc_segmap_parloop_77420;
    futhark_mc_segmap_parloop_77420_task.args =
        &futhark_mc_segmap_parloop_struct_77419;
    futhark_mc_segmap_parloop_77420_task.iterations = iterations;
    futhark_mc_segmap_parloop_77420_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77420_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77420_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77420_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77420_task);
    
    if (futhark_mc_segmap_parloop_77420_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77420_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77420_total_end -
                 futhark_mc_segmap_parloop_77420_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77420_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77420_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77420_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77418_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77418_end -
                 futhark_mc_segmap_task_77418_start;
        
        ctx->futhark_mc_segmap_task_77418_runs[tid]++;
        ctx->futhark_mc_segmap_task_77418_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77418_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77421 {
    struct futhark_context *ctx;
    unsigned char *free_mem_76277;
    unsigned char *free_mem_76278;
    double *retval_defunc_2_reduce_res_76301;
    double *retval_defunc_2_reduce_res_76302;
    double *retval_defunc_2_reduce_res_76303;
    double *retval_defunc_2_reduce_res_76304;
    double *retval_defunc_2_reduce_res_76305;
    unsigned char *retval_mem_76299;
    unsigned char *retval_mem_76300;
};
struct futhark_mc_segred_stage_1_parloop_struct_77428 {
    struct futhark_context *ctx;
    unsigned char *free_mem_76277;
    unsigned char *free_mem_76278;
    unsigned char *free_mem_76299;
    unsigned char *free_mem_76300;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76899;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76901;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76903;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76905;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76907;
};
static int futhark_mc_segred_stage_1_parloop_77429(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_76832, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77428
    *futhark_mc_segred_stage_1_parloop_struct_77428 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77428 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77428->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77429_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77429_start = get_wall_time();
    
    struct memblock mem_76277 = {.desc ="mem_76277", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77428->free_mem_76277,
                                 .size =0, .references =NULL};
    struct memblock mem_76278 = {.desc ="mem_76278", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77428->free_mem_76278,
                                 .size =0, .references =NULL};
    struct memblock mem_76299 = {.desc ="mem_76299", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77428->free_mem_76299,
                                 .size =0, .references =NULL};
    struct memblock mem_76300 = {.desc ="mem_76300", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77428->free_mem_76300,
                                 .size =0, .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_76899 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76899",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77428->free_reduce_stage_1_tid_res_arr_mem_76899,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_76901 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76901",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77428->free_reduce_stage_1_tid_res_arr_mem_76901,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_76903 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76903",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77428->free_reduce_stage_1_tid_res_arr_mem_76903,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_76905 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76905",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77428->free_reduce_stage_1_tid_res_arr_mem_76905,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_76907 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76907",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77428->free_reduce_stage_1_tid_res_arr_mem_76907,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76909 = start;
    double x_76834;
    double x_76835;
    double x_76837;
    double x_76838;
    double x_76840;
    double x_76841;
    double x_76843;
    double x_76844;
    double x_76846;
    double x_76847;
    double local_acc_76910 = 0.0;
    double local_acc_76911 = 0.0;
    double local_acc_76912 = 0.0;
    double local_acc_76913 = 0.0;
    double local_acc_76914 = 0.0;
    
    for (; iter_76909 < end; iter_76909++) {
        int64_t gtid_76833 = iter_76909;
        double x_76849;
        
        x_76849 = ((double *) mem_76277.mem)[gtid_76833];
        
        double x_76850;
        
        x_76850 = ((double *) mem_76278.mem)[gtid_76833];
        
        double defunc_1_f_res_76851 = x_76849 * x_76850;
        double defunc_1_f_res_76852 = x_76849 * defunc_1_f_res_76851;
        double defunc_1_f_res_76853 = x_76849 * defunc_1_f_res_76852;
        double defunc_1_f_res_76854 = x_76849 * defunc_1_f_res_76853;
        
        // save map-out results
        {
            ((double *) mem_76299.mem)[gtid_76833] = defunc_1_f_res_76852;
            ((double *) mem_76300.mem)[gtid_76833] = defunc_1_f_res_76851;
        }
        // Load accum params
        {
            x_76834 = local_acc_76910;
        }
        // Load next params
        {
            x_76835 = x_76850;
        }
        // Red body
        {
            double defunc_1_op_res_76836 = x_76834 + x_76835;
            
            local_acc_76910 = defunc_1_op_res_76836;
        }
        // Load accum params
        {
            x_76837 = local_acc_76911;
        }
        // Load next params
        {
            x_76838 = defunc_1_f_res_76851;
        }
        // Red body
        {
            double defunc_1_op_res_76839 = x_76837 + x_76838;
            
            local_acc_76911 = defunc_1_op_res_76839;
        }
        // Load accum params
        {
            x_76840 = local_acc_76912;
        }
        // Load next params
        {
            x_76841 = defunc_1_f_res_76852;
        }
        // Red body
        {
            double defunc_1_op_res_76842 = x_76840 + x_76841;
            
            local_acc_76912 = defunc_1_op_res_76842;
        }
        // Load accum params
        {
            x_76843 = local_acc_76913;
        }
        // Load next params
        {
            x_76844 = defunc_1_f_res_76853;
        }
        // Red body
        {
            double defunc_1_op_res_76845 = x_76843 + x_76844;
            
            local_acc_76913 = defunc_1_op_res_76845;
        }
        // Load accum params
        {
            x_76846 = local_acc_76914;
        }
        // Load next params
        {
            x_76847 = defunc_1_f_res_76854;
        }
        // Red body
        {
            double defunc_1_op_res_76848 = x_76846 + x_76847;
            
            local_acc_76914 = defunc_1_op_res_76848;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_76899.mem)[flat_tid_76832] =
        local_acc_76910;
    ((double *) reduce_stage_1_tid_res_arr_mem_76901.mem)[flat_tid_76832] =
        local_acc_76911;
    ((double *) reduce_stage_1_tid_res_arr_mem_76903.mem)[flat_tid_76832] =
        local_acc_76912;
    ((double *) reduce_stage_1_tid_res_arr_mem_76905.mem)[flat_tid_76832] =
        local_acc_76913;
    ((double *) reduce_stage_1_tid_res_arr_mem_76907.mem)[flat_tid_76832] =
        local_acc_76914;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77429_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77429_end -
                 futhark_mc_segred_stage_1_parloop_77429_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77429_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77429_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77429_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77422(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76832 = tid;
    int num_tasks_76898 = info.nsubtasks;
    struct futhark_mc_task_77421 *futhark_mc_task_77421 =
                                 (struct futhark_mc_task_77421 *) args;
    struct futhark_context *ctx = futhark_mc_task_77421->ctx;
    uint64_t futhark_mc_segred_task_77422_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77422_start = get_wall_time();
    
    struct memblock mem_76277 = {.desc ="mem_76277", .mem =
                                 futhark_mc_task_77421->free_mem_76277, .size =
                                 0, .references =NULL};
    struct memblock mem_76278 = {.desc ="mem_76278", .mem =
                                 futhark_mc_task_77421->free_mem_76278, .size =
                                 0, .references =NULL};
    double defunc_2_reduce_res_76301 =
           *futhark_mc_task_77421->retval_defunc_2_reduce_res_76301;
    double defunc_2_reduce_res_76302 =
           *futhark_mc_task_77421->retval_defunc_2_reduce_res_76302;
    double defunc_2_reduce_res_76303 =
           *futhark_mc_task_77421->retval_defunc_2_reduce_res_76303;
    double defunc_2_reduce_res_76304 =
           *futhark_mc_task_77421->retval_defunc_2_reduce_res_76304;
    double defunc_2_reduce_res_76305 =
           *futhark_mc_task_77421->retval_defunc_2_reduce_res_76305;
    struct memblock mem_76299 = {.desc ="mem_76299", .mem =
                                 futhark_mc_task_77421->retval_mem_76299,
                                 .size =0, .references =NULL};
    struct memblock mem_76300 = {.desc ="mem_76300", .mem =
                                 futhark_mc_task_77421->retval_mem_76300,
                                 .size =0, .references =NULL};
    size_t reduce_stage_1_tid_res_arr_mem_76899_cached_sizze_77423 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76899 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_76901_cached_sizze_77424 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76901 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_76903_cached_sizze_77425 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76903 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_76905_cached_sizze_77426 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76905 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_76907_cached_sizze_77427 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76907 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_76899_cached_sizze_77423 <
        (size_t) ((int64_t) 8 * num_tasks_76898)) {
        reduce_stage_1_tid_res_arr_mem_76899 =
            realloc(reduce_stage_1_tid_res_arr_mem_76899, (int64_t) 8 *
                    num_tasks_76898);
        reduce_stage_1_tid_res_arr_mem_76899_cached_sizze_77423 = (int64_t) 8 *
            num_tasks_76898;
    }
    if (reduce_stage_1_tid_res_arr_mem_76901_cached_sizze_77424 <
        (size_t) ((int64_t) 8 * num_tasks_76898)) {
        reduce_stage_1_tid_res_arr_mem_76901 =
            realloc(reduce_stage_1_tid_res_arr_mem_76901, (int64_t) 8 *
                    num_tasks_76898);
        reduce_stage_1_tid_res_arr_mem_76901_cached_sizze_77424 = (int64_t) 8 *
            num_tasks_76898;
    }
    if (reduce_stage_1_tid_res_arr_mem_76903_cached_sizze_77425 <
        (size_t) ((int64_t) 8 * num_tasks_76898)) {
        reduce_stage_1_tid_res_arr_mem_76903 =
            realloc(reduce_stage_1_tid_res_arr_mem_76903, (int64_t) 8 *
                    num_tasks_76898);
        reduce_stage_1_tid_res_arr_mem_76903_cached_sizze_77425 = (int64_t) 8 *
            num_tasks_76898;
    }
    if (reduce_stage_1_tid_res_arr_mem_76905_cached_sizze_77426 <
        (size_t) ((int64_t) 8 * num_tasks_76898)) {
        reduce_stage_1_tid_res_arr_mem_76905 =
            realloc(reduce_stage_1_tid_res_arr_mem_76905, (int64_t) 8 *
                    num_tasks_76898);
        reduce_stage_1_tid_res_arr_mem_76905_cached_sizze_77426 = (int64_t) 8 *
            num_tasks_76898;
    }
    if (reduce_stage_1_tid_res_arr_mem_76907_cached_sizze_77427 <
        (size_t) ((int64_t) 8 * num_tasks_76898)) {
        reduce_stage_1_tid_res_arr_mem_76907 =
            realloc(reduce_stage_1_tid_res_arr_mem_76907, (int64_t) 8 *
                    num_tasks_76898);
        reduce_stage_1_tid_res_arr_mem_76907_cached_sizze_77427 = (int64_t) 8 *
            num_tasks_76898;
    }
    
    int64_t iter_76909;
    struct futhark_mc_segred_stage_1_parloop_struct_77428
    futhark_mc_segred_stage_1_parloop_struct_77428;
    
    futhark_mc_segred_stage_1_parloop_struct_77428.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_mem_76277 =
        mem_76277.mem;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_mem_76278 =
        mem_76278.mem;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_mem_76299 =
        mem_76299.mem;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_mem_76300 =
        mem_76300.mem;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_reduce_stage_1_tid_res_arr_mem_76899 =
        reduce_stage_1_tid_res_arr_mem_76899;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_reduce_stage_1_tid_res_arr_mem_76901 =
        reduce_stage_1_tid_res_arr_mem_76901;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_reduce_stage_1_tid_res_arr_mem_76903 =
        reduce_stage_1_tid_res_arr_mem_76903;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_reduce_stage_1_tid_res_arr_mem_76905 =
        reduce_stage_1_tid_res_arr_mem_76905;
    futhark_mc_segred_stage_1_parloop_struct_77428.free_reduce_stage_1_tid_res_arr_mem_76907 =
        reduce_stage_1_tid_res_arr_mem_76907;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77429_task;
    
    futhark_mc_segred_stage_1_parloop_77429_task.name =
        "futhark_mc_segred_stage_1_parloop_77429";
    futhark_mc_segred_stage_1_parloop_77429_task.fn =
        futhark_mc_segred_stage_1_parloop_77429;
    futhark_mc_segred_stage_1_parloop_77429_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77428;
    futhark_mc_segred_stage_1_parloop_77429_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77429_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77429_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77429_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77429_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77429_task);
    
    if (futhark_mc_segred_stage_1_parloop_77429_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77429_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77429_total_end -
                 futhark_mc_segred_stage_1_parloop_77429_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77429_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77429_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77429_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_76301 = 0.0;
        defunc_2_reduce_res_76302 = 0.0;
        defunc_2_reduce_res_76303 = 0.0;
        defunc_2_reduce_res_76304 = 0.0;
        defunc_2_reduce_res_76305 = 0.0;
    }
    
    double x_76915;
    double x_76916;
    double x_76918;
    double x_76919;
    double x_76921;
    double x_76922;
    double x_76924;
    double x_76925;
    double x_76927;
    double x_76928;
    
    for (int32_t i_76930 = 0; i_76930 < num_tasks_76898; i_76930++) {
        flat_tid_76832 = i_76930;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_76915 = defunc_2_reduce_res_76301;
            }
            // load next params
            {
                x_76916 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76899)[flat_tid_76832];
            }
            // red body
            {
                double defunc_1_op_res_76917 = x_76915 + x_76916;
                
                defunc_2_reduce_res_76301 = defunc_1_op_res_76917;
            }
            // load acc params
            {
                x_76918 = defunc_2_reduce_res_76302;
            }
            // load next params
            {
                x_76919 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76901)[flat_tid_76832];
            }
            // red body
            {
                double defunc_1_op_res_76920 = x_76918 + x_76919;
                
                defunc_2_reduce_res_76302 = defunc_1_op_res_76920;
            }
            // load acc params
            {
                x_76921 = defunc_2_reduce_res_76303;
            }
            // load next params
            {
                x_76922 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76903)[flat_tid_76832];
            }
            // red body
            {
                double defunc_1_op_res_76923 = x_76921 + x_76922;
                
                defunc_2_reduce_res_76303 = defunc_1_op_res_76923;
            }
            // load acc params
            {
                x_76924 = defunc_2_reduce_res_76304;
            }
            // load next params
            {
                x_76925 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76905)[flat_tid_76832];
            }
            // red body
            {
                double defunc_1_op_res_76926 = x_76924 + x_76925;
                
                defunc_2_reduce_res_76304 = defunc_1_op_res_76926;
            }
            // load acc params
            {
                x_76927 = defunc_2_reduce_res_76305;
            }
            // load next params
            {
                x_76928 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76907)[flat_tid_76832];
            }
            // red body
            {
                double defunc_1_op_res_76929 = x_76927 + x_76928;
                
                defunc_2_reduce_res_76305 = defunc_1_op_res_76929;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_76899);
        free(reduce_stage_1_tid_res_arr_mem_76901);
        free(reduce_stage_1_tid_res_arr_mem_76903);
        free(reduce_stage_1_tid_res_arr_mem_76905);
        free(reduce_stage_1_tid_res_arr_mem_76907);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77422_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77422_end -
                 futhark_mc_segred_task_77422_start;
        
        ctx->futhark_mc_segred_task_77422_runs[tid]++;
        ctx->futhark_mc_segred_task_77422_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77422_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77421->retval_defunc_2_reduce_res_76301 =
            defunc_2_reduce_res_76301;
        *futhark_mc_task_77421->retval_defunc_2_reduce_res_76302 =
            defunc_2_reduce_res_76302;
        *futhark_mc_task_77421->retval_defunc_2_reduce_res_76303 =
            defunc_2_reduce_res_76303;
        *futhark_mc_task_77421->retval_defunc_2_reduce_res_76304 =
            defunc_2_reduce_res_76304;
        *futhark_mc_task_77421->retval_defunc_2_reduce_res_76305 =
            defunc_2_reduce_res_76305;
        futhark_mc_task_77421->retval_mem_76299 = mem_76299.mem;
        futhark_mc_task_77421->retval_mem_76300 = mem_76300.mem;
    }
    return err;
}
struct futhark_mc_task_77430 {
    struct futhark_context *ctx;
    int64_t free_last_res_69657;
    unsigned char *free_mem_71346;
    int64_t free_max_res_76257;
    unsigned char *free_mem_76278;
    unsigned char *free_mem_76299;
    unsigned char *free_mem_76300;
    double free_a12_76351;
    double free_b12_76352;
    double free_c12_76353;
    double free_b2_76354;
    double free_c2_76355;
    double *retval_defunc_2_reduce_res_76356;
    double *retval_defunc_2_reduce_res_76357;
};
struct futhark_mc_segred_stage_1_parloop_struct_77434 {
    struct futhark_context *ctx;
    int64_t free_last_res_69657;
    unsigned char *free_mem_71346;
    int64_t free_max_res_76257;
    unsigned char *free_mem_76278;
    unsigned char *free_mem_76299;
    unsigned char *free_mem_76300;
    double free_a12_76351;
    double free_b12_76352;
    double free_c12_76353;
    double free_b2_76354;
    double free_c2_76355;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76932;
    unsigned char *free_reduce_stage_1_tid_res_arr_mem_76934;
};
static int futhark_mc_segred_stage_1_parloop_77435(void *args, int64_t start,
                                                   int64_t end,
                                                   int flat_tid_76855, int tid)
{
    int err = 0;
    struct futhark_mc_segred_stage_1_parloop_struct_77434
    *futhark_mc_segred_stage_1_parloop_struct_77434 =
    (struct futhark_mc_segred_stage_1_parloop_struct_77434 *) args;
    struct futhark_context *ctx =
                           futhark_mc_segred_stage_1_parloop_struct_77434->ctx;
    uint64_t futhark_mc_segred_stage_1_parloop_77435_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77435_start = get_wall_time();
    
    int64_t last_res_69657 =
            futhark_mc_segred_stage_1_parloop_struct_77434->free_last_res_69657;
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77434->free_mem_71346,
                                 .size =0, .references =NULL};
    int64_t max_res_76257 =
            futhark_mc_segred_stage_1_parloop_struct_77434->free_max_res_76257;
    struct memblock mem_76278 = {.desc ="mem_76278", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77434->free_mem_76278,
                                 .size =0, .references =NULL};
    struct memblock mem_76299 = {.desc ="mem_76299", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77434->free_mem_76299,
                                 .size =0, .references =NULL};
    struct memblock mem_76300 = {.desc ="mem_76300", .mem =
                                 futhark_mc_segred_stage_1_parloop_struct_77434->free_mem_76300,
                                 .size =0, .references =NULL};
    double a12_76351 =
           futhark_mc_segred_stage_1_parloop_struct_77434->free_a12_76351;
    double b12_76352 =
           futhark_mc_segred_stage_1_parloop_struct_77434->free_b12_76352;
    double c12_76353 =
           futhark_mc_segred_stage_1_parloop_struct_77434->free_c12_76353;
    double b2_76354 =
           futhark_mc_segred_stage_1_parloop_struct_77434->free_b2_76354;
    double c2_76355 =
           futhark_mc_segred_stage_1_parloop_struct_77434->free_c2_76355;
    struct memblock reduce_stage_1_tid_res_arr_mem_76932 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76932",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77434->free_reduce_stage_1_tid_res_arr_mem_76932,
                                                            .size =0,
                                                            .references =NULL};
    struct memblock reduce_stage_1_tid_res_arr_mem_76934 = {.desc =
                                                            "reduce_stage_1_tid_res_arr_mem_76934",
                                                            .mem =
                                                            futhark_mc_segred_stage_1_parloop_struct_77434->free_reduce_stage_1_tid_res_arr_mem_76934,
                                                            .size =0,
                                                            .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_76936 = start;
    double x_76857;
    double x_76858;
    double x_76860;
    double x_76861;
    double local_acc_76937 = 0.0;
    double local_acc_76938 = 0.0;
    
    for (; iter_76936 < end; iter_76936++) {
        int64_t gtid_76856 = iter_76936;
        double x_76863;
        
        x_76863 = ((double *) mem_76278.mem)[gtid_76856];
        
        double x_76864;
        
        x_76864 = ((double *) mem_76300.mem)[gtid_76856];
        
        double x_76865;
        
        x_76865 = ((double *) mem_76299.mem)[gtid_76856];
        
        bool cond_76866 = sle64(last_res_69657, gtid_76856);
        double defunc_0_f_res_76867;
        
        if (cond_76866) {
            defunc_0_f_res_76867 = 0.0;
        } else {
            int64_t i_76868 = add64(max_res_76257, gtid_76856);
            double defunc_0_add_arg_76869;
            
            defunc_0_add_arg_76869 = ((double *) mem_71346.mem)[i_76868];
            defunc_0_f_res_76867 = defunc_0_add_arg_76869;
        }
        
        double x_76870 = a12_76351 * x_76863;
        double y_76871 = b12_76352 * x_76864;
        double x_76872 = x_76870 + y_76871;
        double y_76873 = c12_76353 * x_76865;
        double x_76874 = x_76872 + y_76873;
        double defunc_9_fit_fun_res_76875 = defunc_0_f_res_76867 * x_76874;
        double x_76876 = b12_76352 * x_76863;
        double y_76877 = b2_76354 * x_76864;
        double x_76878 = x_76876 + y_76877;
        double y_76879 = c2_76355 * x_76865;
        double x_76880 = x_76878 + y_76879;
        double defunc_9_slope_fun_res_76881 = defunc_0_f_res_76867 * x_76880;
        
        // save map-out results
        { }
        // Load accum params
        {
            x_76857 = local_acc_76937;
        }
        // Load next params
        {
            x_76858 = defunc_9_fit_fun_res_76875;
        }
        // Red body
        {
            double defunc_1_op_res_76859 = x_76857 + x_76858;
            
            local_acc_76937 = defunc_1_op_res_76859;
        }
        // Load accum params
        {
            x_76860 = local_acc_76938;
        }
        // Load next params
        {
            x_76861 = defunc_9_slope_fun_res_76881;
        }
        // Red body
        {
            double defunc_1_op_res_76862 = x_76860 + x_76861;
            
            local_acc_76938 = defunc_1_op_res_76862;
        }
    }
    ((double *) reduce_stage_1_tid_res_arr_mem_76932.mem)[flat_tid_76855] =
        local_acc_76937;
    ((double *) reduce_stage_1_tid_res_arr_mem_76934.mem)[flat_tid_76855] =
        local_acc_76938;
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77435_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77435_end -
                 futhark_mc_segred_stage_1_parloop_77435_start;
        
        ctx->futhark_mc_segred_stage_1_parloop_77435_runs[tid]++;
        ctx->futhark_mc_segred_stage_1_parloop_77435_total_runtime[tid] +=
            elapsed;
        ctx->futhark_mc_segred_stage_1_parloop_77435_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segred_task_77431(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76855 = tid;
    int num_tasks_76931 = info.nsubtasks;
    struct futhark_mc_task_77430 *futhark_mc_task_77430 =
                                 (struct futhark_mc_task_77430 *) args;
    struct futhark_context *ctx = futhark_mc_task_77430->ctx;
    uint64_t futhark_mc_segred_task_77431_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_task_77431_start = get_wall_time();
    
    int64_t last_res_69657 = futhark_mc_task_77430->free_last_res_69657;
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_task_77430->free_mem_71346, .size =
                                 0, .references =NULL};
    int64_t max_res_76257 = futhark_mc_task_77430->free_max_res_76257;
    struct memblock mem_76278 = {.desc ="mem_76278", .mem =
                                 futhark_mc_task_77430->free_mem_76278, .size =
                                 0, .references =NULL};
    struct memblock mem_76299 = {.desc ="mem_76299", .mem =
                                 futhark_mc_task_77430->free_mem_76299, .size =
                                 0, .references =NULL};
    struct memblock mem_76300 = {.desc ="mem_76300", .mem =
                                 futhark_mc_task_77430->free_mem_76300, .size =
                                 0, .references =NULL};
    double a12_76351 = futhark_mc_task_77430->free_a12_76351;
    double b12_76352 = futhark_mc_task_77430->free_b12_76352;
    double c12_76353 = futhark_mc_task_77430->free_c12_76353;
    double b2_76354 = futhark_mc_task_77430->free_b2_76354;
    double c2_76355 = futhark_mc_task_77430->free_c2_76355;
    double defunc_2_reduce_res_76356 =
           *futhark_mc_task_77430->retval_defunc_2_reduce_res_76356;
    double defunc_2_reduce_res_76357 =
           *futhark_mc_task_77430->retval_defunc_2_reduce_res_76357;
    size_t reduce_stage_1_tid_res_arr_mem_76932_cached_sizze_77432 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76932 = NULL;
    size_t reduce_stage_1_tid_res_arr_mem_76934_cached_sizze_77433 = 0;
    unsigned char *reduce_stage_1_tid_res_arr_mem_76934 = NULL;
    
    if (reduce_stage_1_tid_res_arr_mem_76932_cached_sizze_77432 <
        (size_t) ((int64_t) 8 * num_tasks_76931)) {
        reduce_stage_1_tid_res_arr_mem_76932 =
            realloc(reduce_stage_1_tid_res_arr_mem_76932, (int64_t) 8 *
                    num_tasks_76931);
        reduce_stage_1_tid_res_arr_mem_76932_cached_sizze_77432 = (int64_t) 8 *
            num_tasks_76931;
    }
    if (reduce_stage_1_tid_res_arr_mem_76934_cached_sizze_77433 <
        (size_t) ((int64_t) 8 * num_tasks_76931)) {
        reduce_stage_1_tid_res_arr_mem_76934 =
            realloc(reduce_stage_1_tid_res_arr_mem_76934, (int64_t) 8 *
                    num_tasks_76931);
        reduce_stage_1_tid_res_arr_mem_76934_cached_sizze_77433 = (int64_t) 8 *
            num_tasks_76931;
    }
    
    int64_t iter_76936;
    struct futhark_mc_segred_stage_1_parloop_struct_77434
    futhark_mc_segred_stage_1_parloop_struct_77434;
    
    futhark_mc_segred_stage_1_parloop_struct_77434.ctx = ctx;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_last_res_69657 =
        last_res_69657;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_mem_71346 =
        mem_71346.mem;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_max_res_76257 =
        max_res_76257;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_mem_76278 =
        mem_76278.mem;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_mem_76299 =
        mem_76299.mem;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_mem_76300 =
        mem_76300.mem;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_a12_76351 = a12_76351;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_b12_76352 = b12_76352;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_c12_76353 = c12_76353;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_b2_76354 = b2_76354;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_c2_76355 = c2_76355;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_reduce_stage_1_tid_res_arr_mem_76932 =
        reduce_stage_1_tid_res_arr_mem_76932;
    futhark_mc_segred_stage_1_parloop_struct_77434.free_reduce_stage_1_tid_res_arr_mem_76934 =
        reduce_stage_1_tid_res_arr_mem_76934;
    
    struct scheduler_parloop futhark_mc_segred_stage_1_parloop_77435_task;
    
    futhark_mc_segred_stage_1_parloop_77435_task.name =
        "futhark_mc_segred_stage_1_parloop_77435";
    futhark_mc_segred_stage_1_parloop_77435_task.fn =
        futhark_mc_segred_stage_1_parloop_77435;
    futhark_mc_segred_stage_1_parloop_77435_task.args =
        &futhark_mc_segred_stage_1_parloop_struct_77434;
    futhark_mc_segred_stage_1_parloop_77435_task.iterations = iterations;
    futhark_mc_segred_stage_1_parloop_77435_task.info = info;
    
    uint64_t futhark_mc_segred_stage_1_parloop_77435_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segred_stage_1_parloop_77435_total_start = get_wall_time();
    
    int futhark_mc_segred_stage_1_parloop_77435_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segred_stage_1_parloop_77435_task);
    
    if (futhark_mc_segred_stage_1_parloop_77435_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_stage_1_parloop_77435_total_end =
                 get_wall_time();
        uint64_t elapsed = futhark_mc_segred_stage_1_parloop_77435_total_end -
                 futhark_mc_segred_stage_1_parloop_77435_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77435_total_runs,
                           1, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77435_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segred_stage_1_parloop_77435_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    // neutral-initialise the output
    {
        defunc_2_reduce_res_76356 = 0.0;
        defunc_2_reduce_res_76357 = 0.0;
    }
    
    double x_76939;
    double x_76940;
    double x_76942;
    double x_76943;
    
    for (int32_t i_76945 = 0; i_76945 < num_tasks_76931; i_76945++) {
        flat_tid_76855 = i_76945;
        // Apply main thread reduction
        {
            // load acc params
            {
                x_76939 = defunc_2_reduce_res_76356;
            }
            // load next params
            {
                x_76940 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76932)[flat_tid_76855];
            }
            // red body
            {
                double defunc_1_op_res_76941 = x_76939 + x_76940;
                
                defunc_2_reduce_res_76356 = defunc_1_op_res_76941;
            }
            // load acc params
            {
                x_76942 = defunc_2_reduce_res_76357;
            }
            // load next params
            {
                x_76943 =
                    ((double *) reduce_stage_1_tid_res_arr_mem_76934)[flat_tid_76855];
            }
            // red body
            {
                double defunc_1_op_res_76944 = x_76942 + x_76943;
                
                defunc_2_reduce_res_76357 = defunc_1_op_res_76944;
            }
        }
    }
    
  cleanup:
    {
        free(reduce_stage_1_tid_res_arr_mem_76932);
        free(reduce_stage_1_tid_res_arr_mem_76934);
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segred_task_77431_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segred_task_77431_end -
                 futhark_mc_segred_task_77431_start;
        
        ctx->futhark_mc_segred_task_77431_runs[tid]++;
        ctx->futhark_mc_segred_task_77431_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segred_task_77431_iter[tid] += iterations;
    }
    if (err == 0) {
        *futhark_mc_task_77430->retval_defunc_2_reduce_res_76356 =
            defunc_2_reduce_res_76356;
        *futhark_mc_task_77430->retval_defunc_2_reduce_res_76357 =
            defunc_2_reduce_res_76357;
    }
    return err;
}
static int futhark_mc_segmap_parloop_77412(void *args, int64_t start,
                                           int64_t end, int flat_tid_76189,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77411
    *futhark_mc_segmap_parloop_struct_77411 =
    (struct futhark_mc_segmap_parloop_struct_77411 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77411->ctx;
    uint64_t futhark_mc_segmap_parloop_77412_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77412_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77411->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77411->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77411->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77411->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77411->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77411->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77411->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77411->free_loop_cond_65403;
    int64_t last_res_69657 =
            futhark_mc_segmap_parloop_struct_77411->free_last_res_69657;
    int64_t min_arg_69676 =
            futhark_mc_segmap_parloop_struct_77411->free_min_arg_69676;
    int64_t min_arg_69677 =
            futhark_mc_segmap_parloop_struct_77411->free_min_arg_69677;
    int64_t min_res_69678 =
            futhark_mc_segmap_parloop_struct_77411->free_min_res_69678;
    double max_res_69682 =
           futhark_mc_segmap_parloop_struct_77411->free_max_res_69682;
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_segmap_parloop_struct_77411->free_mem_71346,
                                 .size =0, .references =NULL};
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_segmap_parloop_struct_77411->free_mem_71349,
                                 .size =0, .references =NULL};
    struct memblock mem_71352 = {.desc ="mem_71352", .mem =
                                 futhark_mc_segmap_parloop_struct_77411->free_mem_71352,
                                 .size =0, .references =NULL};
    int64_t bytes_71354 =
            futhark_mc_segmap_parloop_struct_77411->free_bytes_71354;
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_segmap_parloop_struct_77411->free_mem_71355,
                                 .size =0, .references =NULL};
    struct memblock mem_71430 = {.desc ="mem_71430", .mem =
                                 futhark_mc_segmap_parloop_struct_77411->free_mem_71430,
                                 .size =0, .references =NULL};
    struct memblock mem_71433 = {.desc ="mem_71433", .mem =
                                 futhark_mc_segmap_parloop_struct_77411->free_mem_71433,
                                 .size =0, .references =NULL};
    size_t mem_76277_cached_sizze_77413 = 0;
    unsigned char *mem_76277 = NULL;
    size_t mem_76278_cached_sizze_77414 = 0;
    unsigned char *mem_76278 = NULL;
    size_t mem_76299_cached_sizze_77415 = 0;
    unsigned char *mem_76299 = NULL;
    size_t mem_76300_cached_sizze_77416 = 0;
    unsigned char *mem_76300 = NULL;
    int64_t iterations = end - start;
    int64_t iter_76758 = start;
    
    if (mem_76277_cached_sizze_77413 < (size_t) bytes_71354) {
        mem_76277 = realloc(mem_76277, bytes_71354);
        mem_76277_cached_sizze_77413 = bytes_71354;
    }
    if (mem_76278_cached_sizze_77414 < (size_t) bytes_71354) {
        mem_76278 = realloc(mem_76278, bytes_71354);
        mem_76278_cached_sizze_77414 = bytes_71354;
    }
    if (mem_76299_cached_sizze_77415 < (size_t) bytes_71354) {
        mem_76299 = realloc(mem_76299, bytes_71354);
        mem_76299_cached_sizze_77415 = bytes_71354;
    }
    if (mem_76300_cached_sizze_77416 < (size_t) bytes_71354) {
        mem_76300 = realloc(mem_76300, bytes_71354);
        mem_76300_cached_sizze_77416 = bytes_71354;
    }
    for (; iter_76758 < end; iter_76758++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76882 = n_m_65386;
        int64_t gtid_76190 = iter_76758;
        int64_t remnant_76883 = iter_76758 - gtid_76190;
        int64_t min_arg_76191 = mul64(jump_65382, gtid_76190);
        int64_t min_res_76192 = smin64(i_65392, min_arg_76191);
        int64_t defunc_0_g_res_76193 = add64((int64_t) 1, min_res_76192);
        bool init_idx_76194;
        int64_t init_idx_76195;
        int64_t init_idx_76196;
        bool loop_while_76759;
        int64_t low_76760;
        int64_t high_76761;
        
        loop_while_76759 = x_65393;
        low_76760 = (int64_t) 0;
        high_76761 = i_65392;
        while (loop_while_76759) {
            int64_t x_76762 = add64(low_76760, high_76761);
            int64_t mid_76763 = sdiv64(x_76762, (int64_t) 2);
            bool x_76764 = sle64((int64_t) 0, mid_76763);
            bool y_76765 = slt64(mid_76763, n_65378);
            bool bounds_check_76766 = x_76764 && y_76765;
            bool index_certs_76767;
            
            if (!bounds_check_76766) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) mid_76763,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:450:26-36\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t mid_id_76768;
            
            mid_id_76768 = ((int64_t *) mem_71352.mem)[mid_76763];
            
            bool cond_76769 = slt64(mid_id_76768, (int64_t) 0);
            int64_t mid_idx_76770;
            
            if (cond_76769) {
                mid_idx_76770 = (int64_t) 9223372036854775807;
            } else {
                mid_idx_76770 = mid_id_76768;
            }
            
            bool cond_76771 = sle64(defunc_0_g_res_76193, mid_idx_76770);
            int64_t loopres_76772;
            int64_t loopres_76773;
            
            if (cond_76771) {
                int64_t loopres_t_res_76774 = sub64(mid_76763, (int64_t) 1);
                
                loopres_76772 = low_76760;
                loopres_76773 = loopres_t_res_76774;
            } else {
                int64_t loopres_f_res_76775 = add64((int64_t) 1, mid_76763);
                
                loopres_76772 = loopres_f_res_76775;
                loopres_76773 = high_76761;
            }
            
            bool loop_cond_76776 = sle64(loopres_76772, loopres_76773);
            bool loop_while_tmp_76884 = loop_cond_76776;
            int64_t low_tmp_76885 = loopres_76772;
            int64_t high_tmp_76886 = loopres_76773;
            
            loop_while_76759 = loop_while_tmp_76884;
            low_76760 = low_tmp_76885;
            high_76761 = high_tmp_76886;
        }
        init_idx_76194 = loop_while_76759;
        init_idx_76195 = low_76760;
        init_idx_76196 = high_76761;
        
        bool idx_76215;
        int64_t idx_76216;
        int64_t idx_76217;
        int64_t idx_76218;
        bool loop_while_76777;
        int64_t l_idx_76778;
        int64_t r_idx_76779;
        int64_t span_76780;
        
        loop_while_76777 = loop_cond_65403;
        l_idx_76778 = init_idx_76195;
        r_idx_76779 = init_idx_76195;
        span_76780 = (int64_t) 1;
        while (loop_while_76777) {
            int64_t max_arg_76781 = sub64(l_idx_76778, (int64_t) 1);
            int64_t max_res_76782 = smax64((int64_t) 0, max_arg_76781);
            int64_t min_arg_76783 = add64((int64_t) 1, r_idx_76779);
            int64_t min_res_76784 = smin64(min_arg_69676, min_arg_76783);
            bool x_76785 = sle64((int64_t) 0, max_res_76782);
            bool y_76786 = slt64(max_res_76782, n_65378);
            bool bounds_check_76787 = x_76785 && y_76786;
            bool index_certs_76788;
            
            if (!bounds_check_76787) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) max_res_76782,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:460:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_76789;
            
            x_76789 = ((int64_t *) mem_71352.mem)[max_res_76782];
            
            int64_t abs_arg_76790 = sub64(x_76789, defunc_0_g_res_76193);
            int64_t abs_res_76791 = abs64(abs_arg_76790);
            bool x_76792 = sle64((int64_t) 0, min_res_76784);
            bool y_76793 = slt64(min_res_76784, n_65378);
            bool bounds_check_76794 = x_76792 && y_76793;
            bool index_certs_76795;
            
            if (!bounds_check_76794) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) min_res_76784,
                              "] out of bounds for array of shape [",
                              (long long) n_65378, "].",
                              "-> #0  loess.fut:461:35-48\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:443:3-470:10\n   #5  loess.fut:503:15-61\n   #6  loess.fut:590:13-56\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:589:5-591:26\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            int64_t x_76796;
            
            x_76796 = ((int64_t *) mem_71352.mem)[min_res_76784];
            
            int64_t abs_arg_76797 = sub64(x_76796, defunc_0_g_res_76193);
            int64_t abs_res_76798 = abs64(abs_arg_76797);
            bool cond_76799 = max_res_76782 == l_idx_76778;
            int64_t loopres_76800;
            int64_t loopres_76801;
            int64_t loopres_76802;
            
            if (cond_76799) {
                loopres_76800 = l_idx_76778;
                loopres_76801 = r_idx_76779;
                loopres_76802 = min_res_65398;
            } else {
                bool cond_76803 = slt64(abs_res_76791, abs_res_76798);
                bool cond_f_res_76804 = min_res_76784 == r_idx_76779;
                bool x_76805 = !cond_76803;
                bool y_76806 = cond_f_res_76804 && x_76805;
                bool cond_76807 = cond_76803 || y_76806;
                int64_t loopres_f_res_76808;
                
                if (cond_76807) {
                    loopres_f_res_76808 = max_res_76782;
                } else {
                    loopres_f_res_76808 = l_idx_76778;
                }
                
                int64_t loopres_f_res_76809;
                
                if (cond_76807) {
                    loopres_f_res_76809 = r_idx_76779;
                } else {
                    loopres_f_res_76809 = min_res_76784;
                }
                
                int64_t loopres_f_res_76810;
                
                if (cond_76807) {
                    int64_t loopres_f_res_t_res_76811 = add64((int64_t) 1,
                                                              span_76780);
                    
                    loopres_f_res_76810 = loopres_f_res_t_res_76811;
                } else {
                    int64_t loopres_f_res_f_res_76812 = add64((int64_t) 1,
                                                              span_76780);
                    
                    loopres_f_res_76810 = loopres_f_res_f_res_76812;
                }
                loopres_76800 = loopres_f_res_76808;
                loopres_76801 = loopres_f_res_76809;
                loopres_76802 = loopres_f_res_76810;
            }
            
            bool loop_cond_76813 = slt64(loopres_76802, min_res_65398);
            bool loop_while_tmp_76887 = loop_cond_76813;
            int64_t l_idx_tmp_76888 = loopres_76800;
            int64_t r_idx_tmp_76889 = loopres_76801;
            int64_t span_tmp_76890 = loopres_76802;
            
            loop_while_76777 = loop_while_tmp_76887;
            l_idx_76778 = l_idx_tmp_76888;
            r_idx_76779 = r_idx_tmp_76889;
            span_76780 = span_tmp_76890;
        }
        idx_76215 = loop_while_76777;
        idx_76216 = l_idx_76778;
        idx_76217 = r_idx_76779;
        idx_76218 = span_76780;
        
        int64_t min_res_76256 = smin64(min_arg_69677, idx_76216);
        int64_t max_res_76257 = smax64((int64_t) 0, min_res_76256);
        int64_t x_76258 = add64(min_res_69678, max_res_76257);
        int64_t r_76259 = sub64(x_76258, (int64_t) 1);
        bool x_76260 = sle64((int64_t) 0, r_76259);
        bool y_76261 = slt64(r_76259, n_65378);
        bool bounds_check_76262 = x_76260 && y_76261;
        bool index_certs_76263;
        
        if (!bounds_check_76262) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) r_76259,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:485:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_76264;
        
        x_76264 = ((int64_t *) mem_71349.mem)[r_76259];
        
        int64_t abs_arg_76265 = sub64(x_76264, min_res_76192);
        int64_t abs_res_76266 = abs64(abs_arg_76265);
        bool x_76267 = sle64((int64_t) 0, max_res_76257);
        bool y_76268 = slt64(max_res_76257, n_65378);
        bool bounds_check_76269 = x_76267 && y_76268;
        bool index_certs_76270;
        
        if (!bounds_check_76269) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) max_res_76257,
                                   "] out of bounds for array of shape [",
                                   (long long) n_65378, "].",
                                   "-> #0  loess.fut:484:40-47\n   #1  /prelude/soacs.fut:67:19-23\n   #2  /prelude/soacs.fut:67:3-37\n   #3  loess.fut:480:3-488:25\n   #4  loess.fut:504:16-51\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        int64_t x_76271;
        
        x_76271 = ((int64_t *) mem_71349.mem)[max_res_76257];
        
        int64_t abs_arg_76272 = sub64(x_76271, min_res_76192);
        int64_t abs_res_76273 = abs64(abs_arg_76272);
        int64_t max_res_76274 = smax64(abs_res_76266, abs_res_76273);
        double defunc_0_f_res_76275 = sitofp_i64_f64(max_res_76274);
        double defunc_1_f_res_76276 = max_res_69682 + defunc_0_f_res_76275;
        int64_t flat_tid_76814 = (int64_t) 0;
        int32_t num_tasks_76891;
        struct futhark_mc_task_77417 futhark_mc_task_77417;
        
        futhark_mc_task_77417.ctx = ctx;
        futhark_mc_task_77417.free_q_65380 = q_65380;
        futhark_mc_task_77417.free_last_res_69657 = last_res_69657;
        futhark_mc_task_77417.free_mem_71349 = mem_71349.mem;
        futhark_mc_task_77417.free_mem_71355 = mem_71355.mem;
        futhark_mc_task_77417.free_min_res_76192 = min_res_76192;
        futhark_mc_task_77417.free_max_res_76257 = max_res_76257;
        futhark_mc_task_77417.free_defunc_1_f_res_76276 = defunc_1_f_res_76276;
        futhark_mc_task_77417.free_mem_76277 = mem_76277;
        futhark_mc_task_77417.free_mem_76278 = mem_76278;
        
        struct scheduler_segop futhark_mc_task_77417_task;
        
        futhark_mc_task_77417_task.args = &futhark_mc_task_77417;
        futhark_mc_task_77417_task.top_level_fn = futhark_mc_segmap_task_77418;
        futhark_mc_task_77417_task.name = "futhark_mc_segmap_task_77418";
        futhark_mc_task_77417_task.iterations = q_65380;
        futhark_mc_task_77417_task.task_time =
            &ctx->futhark_mc_segmap_task_77418_total_time;
        futhark_mc_task_77417_task.task_iter =
            &ctx->futhark_mc_segmap_task_77418_total_iter;
        futhark_mc_task_77417_task.sched = STATIC;
        futhark_mc_task_77417_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77418_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77417_task);
        
        if (futhark_mc_segmap_task_77418_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double defunc_2_reduce_res_76301;
        double defunc_2_reduce_res_76302;
        double defunc_2_reduce_res_76303;
        double defunc_2_reduce_res_76304;
        double defunc_2_reduce_res_76305;
        int64_t flat_tid_76832 = (int64_t) 0;
        int32_t num_tasks_76898;
        
        defunc_2_reduce_res_76301 = 0.0;
        defunc_2_reduce_res_76302 = 0.0;
        defunc_2_reduce_res_76303 = 0.0;
        defunc_2_reduce_res_76304 = 0.0;
        defunc_2_reduce_res_76305 = 0.0;
        
        struct futhark_mc_task_77421 futhark_mc_task_77421;
        
        futhark_mc_task_77421.ctx = ctx;
        futhark_mc_task_77421.free_mem_76277 = mem_76277;
        futhark_mc_task_77421.free_mem_76278 = mem_76278;
        futhark_mc_task_77421.retval_defunc_2_reduce_res_76301 =
            &defunc_2_reduce_res_76301;
        futhark_mc_task_77421.retval_defunc_2_reduce_res_76302 =
            &defunc_2_reduce_res_76302;
        futhark_mc_task_77421.retval_defunc_2_reduce_res_76303 =
            &defunc_2_reduce_res_76303;
        futhark_mc_task_77421.retval_defunc_2_reduce_res_76304 =
            &defunc_2_reduce_res_76304;
        futhark_mc_task_77421.retval_defunc_2_reduce_res_76305 =
            &defunc_2_reduce_res_76305;
        futhark_mc_task_77421.retval_mem_76299 = mem_76299;
        futhark_mc_task_77421.retval_mem_76300 = mem_76300;
        
        struct scheduler_segop futhark_mc_task_77421_task;
        
        futhark_mc_task_77421_task.args = &futhark_mc_task_77421;
        futhark_mc_task_77421_task.top_level_fn = futhark_mc_segred_task_77422;
        futhark_mc_task_77421_task.name = "futhark_mc_segred_task_77422";
        futhark_mc_task_77421_task.iterations = q_65380;
        futhark_mc_task_77421_task.task_time =
            &ctx->futhark_mc_segred_task_77422_total_time;
        futhark_mc_task_77421_task.task_iter =
            &ctx->futhark_mc_segred_task_77422_total_iter;
        futhark_mc_task_77421_task.sched = STATIC;
        futhark_mc_task_77421_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77422_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77421_task);
        
        if (futhark_mc_segred_task_77422_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        double x_76331 = defunc_2_reduce_res_76303 * defunc_2_reduce_res_76305;
        double y_76332 = defunc_2_reduce_res_76304 * defunc_2_reduce_res_76304;
        double a12_76333 = x_76331 - y_76332;
        double x_76334 = defunc_2_reduce_res_76303 * defunc_2_reduce_res_76304;
        double y_76335 = defunc_2_reduce_res_76302 * defunc_2_reduce_res_76305;
        double b12_76336 = x_76334 - y_76335;
        double x_76337 = defunc_2_reduce_res_76302 * defunc_2_reduce_res_76304;
        double y_76338 = defunc_2_reduce_res_76303 * defunc_2_reduce_res_76303;
        double c12_76339 = x_76337 - y_76338;
        double x_76340 = defunc_2_reduce_res_76301 * defunc_2_reduce_res_76305;
        double b2_76341 = x_76340 - y_76338;
        double x_76342 = defunc_2_reduce_res_76302 * defunc_2_reduce_res_76303;
        double y_76343 = defunc_2_reduce_res_76301 * defunc_2_reduce_res_76304;
        double c2_76344 = x_76342 - y_76343;
        double x_76345 = defunc_2_reduce_res_76301 * a12_76333;
        double y_76346 = defunc_2_reduce_res_76302 * b12_76336;
        double x_76347 = x_76345 + y_76346;
        double y_76348 = defunc_2_reduce_res_76303 * c12_76339;
        double y_76349 = x_76347 + y_76348;
        double det_76350 = 1.0 / y_76349;
        double a12_76351 = a12_76333 * det_76350;
        double b12_76352 = b12_76336 * det_76350;
        double c12_76353 = c12_76339 * det_76350;
        double b2_76354 = b2_76341 * det_76350;
        double c2_76355 = c2_76344 * det_76350;
        double defunc_2_reduce_res_76356;
        double defunc_2_reduce_res_76357;
        int64_t flat_tid_76855 = (int64_t) 0;
        int32_t num_tasks_76931;
        
        defunc_2_reduce_res_76356 = 0.0;
        defunc_2_reduce_res_76357 = 0.0;
        
        struct futhark_mc_task_77430 futhark_mc_task_77430;
        
        futhark_mc_task_77430.ctx = ctx;
        futhark_mc_task_77430.free_last_res_69657 = last_res_69657;
        futhark_mc_task_77430.free_mem_71346 = mem_71346.mem;
        futhark_mc_task_77430.free_max_res_76257 = max_res_76257;
        futhark_mc_task_77430.free_mem_76278 = mem_76278;
        futhark_mc_task_77430.free_mem_76299 = mem_76299;
        futhark_mc_task_77430.free_mem_76300 = mem_76300;
        futhark_mc_task_77430.free_a12_76351 = a12_76351;
        futhark_mc_task_77430.free_b12_76352 = b12_76352;
        futhark_mc_task_77430.free_c12_76353 = c12_76353;
        futhark_mc_task_77430.free_b2_76354 = b2_76354;
        futhark_mc_task_77430.free_c2_76355 = c2_76355;
        futhark_mc_task_77430.retval_defunc_2_reduce_res_76356 =
            &defunc_2_reduce_res_76356;
        futhark_mc_task_77430.retval_defunc_2_reduce_res_76357 =
            &defunc_2_reduce_res_76357;
        
        struct scheduler_segop futhark_mc_task_77430_task;
        
        futhark_mc_task_77430_task.args = &futhark_mc_task_77430;
        futhark_mc_task_77430_task.top_level_fn = futhark_mc_segred_task_77431;
        futhark_mc_task_77430_task.name = "futhark_mc_segred_task_77431";
        futhark_mc_task_77430_task.iterations = q_65380;
        futhark_mc_task_77430_task.task_time =
            &ctx->futhark_mc_segred_task_77431_total_time;
        futhark_mc_task_77430_task.task_iter =
            &ctx->futhark_mc_segred_task_77431_total_iter;
        futhark_mc_task_77430_task.sched = STATIC;
        futhark_mc_task_77430_task.nested_fn = NULL;
        
        int futhark_mc_segred_task_77431_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77430_task);
        
        if (futhark_mc_segred_task_77431_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        ((double *) mem_71430.mem)[gtid_76190] = defunc_2_reduce_res_76356;
        ((double *) mem_71433.mem)[gtid_76190] = defunc_2_reduce_res_76357;
    }
    
  cleanup:
    { }
    free(mem_76277);
    free(mem_76278);
    free(mem_76299);
    free(mem_76300);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77412_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77412_end -
                 futhark_mc_segmap_parloop_77412_start;
        
        ctx->futhark_mc_segmap_parloop_77412_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77412_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77412_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77410(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_76189 = tid;
    int num_tasks_76615 = info.nsubtasks;
    struct futhark_mc_task_77402 *futhark_mc_task_77402 =
                                 (struct futhark_mc_task_77402 *) args;
    struct futhark_context *ctx = futhark_mc_task_77402->ctx;
    uint64_t futhark_mc_segmap_nested_task_77410_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77410_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77402->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77402->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77402->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77402->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77402->free_i_65392;
    bool x_65393 = futhark_mc_task_77402->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77402->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77402->free_loop_cond_65403;
    int64_t last_res_69657 = futhark_mc_task_77402->free_last_res_69657;
    int64_t min_arg_69676 = futhark_mc_task_77402->free_min_arg_69676;
    int64_t min_arg_69677 = futhark_mc_task_77402->free_min_arg_69677;
    int64_t min_res_69678 = futhark_mc_task_77402->free_min_res_69678;
    double max_res_69682 = futhark_mc_task_77402->free_max_res_69682;
    struct memblock mem_71346 = {.desc ="mem_71346", .mem =
                                 futhark_mc_task_77402->free_mem_71346, .size =
                                 0, .references =NULL};
    struct memblock mem_71349 = {.desc ="mem_71349", .mem =
                                 futhark_mc_task_77402->free_mem_71349, .size =
                                 0, .references =NULL};
    struct memblock mem_71352 = {.desc ="mem_71352", .mem =
                                 futhark_mc_task_77402->free_mem_71352, .size =
                                 0, .references =NULL};
    int64_t bytes_71354 = futhark_mc_task_77402->free_bytes_71354;
    struct memblock mem_71355 = {.desc ="mem_71355", .mem =
                                 futhark_mc_task_77402->free_mem_71355, .size =
                                 0, .references =NULL};
    struct memblock mem_71430 = {.desc ="mem_71430", .mem =
                                 futhark_mc_task_77402->free_mem_71430, .size =
                                 0, .references =NULL};
    struct memblock mem_71433 = {.desc ="mem_71433", .mem =
                                 futhark_mc_task_77402->free_mem_71433, .size =
                                 0, .references =NULL};
    int64_t iter_76758;
    struct futhark_mc_segmap_parloop_struct_77411
    futhark_mc_segmap_parloop_struct_77411;
    
    futhark_mc_segmap_parloop_struct_77411.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77411.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77411.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77411.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77411.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77411.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77411.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77411.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77411.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77411.free_last_res_69657 = last_res_69657;
    futhark_mc_segmap_parloop_struct_77411.free_min_arg_69676 = min_arg_69676;
    futhark_mc_segmap_parloop_struct_77411.free_min_arg_69677 = min_arg_69677;
    futhark_mc_segmap_parloop_struct_77411.free_min_res_69678 = min_res_69678;
    futhark_mc_segmap_parloop_struct_77411.free_max_res_69682 = max_res_69682;
    futhark_mc_segmap_parloop_struct_77411.free_mem_71346 = mem_71346.mem;
    futhark_mc_segmap_parloop_struct_77411.free_mem_71349 = mem_71349.mem;
    futhark_mc_segmap_parloop_struct_77411.free_mem_71352 = mem_71352.mem;
    futhark_mc_segmap_parloop_struct_77411.free_bytes_71354 = bytes_71354;
    futhark_mc_segmap_parloop_struct_77411.free_mem_71355 = mem_71355.mem;
    futhark_mc_segmap_parloop_struct_77411.free_mem_71430 = mem_71430.mem;
    futhark_mc_segmap_parloop_struct_77411.free_mem_71433 = mem_71433.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77412_task;
    
    futhark_mc_segmap_parloop_77412_task.name =
        "futhark_mc_segmap_parloop_77412";
    futhark_mc_segmap_parloop_77412_task.fn = futhark_mc_segmap_parloop_77412;
    futhark_mc_segmap_parloop_77412_task.args =
        &futhark_mc_segmap_parloop_struct_77411;
    futhark_mc_segmap_parloop_77412_task.iterations = iterations;
    futhark_mc_segmap_parloop_77412_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77412_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77412_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77412_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77412_task);
    
    if (futhark_mc_segmap_parloop_77412_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77412_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77412_total_end -
                 futhark_mc_segmap_parloop_77412_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77412_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77412_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77412_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77410_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77410_end -
                 futhark_mc_segmap_nested_task_77410_start;
        
        ctx->futhark_mc_segmap_nested_task_77410_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77410_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77410_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77375(void *args, int64_t start,
                                           int64_t end, int flat_tid_69644,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77374
    *futhark_mc_segmap_parloop_struct_77374 =
    (struct futhark_mc_segmap_parloop_struct_77374 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77374->ctx;
    uint64_t futhark_mc_segmap_parloop_77375_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77375_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77374->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77374->free_n_65378;
    int64_t q_65380 = futhark_mc_segmap_parloop_struct_77374->free_q_65380;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77374->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77374->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77374->free_i_65392;
    bool x_65393 = futhark_mc_segmap_parloop_struct_77374->free_x_65393;
    int64_t min_res_65398 =
            futhark_mc_segmap_parloop_struct_77374->free_min_res_65398;
    bool loop_cond_65403 =
         futhark_mc_segmap_parloop_struct_77374->free_loop_cond_65403;
    double i64_res_65404 =
           futhark_mc_segmap_parloop_struct_77374->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_segmap_parloop_struct_77374->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71342 =
            futhark_mc_segmap_parloop_struct_77374->free_bytes_71342;
    int64_t bytes_71354 =
            futhark_mc_segmap_parloop_struct_77374->free_bytes_71354;
    int64_t bytes_71429 =
            futhark_mc_segmap_parloop_struct_77374->free_bytes_71429;
    struct memblock mem_71602 = {.desc ="mem_71602", .mem =
                                 futhark_mc_segmap_parloop_struct_77374->free_mem_71602,
                                 .size =0, .references =NULL};
    struct memblock mem_71606 = {.desc ="mem_71606", .mem =
                                 futhark_mc_segmap_parloop_struct_77374->free_mem_71606,
                                 .size =0, .references =NULL};
    size_t mem_71343_cached_sizze_77376 = 0;
    unsigned char *mem_71343 = NULL;
    size_t mem_71346_cached_sizze_77377 = 0;
    unsigned char *mem_71346 = NULL;
    size_t mem_71349_cached_sizze_77378 = 0;
    unsigned char *mem_71349 = NULL;
    size_t mem_71352_cached_sizze_77379 = 0;
    unsigned char *mem_71352 = NULL;
    size_t mem_71355_cached_sizze_77380 = 0;
    unsigned char *mem_71355 = NULL;
    size_t mem_71430_cached_sizze_77381 = 0;
    unsigned char *mem_71430 = NULL;
    size_t mem_71433_cached_sizze_77382 = 0;
    unsigned char *mem_71433 = NULL;
    int64_t iterations = end - start;
    int64_t iter_76163 = start;
    
    if (mem_71343_cached_sizze_77376 < (size_t) bytes_71342) {
        mem_71343 = realloc(mem_71343, bytes_71342);
        mem_71343_cached_sizze_77376 = bytes_71342;
    }
    if (mem_71346_cached_sizze_77377 < (size_t) bytes_71342) {
        mem_71346 = realloc(mem_71346, bytes_71342);
        mem_71346_cached_sizze_77377 = bytes_71342;
    }
    if (mem_71349_cached_sizze_77378 < (size_t) bytes_71342) {
        mem_71349 = realloc(mem_71349, bytes_71342);
        mem_71349_cached_sizze_77378 = bytes_71342;
    }
    if (mem_71352_cached_sizze_77379 < (size_t) bytes_71342) {
        mem_71352 = realloc(mem_71352, bytes_71342);
        mem_71352_cached_sizze_77379 = bytes_71342;
    }
    if (mem_71355_cached_sizze_77380 < (size_t) bytes_71354) {
        mem_71355 = realloc(mem_71355, bytes_71354);
        mem_71355_cached_sizze_77380 = bytes_71354;
    }
    if (mem_71430_cached_sizze_77381 < (size_t) bytes_71429) {
        mem_71430 = realloc(mem_71430, bytes_71429);
        mem_71430_cached_sizze_77381 = bytes_71429;
    }
    if (mem_71433_cached_sizze_77382 < (size_t) bytes_71429) {
        mem_71433 = realloc(mem_71433, bytes_71429);
        mem_71433_cached_sizze_77382 = bytes_71429;
    }
    for (; iter_76163 < end; iter_76163++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76583 = m_65377;
        int64_t gtid_69645 = iter_76163;
        int64_t remnant_76584 = iter_76163 - gtid_69645;
        int64_t flat_tid_76164 = (int64_t) 0;
        int32_t num_tasks_76585;
        
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "nonsegmented segScan");
        
        struct futhark_mc_task_77383 futhark_mc_task_77383;
        
        futhark_mc_task_77383.ctx = ctx;
        futhark_mc_task_77383.free_n_65378 = n_65378;
        futhark_mc_task_77383.free_gtid_69645 = gtid_69645;
        futhark_mc_task_77383.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77383.free_mem_71343 = mem_71343;
        
        struct scheduler_segop futhark_mc_task_77383_task;
        
        futhark_mc_task_77383_task.args = &futhark_mc_task_77383;
        futhark_mc_task_77383_task.top_level_fn = futhark_mc_segscan_task_77384;
        futhark_mc_task_77383_task.name = "futhark_mc_segscan_task_77384";
        futhark_mc_task_77383_task.iterations = n_65378;
        futhark_mc_task_77383_task.task_time =
            &ctx->futhark_mc_segscan_task_77384_total_time;
        futhark_mc_task_77383_task.task_iter =
            &ctx->futhark_mc_segscan_task_77384_total_iter;
        futhark_mc_task_77383_task.sched = STATIC;
        futhark_mc_task_77383_task.nested_fn = NULL;
        
        int futhark_mc_segscan_task_77384_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77383_task);
        
        if (futhark_mc_segscan_task_77384_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t last_res_69657;
        
        last_res_69657 = ((int64_t *) mem_71343)[i_65392];
        for (int64_t i_76599 = 0; i_76599 < n_65378; i_76599++) {
            ((double *) mem_71346)[i_76599] = 0.0;
        }
        for (int64_t i_76600 = 0; i_76600 < n_65378; i_76600++) {
            ((int64_t *) mem_71349)[i_76600] = (int64_t) -1;
        }
        
        int64_t flat_tid_76173 = (int64_t) 0;
        int32_t num_tasks_76601;
        struct futhark_mc_task_77390 futhark_mc_task_77390;
        
        futhark_mc_task_77390.ctx = ctx;
        futhark_mc_task_77390.free_n_65378 = n_65378;
        futhark_mc_task_77390.free_gtid_69645 = gtid_69645;
        futhark_mc_task_77390.free_Y_mem_70603 = Y_mem_70603.mem;
        futhark_mc_task_77390.free_mem_71343 = mem_71343;
        futhark_mc_task_77390.free_mem_71346 = mem_71346;
        futhark_mc_task_77390.free_mem_71349 = mem_71349;
        
        struct scheduler_segop futhark_mc_task_77390_task;
        
        futhark_mc_task_77390_task.args = &futhark_mc_task_77390;
        futhark_mc_task_77390_task.top_level_fn = futhark_mc_segmap_task_77391;
        futhark_mc_task_77390_task.name = "futhark_mc_segmap_task_77391";
        futhark_mc_task_77390_task.iterations = n_65378;
        futhark_mc_task_77390_task.task_time =
            &ctx->futhark_mc_segmap_task_77391_total_time;
        futhark_mc_task_77390_task.task_iter =
            &ctx->futhark_mc_segmap_task_77391_total_iter;
        futhark_mc_task_77390_task.sched = STATIC;
        futhark_mc_task_77390_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77391_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77390_task);
        
        if (futhark_mc_segmap_task_77391_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_76181 = (int64_t) 0;
        int32_t num_tasks_76607;
        struct futhark_mc_task_77394 futhark_mc_task_77394;
        
        futhark_mc_task_77394.ctx = ctx;
        futhark_mc_task_77394.free_n_65378 = n_65378;
        futhark_mc_task_77394.free_mem_71349 = mem_71349;
        futhark_mc_task_77394.free_mem_71352 = mem_71352;
        
        struct scheduler_segop futhark_mc_task_77394_task;
        
        futhark_mc_task_77394_task.args = &futhark_mc_task_77394;
        futhark_mc_task_77394_task.top_level_fn = futhark_mc_segmap_task_77395;
        futhark_mc_task_77394_task.name = "futhark_mc_segmap_task_77395";
        futhark_mc_task_77394_task.iterations = n_65378;
        futhark_mc_task_77394_task.task_time =
            &ctx->futhark_mc_segmap_task_77395_total_time;
        futhark_mc_task_77394_task.task_iter =
            &ctx->futhark_mc_segmap_task_77395_total_iter;
        futhark_mc_task_77394_task.sched = STATIC;
        futhark_mc_task_77394_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77395_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77394_task);
        
        if (futhark_mc_segmap_task_77395_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t min_arg_69676 = sub64(last_res_69657, (int64_t) 1);
        int64_t min_arg_69677 = sub64(last_res_69657, min_res_65398);
        int64_t min_res_69678 = smin64(q_65380, last_res_69657);
        double i64_res_69679 = sitofp_i64_f64(last_res_69657);
        double x_69680 = i64_res_65404 - i64_res_69679;
        double max_arg_69681 = x_69680 / 2.0;
        double max_res_69682 = fmax64(0.0, max_arg_69681);
        int64_t flat_tid_76185 = (int64_t) 0;
        int32_t num_tasks_76611;
        struct futhark_mc_task_77398 futhark_mc_task_77398;
        
        futhark_mc_task_77398.ctx = ctx;
        futhark_mc_task_77398.free_q_65380 = q_65380;
        futhark_mc_task_77398.free_last_res_69657 = last_res_69657;
        futhark_mc_task_77398.free_mem_71355 = mem_71355;
        
        struct scheduler_segop futhark_mc_task_77398_task;
        
        futhark_mc_task_77398_task.args = &futhark_mc_task_77398;
        futhark_mc_task_77398_task.top_level_fn = futhark_mc_segmap_task_77399;
        futhark_mc_task_77398_task.name = "futhark_mc_segmap_task_77399";
        futhark_mc_task_77398_task.iterations = q_65380;
        futhark_mc_task_77398_task.task_time =
            &ctx->futhark_mc_segmap_task_77399_total_time;
        futhark_mc_task_77398_task.task_iter =
            &ctx->futhark_mc_segmap_task_77399_total_iter;
        futhark_mc_task_77398_task.sched = STATIC;
        futhark_mc_task_77398_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77399_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77398_task);
        
        if (futhark_mc_segmap_task_77399_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        
        int64_t flat_tid_76385 = (int64_t) 0;
        int32_t num_tasks_76615;
        int64_t flat_tid_76189 = (int64_t) 0;
        struct futhark_mc_task_77402 futhark_mc_task_77402;
        
        futhark_mc_task_77402.ctx = ctx;
        futhark_mc_task_77402.free_n_65378 = n_65378;
        futhark_mc_task_77402.free_q_65380 = q_65380;
        futhark_mc_task_77402.free_jump_65382 = jump_65382;
        futhark_mc_task_77402.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77402.free_i_65392 = i_65392;
        futhark_mc_task_77402.free_x_65393 = x_65393;
        futhark_mc_task_77402.free_min_res_65398 = min_res_65398;
        futhark_mc_task_77402.free_loop_cond_65403 = loop_cond_65403;
        futhark_mc_task_77402.free_last_res_69657 = last_res_69657;
        futhark_mc_task_77402.free_min_arg_69676 = min_arg_69676;
        futhark_mc_task_77402.free_min_arg_69677 = min_arg_69677;
        futhark_mc_task_77402.free_min_res_69678 = min_res_69678;
        futhark_mc_task_77402.free_max_res_69682 = max_res_69682;
        futhark_mc_task_77402.free_mem_71346 = mem_71346;
        futhark_mc_task_77402.free_mem_71349 = mem_71349;
        futhark_mc_task_77402.free_mem_71352 = mem_71352;
        futhark_mc_task_77402.free_bytes_71354 = bytes_71354;
        futhark_mc_task_77402.free_mem_71355 = mem_71355;
        futhark_mc_task_77402.free_mem_71430 = mem_71430;
        futhark_mc_task_77402.free_mem_71433 = mem_71433;
        
        struct scheduler_segop futhark_mc_task_77402_task;
        
        futhark_mc_task_77402_task.args = &futhark_mc_task_77402;
        futhark_mc_task_77402_task.top_level_fn = futhark_mc_segmap_task_77403;
        futhark_mc_task_77402_task.name = "futhark_mc_segmap_task_77403";
        futhark_mc_task_77402_task.iterations = n_m_65386;
        futhark_mc_task_77402_task.task_time =
            &ctx->futhark_mc_segmap_task_77403_total_time;
        futhark_mc_task_77402_task.task_iter =
            &ctx->futhark_mc_segmap_task_77403_total_iter;
        futhark_mc_task_77402_task.sched = DYNAMIC;
        futhark_mc_task_77402_task.nested_fn =
            futhark_mc_segmap_nested_task_77410;
        
        int futhark_mc_segmap_task_77403_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77402_task);
        
        if (futhark_mc_segmap_task_77403_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71602.mem + gtid_69645 * n_m_65386 * (int64_t) 8,
                    mem_71430 + (int64_t) 0, n_m_65386 * (int64_t) 8);
        if (n_m_65386 * (int64_t) 8 > 0)
            memmove(mem_71606.mem + gtid_69645 * n_m_65386 * (int64_t) 8,
                    mem_71433 + (int64_t) 0, n_m_65386 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71343);
    free(mem_71346);
    free(mem_71349);
    free(mem_71352);
    free(mem_71355);
    free(mem_71430);
    free(mem_71433);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77375_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77375_end -
                 futhark_mc_segmap_parloop_77375_start;
        
        ctx->futhark_mc_segmap_parloop_77375_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77375_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77375_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77373(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_69644 = tid;
    int num_tasks_75903 = info.nsubtasks;
    struct futhark_mc_task_77358 *futhark_mc_task_77358 =
                                 (struct futhark_mc_task_77358 *) args;
    struct futhark_context *ctx = futhark_mc_task_77358->ctx;
    uint64_t futhark_mc_segmap_nested_task_77373_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77373_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77358->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77358->free_n_65378;
    int64_t q_65380 = futhark_mc_task_77358->free_q_65380;
    int64_t jump_65382 = futhark_mc_task_77358->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77358->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77358->free_i_65392;
    bool x_65393 = futhark_mc_task_77358->free_x_65393;
    int64_t min_res_65398 = futhark_mc_task_77358->free_min_res_65398;
    bool loop_cond_65403 = futhark_mc_task_77358->free_loop_cond_65403;
    double i64_res_65404 = futhark_mc_task_77358->free_i64_res_65404;
    struct memblock Y_mem_70603 = {.desc ="Y_mem_70603", .mem =
                                   futhark_mc_task_77358->free_Y_mem_70603,
                                   .size =0, .references =NULL};
    int64_t bytes_71342 = futhark_mc_task_77358->free_bytes_71342;
    int64_t bytes_71354 = futhark_mc_task_77358->free_bytes_71354;
    int64_t bytes_71429 = futhark_mc_task_77358->free_bytes_71429;
    struct memblock mem_71602 = {.desc ="mem_71602", .mem =
                                 futhark_mc_task_77358->free_mem_71602, .size =
                                 0, .references =NULL};
    struct memblock mem_71606 = {.desc ="mem_71606", .mem =
                                 futhark_mc_task_77358->free_mem_71606, .size =
                                 0, .references =NULL};
    int64_t iter_76163;
    struct futhark_mc_segmap_parloop_struct_77374
    futhark_mc_segmap_parloop_struct_77374;
    
    futhark_mc_segmap_parloop_struct_77374.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77374.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77374.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77374.free_q_65380 = q_65380;
    futhark_mc_segmap_parloop_struct_77374.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77374.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77374.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77374.free_x_65393 = x_65393;
    futhark_mc_segmap_parloop_struct_77374.free_min_res_65398 = min_res_65398;
    futhark_mc_segmap_parloop_struct_77374.free_loop_cond_65403 =
        loop_cond_65403;
    futhark_mc_segmap_parloop_struct_77374.free_i64_res_65404 = i64_res_65404;
    futhark_mc_segmap_parloop_struct_77374.free_Y_mem_70603 = Y_mem_70603.mem;
    futhark_mc_segmap_parloop_struct_77374.free_bytes_71342 = bytes_71342;
    futhark_mc_segmap_parloop_struct_77374.free_bytes_71354 = bytes_71354;
    futhark_mc_segmap_parloop_struct_77374.free_bytes_71429 = bytes_71429;
    futhark_mc_segmap_parloop_struct_77374.free_mem_71602 = mem_71602.mem;
    futhark_mc_segmap_parloop_struct_77374.free_mem_71606 = mem_71606.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77375_task;
    
    futhark_mc_segmap_parloop_77375_task.name =
        "futhark_mc_segmap_parloop_77375";
    futhark_mc_segmap_parloop_77375_task.fn = futhark_mc_segmap_parloop_77375;
    futhark_mc_segmap_parloop_77375_task.args =
        &futhark_mc_segmap_parloop_struct_77374;
    futhark_mc_segmap_parloop_77375_task.iterations = iterations;
    futhark_mc_segmap_parloop_77375_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77375_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77375_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77375_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77375_task);
    
    if (futhark_mc_segmap_parloop_77375_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77375_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77375_total_end -
                 futhark_mc_segmap_parloop_77375_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77375_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77375_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77375_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77373_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77373_end -
                 futhark_mc_segmap_nested_task_77373_start;
        
        ctx->futhark_mc_segmap_nested_task_77373_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77373_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77373_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_task_77436 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    int64_t free_y_66671;
    unsigned char *free_ext_mem_71611;
    unsigned char *free_ext_mem_71612;
    int64_t free_bytes_71614;
    unsigned char *free_mem_71634;
};
struct futhark_mc_segmap_parloop_struct_77438 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    int64_t free_y_66671;
    unsigned char *free_ext_mem_71611;
    unsigned char *free_ext_mem_71612;
    int64_t free_bytes_71614;
    unsigned char *free_mem_71634;
};
static int futhark_mc_segmap_parloop_77439(void *args, int64_t start,
                                           int64_t end, int flat_tid_70075,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77438
    *futhark_mc_segmap_parloop_struct_77438 =
    (struct futhark_mc_segmap_parloop_struct_77438 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77438->ctx;
    uint64_t futhark_mc_segmap_parloop_77439_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77439_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77438->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77438->free_n_65378;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77438->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77438->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77438->free_i_65392;
    int64_t y_66671 = futhark_mc_segmap_parloop_struct_77438->free_y_66671;
    struct memblock ext_mem_71611 = {.desc ="ext_mem_71611", .mem =
                                     futhark_mc_segmap_parloop_struct_77438->free_ext_mem_71611,
                                     .size =0, .references =NULL};
    struct memblock ext_mem_71612 = {.desc ="ext_mem_71612", .mem =
                                     futhark_mc_segmap_parloop_struct_77438->free_ext_mem_71612,
                                     .size =0, .references =NULL};
    int64_t bytes_71614 =
            futhark_mc_segmap_parloop_struct_77438->free_bytes_71614;
    struct memblock mem_71634 = {.desc ="mem_71634", .mem =
                                 futhark_mc_segmap_parloop_struct_77438->free_mem_71634,
                                 .size =0, .references =NULL};
    size_t mem_71618_cached_sizze_77440 = 0;
    unsigned char *mem_71618 = NULL;
    int64_t iterations = end - start;
    int64_t iter_76947 = start;
    
    if (mem_71618_cached_sizze_77440 < (size_t) bytes_71614) {
        mem_71618 = realloc(mem_71618, bytes_71614);
        mem_71618_cached_sizze_77440 = bytes_71614;
    }
    for (; iter_76947 < end; iter_76947++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_76997 = m_65377;
        int64_t gtid_70076 = iter_76947;
        int64_t remnant_76998 = iter_76947 - gtid_70076;
        
        for (int64_t i_76948 = 0; i_76948 < n_65378; i_76948++) {
            int64_t m_v_76950 = sdiv64(i_76948, jump_65382);
            bool cond_76951 = m_v_76950 == y_66671;
            int64_t j_76952;
            
            if (cond_76951) {
                int64_t j_t_res_76953 = sub64(m_v_76950, (int64_t) 1);
                
                j_76952 = j_t_res_76953;
            } else {
                j_76952 = m_v_76950;
            }
            
            int64_t min_arg_76954 = mul64(jump_65382, j_76952);
            int64_t min_res_76955 = smin64(i_65392, min_arg_76954);
            int64_t defunc_0_m_fun_arg_76956 = add64((int64_t) 1, j_76952);
            int64_t min_arg_76957 = mul64(jump_65382, defunc_0_m_fun_arg_76956);
            int64_t min_res_76958 = smin64(i_65392, min_arg_76957);
            int64_t i64_arg_76959 = sub64(min_res_76958, min_res_76955);
            double i64_res_76960 = sitofp_i64_f64(i64_arg_76959);
            int64_t i64_arg_76961 = sub64(i_76948, min_res_76955);
            double i64_res_76962 = sitofp_i64_f64(i64_arg_76961);
            double u_76963 = i64_res_76962 / i64_res_76960;
            double u2_76964 = u_76963 * u_76963;
            double u3_76965 = u_76963 * u2_76964;
            double x_76966 = 2.0 * u3_76965;
            double y_76967 = 3.0 * u2_76964;
            double x_76968 = x_76966 - y_76967;
            double x_76969 = 1.0 + x_76968;
            bool x_76970 = sle64((int64_t) 0, j_76952);
            bool y_76971 = slt64(j_76952, n_m_65386);
            bool bounds_check_76972 = x_76970 && y_76971;
            bool index_certs_76973;
            
            if (!bounds_check_76972) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) j_76952,
                              "] out of bounds for array of shape [",
                              (long long) n_m_65386, "].",
                              "-> #0  loess.fut:536:27-33\n   #1  loess.fut:549:13-50\n   #2  /prelude/soacs.fut:59:3-10\n   #3  /prelude/array.fut:195:3-17\n   #4  utils.fut:6:3-16\n   #5  loess.fut:546:3-550:9\n   #6  loess.fut:609:13-59\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:608:5-610:29\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            double y_76974;
            
            y_76974 = ((double *) ext_mem_71612.mem)[gtid_70076 * n_m_65386 +
                                                     j_76952];
            
            double x_76975 = x_76969 * y_76974;
            double x_76976 = y_76967 - x_76966;
            bool x_76977 = sle64((int64_t) 0, defunc_0_m_fun_arg_76956);
            bool y_76978 = slt64(defunc_0_m_fun_arg_76956, n_m_65386);
            bool bounds_check_76979 = x_76977 && y_76978;
            bool index_certs_76980;
            
            if (!bounds_check_76979) {
                ctx->error =
                    msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                              "Index [", (long long) defunc_0_m_fun_arg_76956,
                              "] out of bounds for array of shape [",
                              (long long) n_m_65386, "].",
                              "-> #0  loess.fut:537:27-37\n   #1  loess.fut:549:13-50\n   #2  /prelude/soacs.fut:59:3-10\n   #3  /prelude/array.fut:195:3-17\n   #4  utils.fut:6:3-16\n   #5  loess.fut:546:3-550:9\n   #6  loess.fut:609:13-59\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:608:5-610:29\n   #10 loess.fut:573:1-612:26\n");
                err = 1;
                goto cleanup;
            }
            
            double y_76981;
            
            y_76981 = ((double *) ext_mem_71612.mem)[gtid_70076 * n_m_65386 +
                                                     defunc_0_m_fun_arg_76956];
            
            double y_76982 = x_76976 * y_76981;
            double x_76983 = x_76975 + y_76982;
            double y_76984 = 2.0 * u2_76964;
            double x_76985 = u3_76965 - y_76984;
            double x_76986 = u_76963 + x_76985;
            double y_76987;
            
            y_76987 = ((double *) ext_mem_71611.mem)[gtid_70076 * n_m_65386 +
                                                     j_76952];
            
            double x_76988 = x_76986 * y_76987;
            double y_76989 = i64_res_76960 * x_76988;
            double x_76990 = x_76983 + y_76989;
            double x_76991 = u3_76965 - u2_76964;
            double y_76992;
            
            y_76992 = ((double *) ext_mem_71611.mem)[gtid_70076 * n_m_65386 +
                                                     defunc_0_m_fun_arg_76956];
            
            double x_76993 = x_76991 * y_76992;
            double y_76994 = i64_res_76960 * x_76993;
            double defunc_4_interpolate_proc_res_76995 = x_76990 + y_76994;
            
            ((double *) mem_71618)[i_76948] =
                defunc_4_interpolate_proc_res_76995;
        }
        if (n_65378 * (int64_t) 8 > 0)
            memmove(mem_71634.mem + gtid_70076 * n_65378 * (int64_t) 8,
                    mem_71618 + (int64_t) 0, n_65378 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71618);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77439_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77439_end -
                 futhark_mc_segmap_parloop_77439_start;
        
        ctx->futhark_mc_segmap_parloop_77439_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77439_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77439_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77437(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_70075 = tid;
    int num_tasks_76946 = info.nsubtasks;
    struct futhark_mc_task_77436 *futhark_mc_task_77436 =
                                 (struct futhark_mc_task_77436 *) args;
    struct futhark_context *ctx = futhark_mc_task_77436->ctx;
    uint64_t futhark_mc_segmap_task_77437_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77437_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77436->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77436->free_n_65378;
    int64_t jump_65382 = futhark_mc_task_77436->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77436->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77436->free_i_65392;
    int64_t y_66671 = futhark_mc_task_77436->free_y_66671;
    struct memblock ext_mem_71611 = {.desc ="ext_mem_71611", .mem =
                                     futhark_mc_task_77436->free_ext_mem_71611,
                                     .size =0, .references =NULL};
    struct memblock ext_mem_71612 = {.desc ="ext_mem_71612", .mem =
                                     futhark_mc_task_77436->free_ext_mem_71612,
                                     .size =0, .references =NULL};
    int64_t bytes_71614 = futhark_mc_task_77436->free_bytes_71614;
    struct memblock mem_71634 = {.desc ="mem_71634", .mem =
                                 futhark_mc_task_77436->free_mem_71634, .size =
                                 0, .references =NULL};
    int64_t iter_76947;
    struct futhark_mc_segmap_parloop_struct_77438
    futhark_mc_segmap_parloop_struct_77438;
    
    futhark_mc_segmap_parloop_struct_77438.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77438.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77438.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77438.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77438.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77438.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77438.free_y_66671 = y_66671;
    futhark_mc_segmap_parloop_struct_77438.free_ext_mem_71611 =
        ext_mem_71611.mem;
    futhark_mc_segmap_parloop_struct_77438.free_ext_mem_71612 =
        ext_mem_71612.mem;
    futhark_mc_segmap_parloop_struct_77438.free_bytes_71614 = bytes_71614;
    futhark_mc_segmap_parloop_struct_77438.free_mem_71634 = mem_71634.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77439_task;
    
    futhark_mc_segmap_parloop_77439_task.name =
        "futhark_mc_segmap_parloop_77439";
    futhark_mc_segmap_parloop_77439_task.fn = futhark_mc_segmap_parloop_77439;
    futhark_mc_segmap_parloop_77439_task.args =
        &futhark_mc_segmap_parloop_struct_77438;
    futhark_mc_segmap_parloop_77439_task.iterations = iterations;
    futhark_mc_segmap_parloop_77439_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77439_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77439_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77439_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77439_task);
    
    if (futhark_mc_segmap_parloop_77439_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77439_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77439_total_end -
                 futhark_mc_segmap_parloop_77439_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77439_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77439_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77439_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77437_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77437_end -
                 futhark_mc_segmap_task_77437_start;
        
        ctx->futhark_mc_segmap_task_77437_runs[tid]++;
        ctx->futhark_mc_segmap_task_77437_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77437_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_mc_segmap_parloop_struct_77442 {
    struct futhark_context *ctx;
    int64_t free_m_65377;
    int64_t free_n_65378;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    int64_t free_y_66671;
    unsigned char *free_ext_mem_71611;
    unsigned char *free_ext_mem_71612;
    int64_t free_bytes_71614;
    unsigned char *free_mem_71634;
};
struct futhark_mc_task_77445 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    int64_t free_y_66671;
    int64_t free_gtid_70082;
    unsigned char *free_ext_mem_71611;
    unsigned char *free_ext_mem_71612;
    unsigned char *free_mem_71615;
};
struct futhark_mc_segmap_parloop_struct_77447 {
    struct futhark_context *ctx;
    int64_t free_n_65378;
    int64_t free_jump_65382;
    int64_t free_n_m_65386;
    int64_t free_i_65392;
    int64_t free_y_66671;
    int64_t free_gtid_70082;
    unsigned char *free_ext_mem_71611;
    unsigned char *free_ext_mem_71612;
    unsigned char *free_mem_71615;
};
static int futhark_mc_segmap_parloop_77448(void *args, int64_t start,
                                           int64_t end, int flat_tid_77001,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77447
    *futhark_mc_segmap_parloop_struct_77447 =
    (struct futhark_mc_segmap_parloop_struct_77447 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77447->ctx;
    uint64_t futhark_mc_segmap_parloop_77448_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77448_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77447->free_n_65378;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77447->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77447->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77447->free_i_65392;
    int64_t y_66671 = futhark_mc_segmap_parloop_struct_77447->free_y_66671;
    int64_t gtid_70082 =
            futhark_mc_segmap_parloop_struct_77447->free_gtid_70082;
    struct memblock ext_mem_71611 = {.desc ="ext_mem_71611", .mem =
                                     futhark_mc_segmap_parloop_struct_77447->free_ext_mem_71611,
                                     .size =0, .references =NULL};
    struct memblock ext_mem_71612 = {.desc ="ext_mem_71612", .mem =
                                     futhark_mc_segmap_parloop_struct_77447->free_ext_mem_71612,
                                     .size =0, .references =NULL};
    struct memblock mem_71615 = {.desc ="mem_71615", .mem =
                                 futhark_mc_segmap_parloop_struct_77447->free_mem_71615,
                                 .size =0, .references =NULL};
    int64_t iterations = end - start;
    int64_t iter_77052 = start;
    
    for (; iter_77052 < end; iter_77052++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_77054 = n_65378;
        int64_t gtid_77002 = iter_77052;
        int64_t remnant_77055 = iter_77052 - gtid_77002;
        int64_t m_v_77003 = sdiv64(gtid_77002, jump_65382);
        bool cond_77004 = m_v_77003 == y_66671;
        int64_t j_77005;
        
        if (cond_77004) {
            int64_t j_t_res_77053 = sub64(m_v_77003, (int64_t) 1);
            
            j_77005 = j_t_res_77053;
        } else {
            j_77005 = m_v_77003;
        }
        
        int64_t min_arg_77007 = mul64(jump_65382, j_77005);
        int64_t min_res_77008 = smin64(i_65392, min_arg_77007);
        int64_t defunc_0_m_fun_arg_77009 = add64((int64_t) 1, j_77005);
        int64_t min_arg_77010 = mul64(jump_65382, defunc_0_m_fun_arg_77009);
        int64_t min_res_77011 = smin64(i_65392, min_arg_77010);
        int64_t i64_arg_77012 = sub64(min_res_77011, min_res_77008);
        double i64_res_77013 = sitofp_i64_f64(i64_arg_77012);
        int64_t i64_arg_77014 = sub64(gtid_77002, min_res_77008);
        double i64_res_77015 = sitofp_i64_f64(i64_arg_77014);
        double u_77016 = i64_res_77015 / i64_res_77013;
        double u2_77017 = u_77016 * u_77016;
        double u3_77018 = u_77016 * u2_77017;
        double x_77019 = 2.0 * u3_77018;
        double y_77020 = 3.0 * u2_77017;
        double x_77021 = x_77019 - y_77020;
        double x_77022 = 1.0 + x_77021;
        bool x_77023 = sle64((int64_t) 0, j_77005);
        bool y_77024 = slt64(j_77005, n_m_65386);
        bool bounds_check_77025 = x_77023 && y_77024;
        bool index_certs_77026;
        
        if (!bounds_check_77025) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [", (long long) j_77005,
                                   "] out of bounds for array of shape [",
                                   (long long) n_m_65386, "].",
                                   "-> #0  loess.fut:536:27-33\n   #1  loess.fut:549:13-50\n   #2  /prelude/soacs.fut:59:3-10\n   #3  /prelude/array.fut:195:3-17\n   #4  utils.fut:6:3-16\n   #5  loess.fut:546:3-550:9\n   #6  loess.fut:609:13-59\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:608:5-610:29\n   #10 loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        double y_77027;
        
        y_77027 = ((double *) ext_mem_71612.mem)[gtid_70082 * n_m_65386 +
                                                 j_77005];
        
        double x_77028 = x_77022 * y_77027;
        double x_77029 = y_77020 - x_77019;
        bool x_77030 = sle64((int64_t) 0, defunc_0_m_fun_arg_77009);
        bool y_77031 = slt64(defunc_0_m_fun_arg_77009, n_m_65386);
        bool bounds_check_77032 = x_77030 && y_77031;
        bool index_certs_77033;
        
        if (!bounds_check_77032) {
            ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                                   "Index [",
                                   (long long) defunc_0_m_fun_arg_77009,
                                   "] out of bounds for array of shape [",
                                   (long long) n_m_65386, "].",
                                   "-> #0  loess.fut:537:27-37\n   #1  loess.fut:549:13-50\n   #2  /prelude/soacs.fut:59:3-10\n   #3  /prelude/array.fut:195:3-17\n   #4  utils.fut:6:3-16\n   #5  loess.fut:546:3-550:9\n   #6  loess.fut:609:13-59\n   #7  /prelude/soacs.fut:67:19-23\n   #8  /prelude/soacs.fut:67:3-37\n   #9  loess.fut:608:5-610:29\n   #10 loess.fut:573:1-612:26\n");
            err = 1;
            goto cleanup;
        }
        
        double y_77034;
        
        y_77034 = ((double *) ext_mem_71612.mem)[gtid_70082 * n_m_65386 +
                                                 defunc_0_m_fun_arg_77009];
        
        double y_77035 = x_77029 * y_77034;
        double x_77036 = x_77028 + y_77035;
        double y_77037 = 2.0 * u2_77017;
        double x_77038 = u3_77018 - y_77037;
        double x_77039 = u_77016 + x_77038;
        double y_77040;
        
        y_77040 = ((double *) ext_mem_71611.mem)[gtid_70082 * n_m_65386 +
                                                 j_77005];
        
        double x_77041 = x_77039 * y_77040;
        double y_77042 = i64_res_77013 * x_77041;
        double x_77043 = x_77036 + y_77042;
        double x_77044 = u3_77018 - u2_77017;
        double y_77045;
        
        y_77045 = ((double *) ext_mem_71611.mem)[gtid_70082 * n_m_65386 +
                                                 defunc_0_m_fun_arg_77009];
        
        double x_77046 = x_77044 * y_77045;
        double y_77047 = i64_res_77013 * x_77046;
        double defunc_4_interpolate_proc_res_77048 = x_77043 + y_77047;
        
        ((double *) mem_71615.mem)[gtid_77002] =
            defunc_4_interpolate_proc_res_77048;
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77448_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77448_end -
                 futhark_mc_segmap_parloop_77448_start;
        
        ctx->futhark_mc_segmap_parloop_77448_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77448_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77448_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_task_77446(void *args, int64_t iterations, int tid,
                                 struct scheduler_info info)
{
    int err = 0;
    int flat_tid_77001 = tid;
    int num_tasks_77051 = info.nsubtasks;
    struct futhark_mc_task_77445 *futhark_mc_task_77445 =
                                 (struct futhark_mc_task_77445 *) args;
    struct futhark_context *ctx = futhark_mc_task_77445->ctx;
    uint64_t futhark_mc_segmap_task_77446_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_task_77446_start = get_wall_time();
    
    int64_t n_65378 = futhark_mc_task_77445->free_n_65378;
    int64_t jump_65382 = futhark_mc_task_77445->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77445->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77445->free_i_65392;
    int64_t y_66671 = futhark_mc_task_77445->free_y_66671;
    int64_t gtid_70082 = futhark_mc_task_77445->free_gtid_70082;
    struct memblock ext_mem_71611 = {.desc ="ext_mem_71611", .mem =
                                     futhark_mc_task_77445->free_ext_mem_71611,
                                     .size =0, .references =NULL};
    struct memblock ext_mem_71612 = {.desc ="ext_mem_71612", .mem =
                                     futhark_mc_task_77445->free_ext_mem_71612,
                                     .size =0, .references =NULL};
    struct memblock mem_71615 = {.desc ="mem_71615", .mem =
                                 futhark_mc_task_77445->free_mem_71615, .size =
                                 0, .references =NULL};
    int64_t iter_77052;
    struct futhark_mc_segmap_parloop_struct_77447
    futhark_mc_segmap_parloop_struct_77447;
    
    futhark_mc_segmap_parloop_struct_77447.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77447.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77447.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77447.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77447.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77447.free_y_66671 = y_66671;
    futhark_mc_segmap_parloop_struct_77447.free_gtid_70082 = gtid_70082;
    futhark_mc_segmap_parloop_struct_77447.free_ext_mem_71611 =
        ext_mem_71611.mem;
    futhark_mc_segmap_parloop_struct_77447.free_ext_mem_71612 =
        ext_mem_71612.mem;
    futhark_mc_segmap_parloop_struct_77447.free_mem_71615 = mem_71615.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77448_task;
    
    futhark_mc_segmap_parloop_77448_task.name =
        "futhark_mc_segmap_parloop_77448";
    futhark_mc_segmap_parloop_77448_task.fn = futhark_mc_segmap_parloop_77448;
    futhark_mc_segmap_parloop_77448_task.args =
        &futhark_mc_segmap_parloop_struct_77447;
    futhark_mc_segmap_parloop_77448_task.iterations = iterations;
    futhark_mc_segmap_parloop_77448_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77448_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77448_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77448_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77448_task);
    
    if (futhark_mc_segmap_parloop_77448_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77448_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77448_total_end -
                 futhark_mc_segmap_parloop_77448_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77448_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77448_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77448_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_task_77446_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_task_77446_end -
                 futhark_mc_segmap_task_77446_start;
        
        ctx->futhark_mc_segmap_task_77446_runs[tid]++;
        ctx->futhark_mc_segmap_task_77446_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_task_77446_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
static int futhark_mc_segmap_parloop_77443(void *args, int64_t start,
                                           int64_t end, int flat_tid_70081,
                                           int tid)
{
    int err = 0;
    struct futhark_mc_segmap_parloop_struct_77442
    *futhark_mc_segmap_parloop_struct_77442 =
    (struct futhark_mc_segmap_parloop_struct_77442 *) args;
    struct futhark_context *ctx = futhark_mc_segmap_parloop_struct_77442->ctx;
    uint64_t futhark_mc_segmap_parloop_77443_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77443_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_segmap_parloop_struct_77442->free_m_65377;
    int64_t n_65378 = futhark_mc_segmap_parloop_struct_77442->free_n_65378;
    int64_t jump_65382 =
            futhark_mc_segmap_parloop_struct_77442->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_segmap_parloop_struct_77442->free_n_m_65386;
    int64_t i_65392 = futhark_mc_segmap_parloop_struct_77442->free_i_65392;
    int64_t y_66671 = futhark_mc_segmap_parloop_struct_77442->free_y_66671;
    struct memblock ext_mem_71611 = {.desc ="ext_mem_71611", .mem =
                                     futhark_mc_segmap_parloop_struct_77442->free_ext_mem_71611,
                                     .size =0, .references =NULL};
    struct memblock ext_mem_71612 = {.desc ="ext_mem_71612", .mem =
                                     futhark_mc_segmap_parloop_struct_77442->free_ext_mem_71612,
                                     .size =0, .references =NULL};
    int64_t bytes_71614 =
            futhark_mc_segmap_parloop_struct_77442->free_bytes_71614;
    struct memblock mem_71634 = {.desc ="mem_71634", .mem =
                                 futhark_mc_segmap_parloop_struct_77442->free_mem_71634,
                                 .size =0, .references =NULL};
    size_t mem_71615_cached_sizze_77444 = 0;
    unsigned char *mem_71615 = NULL;
    int64_t iterations = end - start;
    int64_t iter_77000 = start;
    
    if (mem_71615_cached_sizze_77444 < (size_t) bytes_71614) {
        mem_71615 = realloc(mem_71615, bytes_71614);
        mem_71615_cached_sizze_77444 = bytes_71614;
    }
    for (; iter_77000 < end; iter_77000++) {
        if (ctx->debugging)
            fprintf(ctx->log, "%s\n", "SegMap fbody");
        
        int64_t slice_77049 = m_65377;
        int64_t gtid_70082 = iter_77000;
        int64_t remnant_77050 = iter_77000 - gtid_70082;
        int64_t flat_tid_77001 = (int64_t) 0;
        int32_t num_tasks_77051;
        struct futhark_mc_task_77445 futhark_mc_task_77445;
        
        futhark_mc_task_77445.ctx = ctx;
        futhark_mc_task_77445.free_n_65378 = n_65378;
        futhark_mc_task_77445.free_jump_65382 = jump_65382;
        futhark_mc_task_77445.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77445.free_i_65392 = i_65392;
        futhark_mc_task_77445.free_y_66671 = y_66671;
        futhark_mc_task_77445.free_gtid_70082 = gtid_70082;
        futhark_mc_task_77445.free_ext_mem_71611 = ext_mem_71611.mem;
        futhark_mc_task_77445.free_ext_mem_71612 = ext_mem_71612.mem;
        futhark_mc_task_77445.free_mem_71615 = mem_71615;
        
        struct scheduler_segop futhark_mc_task_77445_task;
        
        futhark_mc_task_77445_task.args = &futhark_mc_task_77445;
        futhark_mc_task_77445_task.top_level_fn = futhark_mc_segmap_task_77446;
        futhark_mc_task_77445_task.name = "futhark_mc_segmap_task_77446";
        futhark_mc_task_77445_task.iterations = n_65378;
        futhark_mc_task_77445_task.task_time =
            &ctx->futhark_mc_segmap_task_77446_total_time;
        futhark_mc_task_77445_task.task_iter =
            &ctx->futhark_mc_segmap_task_77446_total_iter;
        futhark_mc_task_77445_task.sched = STATIC;
        futhark_mc_task_77445_task.nested_fn = NULL;
        
        int futhark_mc_segmap_task_77446_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77445_task);
        
        if (futhark_mc_segmap_task_77446_err != 0) {
            ;
            err = 1;
            goto cleanup;
        }
        if (n_65378 * (int64_t) 8 > 0)
            memmove(mem_71634.mem + gtid_70082 * n_65378 * (int64_t) 8,
                    mem_71615 + (int64_t) 0, n_65378 * (int64_t) 8);
    }
    
  cleanup:
    { }
    free(mem_71615);
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77443_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77443_end -
                 futhark_mc_segmap_parloop_77443_start;
        
        ctx->futhark_mc_segmap_parloop_77443_runs[tid]++;
        ctx->futhark_mc_segmap_parloop_77443_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_parloop_77443_iter[tid] += iterations;
    }
    return err;
}
int futhark_mc_segmap_nested_task_77441(void *args, int64_t iterations, int tid,
                                        struct scheduler_info info)
{
    int err = 0;
    int flat_tid_70081 = tid;
    int num_tasks_76946 = info.nsubtasks;
    struct futhark_mc_task_77436 *futhark_mc_task_77436 =
                                 (struct futhark_mc_task_77436 *) args;
    struct futhark_context *ctx = futhark_mc_task_77436->ctx;
    uint64_t futhark_mc_segmap_nested_task_77441_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_nested_task_77441_start = get_wall_time();
    
    int64_t m_65377 = futhark_mc_task_77436->free_m_65377;
    int64_t n_65378 = futhark_mc_task_77436->free_n_65378;
    int64_t jump_65382 = futhark_mc_task_77436->free_jump_65382;
    int64_t n_m_65386 = futhark_mc_task_77436->free_n_m_65386;
    int64_t i_65392 = futhark_mc_task_77436->free_i_65392;
    int64_t y_66671 = futhark_mc_task_77436->free_y_66671;
    struct memblock ext_mem_71611 = {.desc ="ext_mem_71611", .mem =
                                     futhark_mc_task_77436->free_ext_mem_71611,
                                     .size =0, .references =NULL};
    struct memblock ext_mem_71612 = {.desc ="ext_mem_71612", .mem =
                                     futhark_mc_task_77436->free_ext_mem_71612,
                                     .size =0, .references =NULL};
    int64_t bytes_71614 = futhark_mc_task_77436->free_bytes_71614;
    struct memblock mem_71634 = {.desc ="mem_71634", .mem =
                                 futhark_mc_task_77436->free_mem_71634, .size =
                                 0, .references =NULL};
    int64_t iter_77000;
    struct futhark_mc_segmap_parloop_struct_77442
    futhark_mc_segmap_parloop_struct_77442;
    
    futhark_mc_segmap_parloop_struct_77442.ctx = ctx;
    futhark_mc_segmap_parloop_struct_77442.free_m_65377 = m_65377;
    futhark_mc_segmap_parloop_struct_77442.free_n_65378 = n_65378;
    futhark_mc_segmap_parloop_struct_77442.free_jump_65382 = jump_65382;
    futhark_mc_segmap_parloop_struct_77442.free_n_m_65386 = n_m_65386;
    futhark_mc_segmap_parloop_struct_77442.free_i_65392 = i_65392;
    futhark_mc_segmap_parloop_struct_77442.free_y_66671 = y_66671;
    futhark_mc_segmap_parloop_struct_77442.free_ext_mem_71611 =
        ext_mem_71611.mem;
    futhark_mc_segmap_parloop_struct_77442.free_ext_mem_71612 =
        ext_mem_71612.mem;
    futhark_mc_segmap_parloop_struct_77442.free_bytes_71614 = bytes_71614;
    futhark_mc_segmap_parloop_struct_77442.free_mem_71634 = mem_71634.mem;
    
    struct scheduler_parloop futhark_mc_segmap_parloop_77443_task;
    
    futhark_mc_segmap_parloop_77443_task.name =
        "futhark_mc_segmap_parloop_77443";
    futhark_mc_segmap_parloop_77443_task.fn = futhark_mc_segmap_parloop_77443;
    futhark_mc_segmap_parloop_77443_task.args =
        &futhark_mc_segmap_parloop_struct_77442;
    futhark_mc_segmap_parloop_77443_task.iterations = iterations;
    futhark_mc_segmap_parloop_77443_task.info = info;
    
    uint64_t futhark_mc_segmap_parloop_77443_total_start = 0;
    
    if (ctx->profiling && !ctx->profiling_paused)
        futhark_mc_segmap_parloop_77443_total_start = get_wall_time();
    
    int futhark_mc_segmap_parloop_77443_err =
        scheduler_execute_task(&ctx->scheduler,
                               &futhark_mc_segmap_parloop_77443_task);
    
    if (futhark_mc_segmap_parloop_77443_err != 0) {
        err = 1;
        goto cleanup;
    }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_parloop_77443_total_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_parloop_77443_total_end -
                 futhark_mc_segmap_parloop_77443_total_start;
        
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77443_total_runs, 1,
                           __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77443_total_total_runtime,
                           elapsed, __ATOMIC_RELAXED);
        __atomic_fetch_add(&ctx->futhark_mc_segmap_parloop_77443_total_iter,
                           iterations, __ATOMIC_RELAXED);
    }
    
  cleanup:
    { }
    if (ctx->profiling && !ctx->profiling_paused) {
        uint64_t futhark_mc_segmap_nested_task_77441_end = get_wall_time();
        uint64_t elapsed = futhark_mc_segmap_nested_task_77441_end -
                 futhark_mc_segmap_nested_task_77441_start;
        
        ctx->futhark_mc_segmap_nested_task_77441_runs[tid]++;
        ctx->futhark_mc_segmap_nested_task_77441_total_runtime[tid] += elapsed;
        ctx->futhark_mc_segmap_nested_task_77441_iter[tid] += iterations;
    }
    if (err == 0) { }
    return err;
}
struct futhark_f64_2d {
    struct memblock mem;
    int64_t shape[2];
};
struct futhark_f64_2d *futhark_new_f64_2d(struct futhark_context *ctx, const
                                          double *data, int64_t dim0,
                                          int64_t dim1)
{
    struct futhark_f64_2d *bad = NULL;
    struct futhark_f64_2d *arr =
                          (struct futhark_f64_2d *) malloc(sizeof(struct futhark_f64_2d));
    
    if (arr == NULL)
        return bad;
    lock_lock(&ctx->lock);
    worker_local = &ctx->scheduler.workers[0];
    arr->mem.references = NULL;
    if (memblock_alloc(ctx, &arr->mem, dim0 * dim1 * 8, "arr->mem"))
        return NULL;
    arr->shape[0] = dim0;
    arr->shape[1] = dim1;
    if ((size_t) (dim0 * dim1) * 8 > 0)
        memmove(arr->mem.mem + 0, data + 0, (size_t) (dim0 * dim1) * 8);
    lock_unlock(&ctx->lock);
    return arr;
}
struct futhark_f64_2d *futhark_new_raw_f64_2d(struct futhark_context *ctx, const
                                              unsigned char *data,
                                              int64_t offset, int64_t dim0,
                                              int64_t dim1)
{
    struct futhark_f64_2d *bad = NULL;
    struct futhark_f64_2d *arr =
                          (struct futhark_f64_2d *) malloc(sizeof(struct futhark_f64_2d));
    
    if (arr == NULL)
        return bad;
    lock_lock(&ctx->lock);
    worker_local = &ctx->scheduler.workers[0];
    arr->mem.references = NULL;
    if (memblock_alloc(ctx, &arr->mem, dim0 * dim1 * 8, "arr->mem"))
        return NULL;
    arr->shape[0] = dim0;
    arr->shape[1] = dim1;
    if ((size_t) (dim0 * dim1) * 8 > 0)
        memmove(arr->mem.mem + 0, data + offset, (size_t) (dim0 * dim1) * 8);
    lock_unlock(&ctx->lock);
    return arr;
}
int futhark_free_f64_2d(struct futhark_context *ctx, struct futhark_f64_2d *arr)
{
    lock_lock(&ctx->lock);
    worker_local = &ctx->scheduler.workers[0];
    if (memblock_unref(ctx, &arr->mem, "arr->mem") != 0)
        return 1;
    lock_unlock(&ctx->lock);
    free(arr);
    return 0;
}
int futhark_values_f64_2d(struct futhark_context *ctx,
                          struct futhark_f64_2d *arr, double *data)
{
    lock_lock(&ctx->lock);
    worker_local = &ctx->scheduler.workers[0];
    if ((size_t) (arr->shape[0] * arr->shape[1]) * 8 > 0)
        memmove(data + 0, arr->mem.mem + 0, (size_t) (arr->shape[0] *
                                                      arr->shape[1]) * 8);
    lock_unlock(&ctx->lock);
    return 0;
}
unsigned char *futhark_values_raw_f64_2d(struct futhark_context *ctx,
                                         struct futhark_f64_2d *arr)
{
    (void) ctx;
    return arr->mem.mem;
}
const int64_t *futhark_shape_f64_2d(struct futhark_context *ctx,
                                    struct futhark_f64_2d *arr)
{
    (void) ctx;
    return arr->shape;
}

static int futrts_entry_main(struct futhark_context *ctx,
                             struct memblock *mem_out_p_77056,
                             struct memblock Y_mem_70603, int64_t m_65377,
                             int64_t n_65378, int64_t q_65380,
                             int64_t degree_65381, int64_t jump_65382,
                             int64_t jump_threshold_65383,
                             int64_t q_threshold_65384)
{
    (void) ctx;
    
    int err = 0;
    struct memblock mem_out_71652;
    
    mem_out_71652.references = NULL;
    
    bool cond_65385 = jump_65382 == (int64_t) 1;
    int64_t n_m_65386;
    
    if (cond_65385) {
        n_m_65386 = n_65378;
    } else {
        bool zzero_65387 = jump_65382 == (int64_t) 0;
        bool nonzzero_65388 = !zzero_65387;
        bool nonzzero_cert_65389;
        
        if (!nonzzero_65388) {
            ctx->error = msgprintf("Error: %s\n\nBacktrace:\n%s",
                                   "division by zero",
                                   "-> #0  loess.fut:580:38-45\n   #1  loess.fut:573:1-612:26\n");
            if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
                return 1;
            err = 1;
            goto cleanup;
        }
        
        int64_t x_65390 = sdiv64(n_65378, jump_65382);
        int64_t n_m_f_res_65391 = add64((int64_t) 1, x_65390);
        
        n_m_65386 = n_m_f_res_65391;
    }
    
    int64_t i_65392 = sub64(n_65378, (int64_t) 1);
    bool x_65393 = sle64((int64_t) 0, i_65392);
    bool y_65394 = slt64(i_65392, n_65378);
    bool bounds_check_65395 = x_65393 && y_65394;
    bool index_certs_65396;
    
    if (!bounds_check_65395) {
        ctx->error = msgprintf("Error: %s%lld%s%lld%s\n\nBacktrace:\n%s",
                               "Index [", (long long) i_65392,
                               "] out of bounds for array of shape [",
                               (long long) n_65378, "].",
                               "-> #0  /prelude/array.fut:26:29-34\n   #1  utils.fut:45:13-20\n   #2  loess.fut:585:5-54\n   #3  loess.fut:573:1-612:26\n");
        if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
            return 1;
        err = 1;
        goto cleanup;
    }
    
    int64_t min_res_65398 = smin64(n_65378, q_65380);
    bool bounds_invalid_upwards_65399 = slt64(n_m_65386, (int64_t) 0);
    bool valid_65400 = !bounds_invalid_upwards_65399;
    bool range_valid_c_65401;
    
    if (!valid_65400) {
        ctx->error = msgprintf("Error: %s%lld%s%lld%s%lld%s\n\nBacktrace:\n%s",
                               "Range ", (long long) (int64_t) 0, "..",
                               (long long) (int64_t) 1, "..<",
                               (long long) n_m_65386, " is invalid.",
                               "-> #0  /prelude/array.fut:90:3-10\n   #1  /prelude/array.fut:195:11-16\n   #2  utils.fut:6:3-16\n   #3  loess.fut:443:3-470:10\n   #4  loess.fut:503:15-61\n   #5  loess.fut:590:13-56\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:589:5-591:26\n   #9  loess.fut:573:1-612:26\n");
        if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
            return 1;
        err = 1;
        goto cleanup;
    }
    
    bool loop_cond_65403 = slt64((int64_t) 1, min_res_65398);
    double i64_res_65404 = sitofp_i64_f64(q_65380);
    bool cond_65405 = slt64(jump_65382, jump_threshold_65383);
    bool cond_f_res_65406 = slt64(q_threshold_65384, q_65380);
    bool x_65407 = !cond_65405;
    bool y_65408 = cond_f_res_65406 && x_65407;
    bool cond_65409 = cond_65405 || y_65408;
    struct memblock ext_mem_71612;
    
    ext_mem_71612.references = NULL;
    
    struct memblock ext_mem_71611;
    
    ext_mem_71611.references = NULL;
    if (cond_65409) {
        bool match_lit_65412 = (int64_t) 0 == degree_65381;
        int64_t binop_x_70604 = m_65377 * n_m_65386;
        int64_t binop_y_70605 = (int64_t) 8 * binop_x_70604;
        int64_t bytes_70606 = smax64((int64_t) 0, binop_y_70605);
        struct memblock ext_mem_70991;
        
        ext_mem_70991.references = NULL;
        
        struct memblock ext_mem_70990;
        
        ext_mem_70990.references = NULL;
        if (match_lit_65412) {
            struct memblock mem_70607;
            
            mem_70607.references = NULL;
            if (memblock_alloc(ctx, &mem_70607, bytes_70606, "mem_70607")) {
                err = 1;
                goto cleanup;
            }
            for (int64_t i_71653 = 0; i_71653 < m_65377; i_71653++) {
                for (int64_t i_71654 = 0; i_71654 < n_m_65386; i_71654++) {
                    ((double *) mem_70607.mem)[i_71653 * n_m_65386 + i_71654] =
                        0.0;
                }
            }
            
            struct memblock mem_70719;
            
            mem_70719.references = NULL;
            if (memblock_alloc(ctx, &mem_70719, bytes_70606, "mem_70719")) {
                err = 1;
                goto cleanup;
            }
            
            int64_t binop_y_70608 = (int64_t) 8 * n_65378;
            int64_t bytes_70609 = smax64((int64_t) 0, binop_y_70608);
            int64_t binop_y_70620 = (int64_t) 8 * q_65380;
            int64_t bytes_70621 = smax64((int64_t) 0, binop_y_70620);
            int64_t binop_y_70623 = (int64_t) 8 * n_m_65386;
            int64_t bytes_70624 = smax64((int64_t) 0, binop_y_70623);
            int64_t flat_tid_66726 = (int64_t) 0;
            int32_t num_tasks_71655;
            int64_t flat_tid_66887 = (int64_t) 0;
            struct futhark_mc_task_77057 futhark_mc_task_77057;
            
            futhark_mc_task_77057.ctx = ctx;
            futhark_mc_task_77057.free_m_65377 = m_65377;
            futhark_mc_task_77057.free_n_65378 = n_65378;
            futhark_mc_task_77057.free_q_65380 = q_65380;
            futhark_mc_task_77057.free_jump_65382 = jump_65382;
            futhark_mc_task_77057.free_n_m_65386 = n_m_65386;
            futhark_mc_task_77057.free_i_65392 = i_65392;
            futhark_mc_task_77057.free_x_65393 = x_65393;
            futhark_mc_task_77057.free_min_res_65398 = min_res_65398;
            futhark_mc_task_77057.free_loop_cond_65403 = loop_cond_65403;
            futhark_mc_task_77057.free_i64_res_65404 = i64_res_65404;
            futhark_mc_task_77057.free_Y_mem_70603 = Y_mem_70603.mem;
            futhark_mc_task_77057.free_bytes_70609 = bytes_70609;
            futhark_mc_task_77057.free_bytes_70621 = bytes_70621;
            futhark_mc_task_77057.free_bytes_70624 = bytes_70624;
            futhark_mc_task_77057.free_mem_70719 = mem_70719.mem;
            
            struct scheduler_segop futhark_mc_task_77057_task;
            
            futhark_mc_task_77057_task.args = &futhark_mc_task_77057;
            futhark_mc_task_77057_task.top_level_fn =
                futhark_mc_segmap_task_77058;
            futhark_mc_task_77057_task.name = "futhark_mc_segmap_task_77058";
            futhark_mc_task_77057_task.iterations = m_65377;
            futhark_mc_task_77057_task.task_time =
                &ctx->futhark_mc_segmap_task_77058_total_time;
            futhark_mc_task_77057_task.task_iter =
                &ctx->futhark_mc_segmap_task_77058_total_iter;
            futhark_mc_task_77057_task.sched = DYNAMIC;
            futhark_mc_task_77057_task.nested_fn =
                futhark_mc_segmap_nested_task_77067;
            
            int futhark_mc_segmap_task_77058_err =
                scheduler_prepare_task(&ctx->scheduler,
                                       &futhark_mc_task_77057_task);
            
            if (futhark_mc_segmap_task_77058_err != 0) {
                if (memblock_unref(ctx, &mem_70719, "mem_70719") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_70607, "mem_70607") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_70990, "ext_mem_70990") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_70991, "ext_mem_70991") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
                    return 1;
                ;
                err = 1;
                goto cleanup;
            }
            if (memblock_set(ctx, &ext_mem_70991, &mem_70719, "mem_70719") != 0)
                return 1;
            if (memblock_set(ctx, &ext_mem_70990, &mem_70607, "mem_70607") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_70719, "mem_70719") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_70607, "mem_70607") != 0)
                return 1;
        } else {
            bool match_lit_65591 = (int64_t) 1 == degree_65381;
            struct memblock ext_mem_70989;
            
            ext_mem_70989.references = NULL;
            
            struct memblock ext_mem_70988;
            
            ext_mem_70988.references = NULL;
            if (match_lit_65591) {
                struct memblock mem_70849;
                
                mem_70849.references = NULL;
                if (memblock_alloc(ctx, &mem_70849, bytes_70606, "mem_70849")) {
                    err = 1;
                    goto cleanup;
                }
                
                struct memblock mem_70853;
                
                mem_70853.references = NULL;
                if (memblock_alloc(ctx, &mem_70853, bytes_70606, "mem_70853")) {
                    err = 1;
                    goto cleanup;
                }
                
                int64_t binop_y_70720 = (int64_t) 8 * n_65378;
                int64_t bytes_70721 = smax64((int64_t) 0, binop_y_70720);
                int64_t binop_y_70732 = (int64_t) 8 * q_65380;
                int64_t bytes_70733 = smax64((int64_t) 0, binop_y_70732);
                int64_t binop_y_70735 = (int64_t) 8 * n_m_65386;
                int64_t bytes_70736 = smax64((int64_t) 0, binop_y_70735);
                int64_t flat_tid_67211 = (int64_t) 0;
                int32_t num_tasks_72414;
                int64_t flat_tid_67400 = (int64_t) 0;
                struct futhark_mc_task_77112 futhark_mc_task_77112;
                
                futhark_mc_task_77112.ctx = ctx;
                futhark_mc_task_77112.free_m_65377 = m_65377;
                futhark_mc_task_77112.free_n_65378 = n_65378;
                futhark_mc_task_77112.free_q_65380 = q_65380;
                futhark_mc_task_77112.free_jump_65382 = jump_65382;
                futhark_mc_task_77112.free_n_m_65386 = n_m_65386;
                futhark_mc_task_77112.free_i_65392 = i_65392;
                futhark_mc_task_77112.free_x_65393 = x_65393;
                futhark_mc_task_77112.free_min_res_65398 = min_res_65398;
                futhark_mc_task_77112.free_loop_cond_65403 = loop_cond_65403;
                futhark_mc_task_77112.free_i64_res_65404 = i64_res_65404;
                futhark_mc_task_77112.free_Y_mem_70603 = Y_mem_70603.mem;
                futhark_mc_task_77112.free_bytes_70721 = bytes_70721;
                futhark_mc_task_77112.free_bytes_70733 = bytes_70733;
                futhark_mc_task_77112.free_bytes_70736 = bytes_70736;
                futhark_mc_task_77112.free_mem_70849 = mem_70849.mem;
                futhark_mc_task_77112.free_mem_70853 = mem_70853.mem;
                
                struct scheduler_segop futhark_mc_task_77112_task;
                
                futhark_mc_task_77112_task.args = &futhark_mc_task_77112;
                futhark_mc_task_77112_task.top_level_fn =
                    futhark_mc_segmap_task_77113;
                futhark_mc_task_77112_task.name =
                    "futhark_mc_segmap_task_77113";
                futhark_mc_task_77112_task.iterations = m_65377;
                futhark_mc_task_77112_task.task_time =
                    &ctx->futhark_mc_segmap_task_77113_total_time;
                futhark_mc_task_77112_task.task_iter =
                    &ctx->futhark_mc_segmap_task_77113_total_iter;
                futhark_mc_task_77112_task.sched = DYNAMIC;
                futhark_mc_task_77112_task.nested_fn =
                    futhark_mc_segmap_nested_task_77123;
                
                int futhark_mc_segmap_task_77113_err =
                    scheduler_prepare_task(&ctx->scheduler,
                                           &futhark_mc_task_77112_task);
                
                if (futhark_mc_segmap_task_77113_err != 0) {
                    if (memblock_unref(ctx, &mem_70853, "mem_70853") != 0)
                        return 1;
                    if (memblock_unref(ctx, &mem_70849, "mem_70849") != 0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70988, "ext_mem_70988") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70989, "ext_mem_70989") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70990, "ext_mem_70990") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70991, "ext_mem_70991") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") !=
                        0)
                        return 1;
                    ;
                    err = 1;
                    goto cleanup;
                }
                if (memblock_set(ctx, &ext_mem_70989, &mem_70849,
                                 "mem_70849") != 0)
                    return 1;
                if (memblock_set(ctx, &ext_mem_70988, &mem_70853,
                                 "mem_70853") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_70853, "mem_70853") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_70849, "mem_70849") != 0)
                    return 1;
            } else {
                struct memblock mem_70983;
                
                mem_70983.references = NULL;
                if (memblock_alloc(ctx, &mem_70983, bytes_70606, "mem_70983")) {
                    err = 1;
                    goto cleanup;
                }
                
                struct memblock mem_70987;
                
                mem_70987.references = NULL;
                if (memblock_alloc(ctx, &mem_70987, bytes_70606, "mem_70987")) {
                    err = 1;
                    goto cleanup;
                }
                
                int64_t binop_y_70854 = (int64_t) 8 * n_65378;
                int64_t bytes_70855 = smax64((int64_t) 0, binop_y_70854);
                int64_t binop_y_70866 = (int64_t) 8 * q_65380;
                int64_t bytes_70867 = smax64((int64_t) 0, binop_y_70866);
                int64_t binop_y_70869 = (int64_t) 8 * n_m_65386;
                int64_t bytes_70870 = smax64((int64_t) 0, binop_y_70869);
                int64_t flat_tid_67781 = (int64_t) 0;
                int32_t num_tasks_73311;
                int64_t flat_tid_68002 = (int64_t) 0;
                struct futhark_mc_task_77172 futhark_mc_task_77172;
                
                futhark_mc_task_77172.ctx = ctx;
                futhark_mc_task_77172.free_m_65377 = m_65377;
                futhark_mc_task_77172.free_n_65378 = n_65378;
                futhark_mc_task_77172.free_q_65380 = q_65380;
                futhark_mc_task_77172.free_jump_65382 = jump_65382;
                futhark_mc_task_77172.free_n_m_65386 = n_m_65386;
                futhark_mc_task_77172.free_i_65392 = i_65392;
                futhark_mc_task_77172.free_x_65393 = x_65393;
                futhark_mc_task_77172.free_min_res_65398 = min_res_65398;
                futhark_mc_task_77172.free_loop_cond_65403 = loop_cond_65403;
                futhark_mc_task_77172.free_i64_res_65404 = i64_res_65404;
                futhark_mc_task_77172.free_Y_mem_70603 = Y_mem_70603.mem;
                futhark_mc_task_77172.free_bytes_70855 = bytes_70855;
                futhark_mc_task_77172.free_bytes_70867 = bytes_70867;
                futhark_mc_task_77172.free_bytes_70870 = bytes_70870;
                futhark_mc_task_77172.free_mem_70983 = mem_70983.mem;
                futhark_mc_task_77172.free_mem_70987 = mem_70987.mem;
                
                struct scheduler_segop futhark_mc_task_77172_task;
                
                futhark_mc_task_77172_task.args = &futhark_mc_task_77172;
                futhark_mc_task_77172_task.top_level_fn =
                    futhark_mc_segmap_task_77173;
                futhark_mc_task_77172_task.name =
                    "futhark_mc_segmap_task_77173";
                futhark_mc_task_77172_task.iterations = m_65377;
                futhark_mc_task_77172_task.task_time =
                    &ctx->futhark_mc_segmap_task_77173_total_time;
                futhark_mc_task_77172_task.task_iter =
                    &ctx->futhark_mc_segmap_task_77173_total_iter;
                futhark_mc_task_77172_task.sched = DYNAMIC;
                futhark_mc_task_77172_task.nested_fn =
                    futhark_mc_segmap_nested_task_77183;
                
                int futhark_mc_segmap_task_77173_err =
                    scheduler_prepare_task(&ctx->scheduler,
                                           &futhark_mc_task_77172_task);
                
                if (futhark_mc_segmap_task_77173_err != 0) {
                    if (memblock_unref(ctx, &mem_70987, "mem_70987") != 0)
                        return 1;
                    if (memblock_unref(ctx, &mem_70983, "mem_70983") != 0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70988, "ext_mem_70988") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70989, "ext_mem_70989") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70990, "ext_mem_70990") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_70991, "ext_mem_70991") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") !=
                        0)
                        return 1;
                    ;
                    err = 1;
                    goto cleanup;
                }
                if (memblock_set(ctx, &ext_mem_70989, &mem_70983,
                                 "mem_70983") != 0)
                    return 1;
                if (memblock_set(ctx, &ext_mem_70988, &mem_70987,
                                 "mem_70987") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_70987, "mem_70987") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_70983, "mem_70983") != 0)
                    return 1;
            }
            if (memblock_set(ctx, &ext_mem_70991, &ext_mem_70989,
                             "ext_mem_70989") != 0)
                return 1;
            if (memblock_set(ctx, &ext_mem_70990, &ext_mem_70988,
                             "ext_mem_70988") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_70988, "ext_mem_70988") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_70989, "ext_mem_70989") != 0)
                return 1;
        }
        if (memblock_set(ctx, &ext_mem_71612, &ext_mem_70991,
                         "ext_mem_70991") != 0)
            return 1;
        if (memblock_set(ctx, &ext_mem_71611, &ext_mem_70990,
                         "ext_mem_70990") != 0)
            return 1;
        if (memblock_unref(ctx, &ext_mem_70990, "ext_mem_70990") != 0)
            return 1;
        if (memblock_unref(ctx, &ext_mem_70991, "ext_mem_70991") != 0)
            return 1;
    } else {
        bool match_lit_66036 = (int64_t) 0 == degree_65381;
        int64_t binop_x_70992 = m_65377 * n_m_65386;
        int64_t binop_y_70993 = (int64_t) 8 * binop_x_70992;
        int64_t bytes_70994 = smax64((int64_t) 0, binop_y_70993);
        struct memblock ext_mem_71610;
        
        ext_mem_71610.references = NULL;
        
        struct memblock ext_mem_71609;
        
        ext_mem_71609.references = NULL;
        if (match_lit_66036) {
            struct memblock mem_70995;
            
            mem_70995.references = NULL;
            if (memblock_alloc(ctx, &mem_70995, bytes_70994, "mem_70995")) {
                err = 1;
                goto cleanup;
            }
            for (int64_t i_74340 = 0; i_74340 < m_65377; i_74340++) {
                for (int64_t i_74341 = 0; i_74341 < n_m_65386; i_74341++) {
                    ((double *) mem_70995.mem)[i_74340 * n_m_65386 + i_74341] =
                        0.0;
                }
            }
            
            struct memblock mem_71140;
            
            mem_71140.references = NULL;
            if (memblock_alloc(ctx, &mem_71140, bytes_70994, "mem_71140")) {
                err = 1;
                goto cleanup;
            }
            
            int64_t binop_y_70996 = (int64_t) 8 * n_65378;
            int64_t bytes_70997 = smax64((int64_t) 0, binop_y_70996);
            int64_t binop_y_71008 = (int64_t) 8 * q_65380;
            int64_t bytes_71009 = smax64((int64_t) 0, binop_y_71008);
            int64_t binop_y_71029 = (int64_t) 8 * n_m_65386;
            int64_t bytes_71030 = smax64((int64_t) 0, binop_y_71029);
            int64_t flat_tid_68447 = (int64_t) 0;
            int32_t num_tasks_74342;
            int64_t flat_tid_68595 = (int64_t) 0;
            struct futhark_mc_task_77234 futhark_mc_task_77234;
            
            futhark_mc_task_77234.ctx = ctx;
            futhark_mc_task_77234.free_m_65377 = m_65377;
            futhark_mc_task_77234.free_n_65378 = n_65378;
            futhark_mc_task_77234.free_q_65380 = q_65380;
            futhark_mc_task_77234.free_jump_65382 = jump_65382;
            futhark_mc_task_77234.free_n_m_65386 = n_m_65386;
            futhark_mc_task_77234.free_i_65392 = i_65392;
            futhark_mc_task_77234.free_x_65393 = x_65393;
            futhark_mc_task_77234.free_min_res_65398 = min_res_65398;
            futhark_mc_task_77234.free_loop_cond_65403 = loop_cond_65403;
            futhark_mc_task_77234.free_i64_res_65404 = i64_res_65404;
            futhark_mc_task_77234.free_Y_mem_70603 = Y_mem_70603.mem;
            futhark_mc_task_77234.free_bytes_70997 = bytes_70997;
            futhark_mc_task_77234.free_bytes_71009 = bytes_71009;
            futhark_mc_task_77234.free_bytes_71030 = bytes_71030;
            futhark_mc_task_77234.free_mem_71140 = mem_71140.mem;
            
            struct scheduler_segop futhark_mc_task_77234_task;
            
            futhark_mc_task_77234_task.args = &futhark_mc_task_77234;
            futhark_mc_task_77234_task.top_level_fn =
                futhark_mc_segmap_task_77235;
            futhark_mc_task_77234_task.name = "futhark_mc_segmap_task_77235";
            futhark_mc_task_77234_task.iterations = m_65377;
            futhark_mc_task_77234_task.task_time =
                &ctx->futhark_mc_segmap_task_77235_total_time;
            futhark_mc_task_77234_task.task_iter =
                &ctx->futhark_mc_segmap_task_77235_total_iter;
            futhark_mc_task_77234_task.sched = DYNAMIC;
            futhark_mc_task_77234_task.nested_fn =
                futhark_mc_segmap_nested_task_77245;
            
            int futhark_mc_segmap_task_77235_err =
                scheduler_prepare_task(&ctx->scheduler,
                                       &futhark_mc_task_77234_task);
            
            if (futhark_mc_segmap_task_77235_err != 0) {
                if (memblock_unref(ctx, &mem_71140, "mem_71140") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_70995, "mem_70995") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_71609, "ext_mem_71609") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_71610, "ext_mem_71610") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
                    return 1;
                if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
                    return 1;
                ;
                err = 1;
                goto cleanup;
            }
            if (memblock_set(ctx, &ext_mem_71610, &mem_71140, "mem_71140") != 0)
                return 1;
            if (memblock_set(ctx, &ext_mem_71609, &mem_70995, "mem_70995") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_71140, "mem_71140") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_70995, "mem_70995") != 0)
                return 1;
        } else {
            bool match_lit_66202 = (int64_t) 1 == degree_65381;
            struct memblock ext_mem_71608;
            
            ext_mem_71608.references = NULL;
            
            struct memblock ext_mem_71607;
            
            ext_mem_71607.references = NULL;
            if (match_lit_66202) {
                struct memblock mem_71336;
                
                mem_71336.references = NULL;
                if (memblock_alloc(ctx, &mem_71336, bytes_70994, "mem_71336")) {
                    err = 1;
                    goto cleanup;
                }
                
                struct memblock mem_71340;
                
                mem_71340.references = NULL;
                if (memblock_alloc(ctx, &mem_71340, bytes_70994, "mem_71340")) {
                    err = 1;
                    goto cleanup;
                }
                
                int64_t binop_y_71141 = (int64_t) 8 * n_65378;
                int64_t bytes_71142 = smax64((int64_t) 0, binop_y_71141);
                int64_t binop_y_71153 = (int64_t) 8 * q_65380;
                int64_t bytes_71154 = smax64((int64_t) 0, binop_y_71153);
                int64_t binop_y_71192 = (int64_t) 8 * n_m_65386;
                int64_t bytes_71193 = smax64((int64_t) 0, binop_y_71192);
                int64_t flat_tid_68893 = (int64_t) 0;
                int32_t num_tasks_75046;
                int64_t flat_tid_69070 = (int64_t) 0;
                struct futhark_mc_task_77292 futhark_mc_task_77292;
                
                futhark_mc_task_77292.ctx = ctx;
                futhark_mc_task_77292.free_m_65377 = m_65377;
                futhark_mc_task_77292.free_n_65378 = n_65378;
                futhark_mc_task_77292.free_q_65380 = q_65380;
                futhark_mc_task_77292.free_jump_65382 = jump_65382;
                futhark_mc_task_77292.free_n_m_65386 = n_m_65386;
                futhark_mc_task_77292.free_i_65392 = i_65392;
                futhark_mc_task_77292.free_x_65393 = x_65393;
                futhark_mc_task_77292.free_min_res_65398 = min_res_65398;
                futhark_mc_task_77292.free_loop_cond_65403 = loop_cond_65403;
                futhark_mc_task_77292.free_i64_res_65404 = i64_res_65404;
                futhark_mc_task_77292.free_Y_mem_70603 = Y_mem_70603.mem;
                futhark_mc_task_77292.free_bytes_71142 = bytes_71142;
                futhark_mc_task_77292.free_bytes_71154 = bytes_71154;
                futhark_mc_task_77292.free_bytes_71193 = bytes_71193;
                futhark_mc_task_77292.free_mem_71336 = mem_71336.mem;
                futhark_mc_task_77292.free_mem_71340 = mem_71340.mem;
                
                struct scheduler_segop futhark_mc_task_77292_task;
                
                futhark_mc_task_77292_task.args = &futhark_mc_task_77292;
                futhark_mc_task_77292_task.top_level_fn =
                    futhark_mc_segmap_task_77293;
                futhark_mc_task_77292_task.name =
                    "futhark_mc_segmap_task_77293";
                futhark_mc_task_77292_task.iterations = m_65377;
                futhark_mc_task_77292_task.task_time =
                    &ctx->futhark_mc_segmap_task_77293_total_time;
                futhark_mc_task_77292_task.task_iter =
                    &ctx->futhark_mc_segmap_task_77293_total_iter;
                futhark_mc_task_77292_task.sched = DYNAMIC;
                futhark_mc_task_77292_task.nested_fn =
                    futhark_mc_segmap_nested_task_77305;
                
                int futhark_mc_segmap_task_77293_err =
                    scheduler_prepare_task(&ctx->scheduler,
                                           &futhark_mc_task_77292_task);
                
                if (futhark_mc_segmap_task_77293_err != 0) {
                    if (memblock_unref(ctx, &mem_71340, "mem_71340") != 0)
                        return 1;
                    if (memblock_unref(ctx, &mem_71336, "mem_71336") != 0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71607, "ext_mem_71607") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71608, "ext_mem_71608") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71609, "ext_mem_71609") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71610, "ext_mem_71610") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") !=
                        0)
                        return 1;
                    ;
                    err = 1;
                    goto cleanup;
                }
                if (memblock_set(ctx, &ext_mem_71608, &mem_71336,
                                 "mem_71336") != 0)
                    return 1;
                if (memblock_set(ctx, &ext_mem_71607, &mem_71340,
                                 "mem_71340") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_71340, "mem_71340") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_71336, "mem_71336") != 0)
                    return 1;
            } else {
                struct memblock mem_71602;
                
                mem_71602.references = NULL;
                if (memblock_alloc(ctx, &mem_71602, bytes_70994, "mem_71602")) {
                    err = 1;
                    goto cleanup;
                }
                
                struct memblock mem_71606;
                
                mem_71606.references = NULL;
                if (memblock_alloc(ctx, &mem_71606, bytes_70994, "mem_71606")) {
                    err = 1;
                    goto cleanup;
                }
                
                int64_t binop_y_71341 = (int64_t) 8 * n_65378;
                int64_t bytes_71342 = smax64((int64_t) 0, binop_y_71341);
                int64_t binop_y_71353 = (int64_t) 8 * q_65380;
                int64_t bytes_71354 = smax64((int64_t) 0, binop_y_71353);
                int64_t binop_y_71428 = (int64_t) 8 * n_m_65386;
                int64_t bytes_71429 = smax64((int64_t) 0, binop_y_71428);
                int64_t flat_tid_69427 = (int64_t) 0;
                int32_t num_tasks_75903;
                int64_t flat_tid_69644 = (int64_t) 0;
                struct futhark_mc_task_77358 futhark_mc_task_77358;
                
                futhark_mc_task_77358.ctx = ctx;
                futhark_mc_task_77358.free_m_65377 = m_65377;
                futhark_mc_task_77358.free_n_65378 = n_65378;
                futhark_mc_task_77358.free_q_65380 = q_65380;
                futhark_mc_task_77358.free_jump_65382 = jump_65382;
                futhark_mc_task_77358.free_n_m_65386 = n_m_65386;
                futhark_mc_task_77358.free_i_65392 = i_65392;
                futhark_mc_task_77358.free_x_65393 = x_65393;
                futhark_mc_task_77358.free_min_res_65398 = min_res_65398;
                futhark_mc_task_77358.free_loop_cond_65403 = loop_cond_65403;
                futhark_mc_task_77358.free_i64_res_65404 = i64_res_65404;
                futhark_mc_task_77358.free_Y_mem_70603 = Y_mem_70603.mem;
                futhark_mc_task_77358.free_bytes_71342 = bytes_71342;
                futhark_mc_task_77358.free_bytes_71354 = bytes_71354;
                futhark_mc_task_77358.free_bytes_71429 = bytes_71429;
                futhark_mc_task_77358.free_mem_71602 = mem_71602.mem;
                futhark_mc_task_77358.free_mem_71606 = mem_71606.mem;
                
                struct scheduler_segop futhark_mc_task_77358_task;
                
                futhark_mc_task_77358_task.args = &futhark_mc_task_77358;
                futhark_mc_task_77358_task.top_level_fn =
                    futhark_mc_segmap_task_77359;
                futhark_mc_task_77358_task.name =
                    "futhark_mc_segmap_task_77359";
                futhark_mc_task_77358_task.iterations = m_65377;
                futhark_mc_task_77358_task.task_time =
                    &ctx->futhark_mc_segmap_task_77359_total_time;
                futhark_mc_task_77358_task.task_iter =
                    &ctx->futhark_mc_segmap_task_77359_total_iter;
                futhark_mc_task_77358_task.sched = DYNAMIC;
                futhark_mc_task_77358_task.nested_fn =
                    futhark_mc_segmap_nested_task_77373;
                
                int futhark_mc_segmap_task_77359_err =
                    scheduler_prepare_task(&ctx->scheduler,
                                           &futhark_mc_task_77358_task);
                
                if (futhark_mc_segmap_task_77359_err != 0) {
                    if (memblock_unref(ctx, &mem_71606, "mem_71606") != 0)
                        return 1;
                    if (memblock_unref(ctx, &mem_71602, "mem_71602") != 0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71607, "ext_mem_71607") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71608, "ext_mem_71608") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71609, "ext_mem_71609") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71610, "ext_mem_71610") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") !=
                        0)
                        return 1;
                    if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") !=
                        0)
                        return 1;
                    ;
                    err = 1;
                    goto cleanup;
                }
                if (memblock_set(ctx, &ext_mem_71608, &mem_71602,
                                 "mem_71602") != 0)
                    return 1;
                if (memblock_set(ctx, &ext_mem_71607, &mem_71606,
                                 "mem_71606") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_71606, "mem_71606") != 0)
                    return 1;
                if (memblock_unref(ctx, &mem_71602, "mem_71602") != 0)
                    return 1;
            }
            if (memblock_set(ctx, &ext_mem_71610, &ext_mem_71608,
                             "ext_mem_71608") != 0)
                return 1;
            if (memblock_set(ctx, &ext_mem_71609, &ext_mem_71607,
                             "ext_mem_71607") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71607, "ext_mem_71607") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71608, "ext_mem_71608") != 0)
                return 1;
        }
        if (memblock_set(ctx, &ext_mem_71612, &ext_mem_71610,
                         "ext_mem_71610") != 0)
            return 1;
        if (memblock_set(ctx, &ext_mem_71611, &ext_mem_71609,
                         "ext_mem_71609") != 0)
            return 1;
        if (memblock_unref(ctx, &ext_mem_71609, "ext_mem_71609") != 0)
            return 1;
        if (memblock_unref(ctx, &ext_mem_71610, "ext_mem_71610") != 0)
            return 1;
    }
    
    bool cond_66666 = slt64((int64_t) 1, jump_65382);
    int64_t ext_71636;
    
    if (cond_66666) {
        ext_71636 = n_65378;
    } else {
        ext_71636 = n_m_65386;
    }
    
    int64_t binop_x_71631 = m_65377 * n_65378;
    int64_t binop_y_71632 = (int64_t) 8 * binop_x_71631;
    int64_t bytes_71633 = smax64((int64_t) 0, binop_y_71632);
    struct memblock ext_mem_71635;
    
    ext_mem_71635.references = NULL;
    if (cond_66666) {
        bool zzero_66668 = jump_65382 == (int64_t) 0;
        bool nonzzero_66669 = !zzero_66668;
        bool nonzzero_cert_66670;
        
        if (!nonzzero_66669) {
            ctx->error = msgprintf("Error: %s\n\nBacktrace:\n%s",
                                   "division by zero",
                                   "-> #0  loess.fut:547:20-27\n   #1  /prelude/soacs.fut:59:3-10\n   #2  /prelude/array.fut:195:3-17\n   #3  utils.fut:6:3-16\n   #4  loess.fut:546:3-550:9\n   #5  loess.fut:609:13-59\n   #6  /prelude/soacs.fut:67:19-23\n   #7  /prelude/soacs.fut:67:3-37\n   #8  loess.fut:608:5-610:29\n   #9  loess.fut:573:1-612:26\n");
            if (memblock_unref(ctx, &ext_mem_71635, "ext_mem_71635") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
                return 1;
            err = 1;
            goto cleanup;
        }
        
        int64_t y_66671 = sub64(n_m_65386, (int64_t) 1);
        struct memblock mem_71634;
        
        mem_71634.references = NULL;
        if (memblock_alloc(ctx, &mem_71634, bytes_71633, "mem_71634")) {
            err = 1;
            goto cleanup;
        }
        
        int64_t binop_y_71613 = (int64_t) 8 * n_65378;
        int64_t bytes_71614 = smax64((int64_t) 0, binop_y_71613);
        int64_t flat_tid_70075 = (int64_t) 0;
        int32_t num_tasks_76946;
        int64_t flat_tid_70081 = (int64_t) 0;
        struct futhark_mc_task_77436 futhark_mc_task_77436;
        
        futhark_mc_task_77436.ctx = ctx;
        futhark_mc_task_77436.free_m_65377 = m_65377;
        futhark_mc_task_77436.free_n_65378 = n_65378;
        futhark_mc_task_77436.free_jump_65382 = jump_65382;
        futhark_mc_task_77436.free_n_m_65386 = n_m_65386;
        futhark_mc_task_77436.free_i_65392 = i_65392;
        futhark_mc_task_77436.free_y_66671 = y_66671;
        futhark_mc_task_77436.free_ext_mem_71611 = ext_mem_71611.mem;
        futhark_mc_task_77436.free_ext_mem_71612 = ext_mem_71612.mem;
        futhark_mc_task_77436.free_bytes_71614 = bytes_71614;
        futhark_mc_task_77436.free_mem_71634 = mem_71634.mem;
        
        struct scheduler_segop futhark_mc_task_77436_task;
        
        futhark_mc_task_77436_task.args = &futhark_mc_task_77436;
        futhark_mc_task_77436_task.top_level_fn = futhark_mc_segmap_task_77437;
        futhark_mc_task_77436_task.name = "futhark_mc_segmap_task_77437";
        futhark_mc_task_77436_task.iterations = m_65377;
        futhark_mc_task_77436_task.task_time =
            &ctx->futhark_mc_segmap_task_77437_total_time;
        futhark_mc_task_77436_task.task_iter =
            &ctx->futhark_mc_segmap_task_77437_total_iter;
        futhark_mc_task_77436_task.sched = STATIC;
        futhark_mc_task_77436_task.nested_fn =
            futhark_mc_segmap_nested_task_77441;
        
        int futhark_mc_segmap_task_77437_err =
            scheduler_prepare_task(&ctx->scheduler,
                                   &futhark_mc_task_77436_task);
        
        if (futhark_mc_segmap_task_77437_err != 0) {
            if (memblock_unref(ctx, &mem_71634, "mem_71634") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71635, "ext_mem_71635") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
                return 1;
            ;
            err = 1;
            goto cleanup;
        }
        if (memblock_set(ctx, &ext_mem_71635, &mem_71634, "mem_71634") != 0)
            return 1;
        if (memblock_unref(ctx, &mem_71634, "mem_71634") != 0)
            return 1;
    } else {
        bool dim_match_66723 = n_65378 == n_m_65386;
        bool empty_or_match_cert_66724;
        
        if (!dim_match_66723) {
            ctx->error =
                msgprintf("Error: %s%lld%s%lld%s%lld%s%lld%s\n\nBacktrace:\n%s",
                          "Value of (core language) shape (",
                          (long long) m_65377, ", ", (long long) n_m_65386,
                          ") cannot match shape of type `[",
                          (long long) m_65377, "][", (long long) n_65378,
                          "]f64`.",
                          "-> #0  loess.fut:612:5-26\n   #1  loess.fut:573:1-612:26\n");
            if (memblock_unref(ctx, &ext_mem_71635, "ext_mem_71635") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
                return 1;
            if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
                return 1;
            if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
                return 1;
            err = 1;
            goto cleanup;
        }
        if (memblock_set(ctx, &ext_mem_71635, &ext_mem_71612,
                         "ext_mem_71612") != 0)
            return 1;
    }
    if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
        return 1;
    if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
        return 1;
    
    struct memblock mem_71640;
    
    mem_71640.references = NULL;
    if (memblock_alloc(ctx, &mem_71640, bytes_71633, "mem_71640")) {
        err = 1;
        goto cleanup;
    }
    if (m_65377 * n_65378 * (int64_t) 8 > 0)
        memmove(mem_71640.mem + (int64_t) 0, ext_mem_71635.mem + (int64_t) 0,
                m_65377 * n_65378 * (int64_t) 8);
    if (memblock_unref(ctx, &ext_mem_71635, "ext_mem_71635") != 0)
        return 1;
    if (memblock_set(ctx, &mem_out_71652, &mem_71640, "mem_71640") != 0)
        return 1;
    (*mem_out_p_77056).references = NULL;
    if (memblock_set(ctx, &*mem_out_p_77056, &mem_out_71652, "mem_out_71652") !=
        0)
        return 1;
    if (memblock_unref(ctx, &mem_71640, "mem_71640") != 0)
        return 1;
    if (memblock_unref(ctx, &ext_mem_71635, "ext_mem_71635") != 0)
        return 1;
    if (memblock_unref(ctx, &ext_mem_71611, "ext_mem_71611") != 0)
        return 1;
    if (memblock_unref(ctx, &ext_mem_71612, "ext_mem_71612") != 0)
        return 1;
    if (memblock_unref(ctx, &mem_out_71652, "mem_out_71652") != 0)
        return 1;
    
  cleanup:
    { }
    return err;
}

int futhark_entry_main(struct futhark_context *ctx,
                       struct futhark_f64_2d **out0, const
                       struct futhark_f64_2d *in0, const int64_t in1, const
                       int64_t in2, const int64_t in3, const int64_t in4, const
                       int64_t in5)
{
    struct memblock Y_mem_70603;
    
    Y_mem_70603.references = NULL;
    
    int64_t m_65377;
    int64_t n_65378;
    int64_t q_65380;
    int64_t degree_65381;
    int64_t jump_65382;
    int64_t jump_threshold_65383;
    int64_t q_threshold_65384;
    struct memblock mem_out_71652;
    
    mem_out_71652.references = NULL;
    
    int ret = 0;
    
    lock_lock(&ctx->lock);
    worker_local = &ctx->scheduler.workers[0];
    Y_mem_70603 = in0->mem;
    m_65377 = in0->shape[0];
    n_65378 = in0->shape[1];
    q_65380 = in1;
    degree_65381 = in2;
    jump_65382 = in3;
    jump_threshold_65383 = in4;
    q_threshold_65384 = in5;
    if (!(m_65377 == in0->shape[0] && n_65378 == in0->shape[1])) {
        ret = 1;
        if (!ctx->error)
            ctx->error =
                msgprintf("Error: entry point arguments have invalid sizes.\n");
    }
    if (ret == 0) {
        ret = futrts_entry_main(ctx, &mem_out_71652, Y_mem_70603, m_65377,
                                n_65378, q_65380, degree_65381, jump_65382,
                                jump_threshold_65383, q_threshold_65384);
        if (ret == 0) {
            assert((*out0 =
                    (struct futhark_f64_2d *) malloc(sizeof(struct futhark_f64_2d))) !=
                NULL);
            (*out0)->mem = mem_out_71652;
            (*out0)->shape[0] = m_65377;
            (*out0)->shape[1] = n_65378;
        }
    }
    lock_unlock(&ctx->lock);
    return ret;
}
  
