<commit_before>void* malloc(unsigned long);
uint64_t  pthread_create();
uint64_t  pthread_join(uint64_t* wstatus);

uint64_t sumChilds(uint64_t pid, uint64_t acc) {
  uint64_t* s;

  s = malloc(8);

  if (pid) {
    // this is the parent process/thread
    // => accumulate pid from pthread_create call, pid from pthread_join call and exit status code
    acc = acc + pid + pthread_join(s);
    acc = acc + *s;
  }

  return acc;
}

int main(int argc, char** argv) {
  uint64_t pid1;
  uint64_t pid2;
  uint64_t pid3;
  uint64_t result;

  // 2^3 processes
  pid1 = pthread_create();
  pid2 = pthread_create();
  pid3 = pthread_create();

  // do not wait for child-threads of the parent-process
  if (pid3 == 0)
    pid2 = 0;
  if (pid2 == 0)
    pid1 = 0;

  result = sumChilds(pid3, sumChilds(pid2, sumChilds(pid1, 0)));

  if (pid1 != 0)
    if (pid2 != 0)
      if (pid3 != 0)
        return result;

  pthread_exit(result);
}<commit_msg>Fix race condition in thread assignment<commit_after>void* malloc(unsigned long);
uint64_t  pthread_create();
uint64_t  pthread_join(uint64_t* wstatus);

uint64_t* status;

uint64_t sumChilds(uint64_t own_pid, uint64_t pid, uint64_t acc) {
  if (pid) {
    // this is the parent process/thread
    // => accumulate pid from pthread_create call, pid from pthread_join call and exit status code
    acc = acc + pid + pthread_join(status + own_pid - 1);
    acc = acc + *(status + own_pid - 1);
  }

  return acc;
}

uint64_t get_own_pid(uint64_t pid1, uint64_t pid2, uint64_t pid3) {
  uint64_t pid;

  pid = 0;

  if (pid1 != 0)
    pid = pid + 1;
  pid = pid * 2;
  if (pid2 != 0)
    pid = pid + 1;
  pid = pid * 2;
  if (pid3 != 0)
    pid = pid + 1;

  return 8 - pid;
} 

int main(int argc, char** argv) {
  uint64_t own_pid;
  uint64_t pid1;
  uint64_t pid2;
  uint64_t pid3;
  uint64_t result;

  status = malloc(8 * 8);

  // 2^3 processes
  pid1 = pthread_create();
  pid2 = pthread_create();
  pid3 = pthread_create();

  own_pid = get_own_pid(pid1, pid2, pid3);

  // do not wait for child-threads of the parent-process
  if (pid3 == 0)
    pid2 = 0;
  if (pid2 == 0)
    pid1 = 0;

  result = sumChilds(own_pid, pid3, sumChilds(own_pid, pid2, sumChilds(own_pid, pid1, 0)));

  if (pid1 != 0)
    if (pid2 != 0)
      if (pid3 != 0)
        return result;

  pthread_exit(result);
}
{'fraction_non_alphanumeric': 0.12419700214132762, 'fraction_numerical': 0.05738758029978587, 'mean_word_length': 2.986348122866894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6798089', 'n_tokens_mistral': 1005, 'n_tokens_neox': 917, 'n_words': 263}