diff --git a/.gitignore b/.gitignore
index 003665ac33a3e76c47b5cb59f8c89201e5c010b1..3cc0d2a9c1cbd8a056acecd434337d4402133def 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
 config.status
 lia.cache
 
+frama_c_journal.ml
 running
 command
 parse.log
diff --git a/cgc-challenges/chess_mimic/.frama-c/GNUmakefile b/cgc-challenges/chess_mimic/.frama-c/GNUmakefile
new file mode 100644
index 0000000000000000000000000000000000000000..49a38af9970c20ee0be05e33829c1f9ccdc7ca02
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/GNUmakefile
@@ -0,0 +1,50 @@
+# Makefile template for Frama-C/Eva case studies.
+# For details and usage information, see the Frama-C User Manual.
+
+### Prologue. Do not modify this block. #######################################
+-include path.mk
+FRAMAC ?= frama-c
+include $(shell $(FRAMAC)-config -scripts)/prologue.mk
+###############################################################################
+
+# Edit below as needed. MACHDEP is mandatory. Suggested flags are optional.
+
+MACHDEP = x86_32
+
+## Preprocessing flags (for -cpp-extra-args)
+CPPFLAGS    += \
+  -DPATCHED \
+  -D__FC_PATCHED \
+  -I../../lib \
+  -I../lib \
+  -I../include \
+
+
+## General flags
+FCFLAGS     += \
+  -add-symbolic-path=..:. \
+  -kernel-warn-key annot:missing-spec=abort \
+  -kernel-warn-key typing:implicit-function-declaration=abort \
+  -absolute-valid-range 0x4347C000-0x4347FFFF \
+  -c11 \
+
+## Eva-specific flags
+EVAFLAGS    += \
+  -eva-precision 8 \
+  -eva-warn-key builtins:missing-spec=abort \
+
+## GUI-only flags
+FCGUIFLAGS += \
+
+## Analysis targets (suffixed with .eva)
+TARGETS = chess_mimic.eva
+
+### Each target <t>.eva needs a rule <t>.parse with source files as prerequisites
+chess_mimic.parse: \
+  ../../lib/common.c \
+  ../../lib/libcgc.c \
+  ../src/service.c \
+
+### Epilogue. Do not modify this block. #######################################
+include $(shell $(FRAMAC)-config -scripts)/epilogue.mk
+###############################################################################
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/alarms.csv b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/alarms.csv
new file mode 100644
index 0000000000000000000000000000000000000000..a3b064a7a6e46f3134f736999ea3296df031ab4f
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/alarms.csv
@@ -0,0 +1,61 @@
+directory	file	line	function	property kind	status	property
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	129	cgc_getPiece	initialization	Unknown	\initialized(&loc.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	129	cgc_getPiece	initialization	Unknown	\initialized(&loc.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	129	cgc_getPiece	index_bound	Unknown	0 ≤ loc.x
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	129	cgc_getPiece	index_bound	Unknown	loc.x < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	129	cgc_getPiece	index_bound	Unknown	0 ≤ loc.y
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	129	cgc_getPiece	index_bound	Unknown	loc.y < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	164	cgc_checkNoCollision	initialization	Unknown	\initialized(&move.dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	164	cgc_checkNoCollision	initialization	Unknown	\initialized(&move.src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	166	cgc_checkNoCollision	initialization	Unknown	\initialized(&move.dst.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	166	cgc_checkNoCollision	initialization	Unknown	\initialized(&move.src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	198	cgc_checkNoCollision	initialization	Unknown	\initialized(&move.dst.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	198	cgc_checkNoCollision	initialization	Unknown	\initialized(&move.src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	239	cgc_checkNoCollision	initialization	Unknown	\initialized(&dst.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	239	cgc_checkNoCollision	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	239	cgc_checkNoCollision	initialization	Unknown	\initialized(&dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	239	cgc_checkNoCollision	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	241	cgc_checkNoCollision	index_bound	Unknown	square_cnt < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	244	cgc_checkNoCollision	initialization	Unknown	\initialized(&dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	244	cgc_checkNoCollision	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	246	cgc_checkNoCollision	index_bound	Unknown	square_cnt < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	249	cgc_checkNoCollision	initialization	Unknown	\initialized(&dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	249	cgc_checkNoCollision	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	251	cgc_checkNoCollision	index_bound	Unknown	square_cnt < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	254	cgc_checkNoCollision	initialization	Unknown	\initialized(&dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	254	cgc_checkNoCollision	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	256	cgc_checkNoCollision	index_bound	Unknown	square_cnt < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	272	cgc_checkNoCollision	initialization	Unknown	\initialized(&squares[i_4][0])
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	272	cgc_checkNoCollision	initialization	Unknown	\initialized(&squares[i_4][1])
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	352	cgc_performMove	initialization	Unknown	\initialized(&dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	352	cgc_performMove	initialization	Unknown	\initialized(&dst.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	360	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	360	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	373	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	373	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	389	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	391	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	400	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	417	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	419	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	428	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	444	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	445	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	457	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	459	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	480	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	481	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	497	cgc_performMove	initialization	Unknown	\initialized(&src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	497	cgc_performMove	initialization	Unknown	\initialized(&src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	515	cgc_swap	initialization	Unknown	\initialized(&move.dst.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	515	cgc_swap	initialization	Unknown	\initialized(&move.dst.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	515	cgc_swap	index_bound	Unknown	move.dst.x < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	515	cgc_swap	index_bound	Unknown	move.dst.y < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	516	cgc_swap	initialization	Unknown	\initialized(&move.src.x)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	516	cgc_swap	initialization	Unknown	\initialized(&move.src.y)
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	516	cgc_swap	index_bound	Unknown	move.src.x < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	516	cgc_swap	index_bound	Unknown	move.src.y < 8
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	609	cgc_parseUserInput	user assertion	Unknown	0 ≤ tmp.src.x ≤ 9
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	615	cgc_parseUserInput	user assertion	Unknown	0 ≤ tmp.src.y ≤ 9
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	621	cgc_parseUserInput	user assertion	Unknown	0 ≤ tmp.dst.x ≤ 9
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src	service.c	627	cgc_parseUserInput	user assertion	Unknown	0 ≤ tmp.dst.y ≤ 9
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/metrics.log b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/metrics.log
new file mode 100644
index 0000000000000000000000000000000000000000..aa98484ef54355d70a25d76befc824705ef9bdfe
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/metrics.log
@@ -0,0 +1,23 @@
+[metrics] Eva coverage statistics
+=======================
+Syntactically reachable functions = 13 (out of 27)
+Semantically reached functions = 13
+Coverage estimation = 100.0%
+[metrics] References to non-analyzed functions
+------------------------------------
+[metrics] Statements analyzed by Eva
+--------------------------
+599 stmts in analyzed functions, 582 stmts analyzed (97.2%)
+cgc_checkNoCollision: 159 stmts out of 159 (100.0%)
+cgc_displayboard: 16 stmts out of 16 (100.0%)
+cgc_getColor: 12 stmts out of 12 (100.0%)
+cgc_getPiece: 2 stmts out of 2 (100.0%)
+cgc_initboard: 47 stmts out of 47 (100.0%)
+cgc_receive: 9 stmts out of 9 (100.0%)
+cgc_swap: 4 stmts out of 4 (100.0%)
+cgc_verifyFormat: 17 stmts out of 17 (100.0%)
+cgc_performMove: 213 stmts out of 219 (97.3%)
+main: 28 stmts out of 30 (93.3%)
+cgc_parseUserInput: 66 stmts out of 73 (90.4%)
+cgc_transmit: 8 stmts out of 9 (88.9%)
+cgc__terminate: 1 stmts out of 2 (50.0%)
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/nonterm.log b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/nonterm.log
new file mode 100644
index 0000000000000000000000000000000000000000..a3e898a73a447efadb936afee74a2d0e0ebbaf74
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/nonterm.log
@@ -0,0 +1,3 @@
+/home/dario/git/open-source-case-studies/cgc-challenges/lib/libcgc.c:24:[nonterm] warning: unreachable implicit return
+/home/dario/git/open-source-case-studies/cgc-challenges/chess_mimic/src/service.c:660:[nonterm] warning: non-terminating loop
+stack: main
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/warnings.log b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.eva/warnings.log
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/framac.ast b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/framac.ast
new file mode 100644
index 0000000000000000000000000000000000000000..f035c44917db3338c254f384f7d94488d4920135
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/framac.ast
@@ -0,0 +1,1268 @@
+/* Generated by Frama-C */
+#include "ctype.h"
+#include "errno.h"
+#include "fcntl.h"
+#include "math.h"
+#include "signal.h"
+#include "stdarg.h"
+#include "stddef.h"
+#include "stdint.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+#include "strings.h"
+#include "sys/mman.h"
+#include "sys/select.h"
+#include "sys/time.h"
+#include "sys/types.h"
+#include "unistd.h"
+struct cgc_aes_state {
+   uint8_t vec[16]  __attribute__((__aligned__(1)));
+   uint8_t key[16]  __attribute__((__aligned__(1)));
+   uint8_t datetime[16]  __attribute__((__aligned__(1)));
+} __attribute__((__packed__, __aligned__(1)));
+typedef struct cgc_aes_state cgc_aes_state;
+struct cgc_prng {
+   cgc_aes_state state ;
+   uint8_t intermediate[16] ;
+   uint8_t random_data[16] ;
+   uint8_t random_idx ;
+};
+typedef struct cgc_prng cgc_prng_0;
+struct Location {
+   int x ;
+   int y ;
+};
+typedef struct Location Location;
+struct Move {
+   Location src ;
+   Location dst ;
+};
+typedef struct Move Move;
+int receive_bytes_iPcz(char *buffer, size_t count);
+
+int __prng_state;
+/*@ assigns __prng_state;
+    assigns __prng_state \from seedValue; */
+void seed_prng(uint32_t seedValue);
+
+/*@ assigns \result, __prng_state;
+    assigns \result \from __prng_state;
+    assigns __prng_state \from __prng_state;
+ */
+uint32_t cgc_prng(void);
+
+ __attribute__((__noreturn__)) void cgc__terminate(unsigned int status);
+
+int cgc_transmit(int fd, void const *buf, size_t count, size_t *tx_bytes);
+
+int cgc_receive(int fd, void *buf, size_t count, size_t *rx_bytes);
+
+int cgc_fdwait(int nfds, fd_set *readfds, fd_set *writefds,
+               struct timeval const *timeout, int *readyfds);
+
+int cgc_allocate(size_t length, int is_executable, void **addr);
+
+int cgc_deallocate(void *addr, size_t length);
+
+int cgc_random(void *buf, size_t count, size_t *rnd_bytes);
+
+int receive_bytes_iPcz(char *buffer, size_t count)
+{
+  int __retres;
+  size_t total;
+  size_t rxbytes;
+  total = (unsigned int)0;
+  while (total < count) {
+    int tmp;
+    rxbytes = (unsigned int)0;
+    tmp = cgc_receive(0,(void *)(buffer + total),count - total,& rxbytes);
+    if (tmp == 0) 
+      if (rxbytes == (size_t)0) {
+        __retres = 0;
+        goto return_label;
+      }
+      else total += rxbytes;
+    else {
+      __retres = -1;
+      goto return_label;
+    }
+  }
+  __retres = 0;
+  return_label: return __retres;
+}
+
+int cgc_check_timeout(struct timeval const *timeout)
+{
+  int __retres;
+  if (! timeout) {
+    __retres = 0;
+    goto return_label;
+  }
+  else 
+    if ((time_t)0 > timeout->tv_sec) goto _LOR;
+    else 
+      if (0 > timeout->tv_usec) {
+        _LOR: {
+                __retres = 22;
+                goto return_label;
+              }
+      }
+      else {
+        __retres = 0;
+        goto return_label;
+      }
+  return_label: return __retres;
+}
+
+void cgc_init_prng(cgc_prng_0 *, cgc_aes_state const *);
+
+void cgc_aes_get_bytes(cgc_prng_0 *, uint32_t, uint8_t *);
+
+ __attribute__((__noreturn__)) void cgc__terminate(unsigned int status);
+void cgc__terminate(unsigned int status)
+{
+  exit((int)status);
+  return;
+}
+
+int cgc_transmit(int fd, void const *buf, size_t count, size_t *tx_bytes)
+{
+  int __retres;
+  ssize_t const ret = write(fd,buf,count);
+  if (ret < 0) {
+    __retres = __fc_errno;
+    goto return_label;
+  }
+  else 
+    if (tx_bytes != (size_t *)0) *tx_bytes = (unsigned int)ret;
+  __retres = 0;
+  return_label: return __retres;
+}
+
+int cgc_receive(int fd, void *buf, size_t count, size_t *rx_bytes)
+{
+  int __retres;
+  ssize_t const ret = read(fd,buf,count);
+  if (ret < 0) {
+    __retres = __fc_errno;
+    goto return_label;
+  }
+  else 
+    if (rx_bytes != (size_t *)0) *rx_bytes = (unsigned int)ret;
+  __retres = 0;
+  return_label: return __retres;
+}
+
+static int cgc_copy_cgc_fd_set(fd_set const *cgc_fds, fd_set *os_fds,
+                               int *num_fds)
+{
+  int __retres;
+  {
+    unsigned int fd = (unsigned int)0;
+    while (fd < (unsigned int)8 * sizeof(long)) {
+      {
+        int tmp;
+        tmp = FD_ISSET((int)fd,cgc_fds);
+        if (tmp) {
+          if (fd >= (unsigned int)(3 + 2 * 10)) {
+            __retres = 9;
+            goto return_label;
+          }
+          if (fd > (unsigned int)8 * sizeof(long)) goto __Cont;
+          FD_SET((int)fd,os_fds);
+          (*num_fds) ++;
+        }
+      }
+      __Cont: fd ++;
+    }
+  }
+  __retres = 0;
+  return_label: return __retres;
+}
+
+static void cgc_copy_os_fd_set(fd_set const *os_fds, fd_set *cgc_fds)
+{
+  unsigned int fd = (unsigned int)0;
+  while (1) {
+    unsigned int tmp_0;
+    if ((unsigned int)8 * sizeof(long) < (unsigned int)8 * sizeof(long)) 
+      tmp_0 = (unsigned int)8 * sizeof(long);
+    else tmp_0 = (unsigned int)8 * sizeof(long);
+    ;
+    if (! (fd < tmp_0)) break;
+    {
+      int tmp;
+      tmp = FD_ISSET((int)fd,os_fds);
+      if (tmp) FD_SET((int)fd,cgc_fds);
+    }
+    fd ++;
+  }
+  return;
+}
+
+int cgc_fdwait(int nfds, fd_set *readfds, fd_set *writefds,
+               struct timeval const *timeout, int *readyfds)
+{
+  int __retres;
+  fd_set read_fds;
+  fd_set write_fds;
+  int tmp_3;
+  struct timeval *tmp_0;
+  fd_set *tmp_1;
+  fd_set *tmp_2;
+  int ret = cgc_check_timeout(timeout);
+  int actual_num_fds = 0;
+  struct timeval max_wait_time = {.tv_sec = (long)0, .tv_usec = 0};
+  if (ret) {
+    __retres = ret;
+    goto return_label;
+  }
+  else 
+    if (0 > nfds) goto _LOR;
+    else 
+      if ((unsigned int)8 * sizeof(long) < (unsigned int)nfds) {
+        _LOR: {
+                __retres = 22;
+                goto return_label;
+              }
+      }
+  FD_ZERO(& read_fds);
+  FD_ZERO(& write_fds);
+  if (readfds) {
+    ret = cgc_copy_cgc_fd_set((fd_set const *)readfds,& read_fds,
+                              & actual_num_fds);
+    if (0 != ret) {
+      __retres = ret;
+      goto return_label;
+    }
+  }
+  if (writefds) {
+    ret = cgc_copy_cgc_fd_set((fd_set const *)writefds,& write_fds,
+                              & actual_num_fds);
+    if (0 != ret) {
+      __retres = ret;
+      goto return_label;
+    }
+  }
+  if (actual_num_fds != nfds) {
+    __retres = 22;
+    goto return_label;
+  }
+  if (readfds) FD_ZERO(readfds);
+  if (writefds) FD_ZERO(writefds);
+  if (timeout) {
+    max_wait_time.tv_sec = timeout->tv_sec;
+    max_wait_time.tv_usec = timeout->tv_usec;
+  }
+  if (timeout) tmp_0 = & max_wait_time; else tmp_0 = (struct timeval *)0;
+  if (writefds) tmp_1 = & write_fds; else tmp_1 = (fd_set *)0;
+  if (readfds) tmp_2 = & read_fds; else tmp_2 = (fd_set *)0;
+  ;
+  tmp_3 = select(nfds,tmp_2,tmp_1,(fd_set *)0,tmp_0);
+  int num_selected_fds = tmp_3;
+  if (num_selected_fds < 0) {
+    __retres = __fc_errno;
+    goto return_label;
+  }
+  if (readfds) cgc_copy_os_fd_set((fd_set const *)(& read_fds),readfds);
+  if (writefds) cgc_copy_os_fd_set((fd_set const *)(& write_fds),writefds);
+  if (readyfds) *readyfds = num_selected_fds;
+  __retres = 0;
+  return_label: return __retres;
+}
+
+int cgc_allocate(size_t length, int is_executable, void **addr)
+{
+  int __retres;
+  int page_perms = 0x1 | 0x2;
+  if (is_executable) page_perms |= 0x4;
+  void *return_address =
+    mmap((void *)0,length,page_perms,0x20 | 0x02,-1,(long)0);
+  if (return_address == (void *)(-1)) {
+    __retres = __fc_errno;
+    goto return_label;
+  }
+  if (addr) *addr = return_address;
+  memset(return_address,0,length);
+  __retres = 0;
+  return_label: return __retres;
+}
+
+int cgc_deallocate(void *addr, size_t length)
+{
+  int __retres;
+  int const ret = munmap(addr,length);
+  if (ret < 0) {
+    __retres = __fc_errno;
+    goto return_label;
+  }
+  __retres = 0;
+  return_label: return __retres;
+}
+
+static cgc_prng_0 *cgc_internal_prng = (cgc_prng_0 *)0;
+/*@ requires valid_read_string(s);
+    requires valid_read_string(format);
+    requires \valid(param0);
+    ensures \initialized(param0);
+    assigns \result, *param0;
+    assigns \result
+      \from (indirect: *(s + (0 ..))), (indirect: *(format + (0 ..)));
+    assigns *param0
+      \from (indirect: *(s + (0 ..))), (indirect: *(format + (0 ..)));
+ */
+int sscanf_va_1(char const * __restrict s, char const * __restrict format,
+                unsigned char *param0);
+
+static void cgc_try_init_prng(void)
+{
+  if (cgc_internal_prng != (cgc_prng_0 *)0) goto return_label;
+  uint8_t prng_seed[16 * 3] =
+    {(unsigned char)0x73,
+     (unsigned char)0x65,
+     (unsigned char)0x65,
+     (unsigned char)0x64,
+     (unsigned char)0x73,
+     (unsigned char)0x65,
+     (unsigned char)0x65,
+     (unsigned char)0x64,
+     (unsigned char)0x73,
+     (unsigned char)0x65,
+     (unsigned char)0x65,
+     (unsigned char)0x64,
+     (unsigned char)0x73,
+     (unsigned char)0x65,
+     (unsigned char)0x65,
+     (unsigned char)0x64,
+     (unsigned char)0x30,
+     (unsigned char)0x31,
+     (unsigned char)0x32,
+     (unsigned char)0x33,
+     (unsigned char)0x34,
+     (unsigned char)0x35,
+     (unsigned char)0x36,
+     (unsigned char)0x37,
+     (unsigned char)0x38,
+     (unsigned char)0x39,
+     (unsigned char)0x61,
+     (unsigned char)0x62,
+     (unsigned char)0x63,
+     (unsigned char)0x64,
+     (unsigned char)0x65,
+     (unsigned char)0x66,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00,
+     (unsigned char)0x00};
+  char const *prng_seed_hex = getenv("seed");
+  if (prng_seed_hex != (char const *)0) {
+    size_t tmp_0;
+    tmp_0 = strlen(prng_seed_hex);
+    if (tmp_0 == (size_t)((16 * 3) * 2)) {
+      char const *pos = prng_seed_hex;
+      {
+        int i = 0;
+        while (i < 16 * 3) {
+          sscanf_va_1(pos,"%2hhx",(unsigned char *)(& prng_seed[i]));
+          pos += 2;
+          i ++;
+        }
+      }
+    }
+  }
+  cgc_internal_prng = (cgc_prng_0 *)malloc(sizeof(cgc_prng_0));
+  cgc_aes_state *seed = (cgc_aes_state *)(prng_seed);
+  cgc_init_prng(cgc_internal_prng,(cgc_aes_state const *)seed);
+  return_label: return;
+}
+
+int cgc_random(void *buf, size_t count, size_t *rnd_bytes)
+{
+  int __retres;
+  cgc_try_init_prng();
+  cgc_aes_get_bytes(cgc_internal_prng,count,(uint8_t *)buf);
+  if (rnd_bytes) *rnd_bytes = count;
+  __retres = 0;
+  return __retres;
+}
+
+/*@ assigns \nothing; */
+static void cgc_initialize_flag_page(void) __attribute__((__constructor__));
+
+void cgc_initboard(void);
+
+void cgc_swap(Move move);
+
+int cgc_parseUserInput(Move *movers);
+
+char (*ptr_array)[8][8];
+char current_team = (char)1;
+int cgc_getColor(char piece)
+{
+  int __retres;
+  if ((int)piece <= 'f') 
+    if ((int)piece >= 'a') {
+      __retres = 1;
+      goto return_label;
+    }
+  if ((int)piece <= 'l') 
+    if ((int)piece >= 'g') {
+      __retres = 0;
+      goto return_label;
+    }
+  __retres = '.';
+  return_label: return __retres;
+}
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_1(char const * __restrict format);
+
+void cgc_displayboard(void)
+{
+  int i = 8 - 1;
+  while (i >= 0) {
+    {
+      int j = 0;
+      while (j < 8) {
+        cgc_transmit(0,(void const *)(& (*ptr_array)[j][i]),(unsigned int)1,
+                     (size_t *)0);
+        j ++;
+      }
+    }
+    printf_va_1("\n");
+    i --;
+  }
+  return;
+}
+
+void cgc_initboard(void)
+{
+  {
+    int i = 0;
+    while (i < 8) {
+      {
+        int j = 0;
+        while (j < 8) {
+          (*ptr_array)[i][j] = (char)'.';
+          j ++;
+        }
+      }
+      i ++;
+    }
+  }
+  (*ptr_array)[0][0] = (char)'d';
+  (*ptr_array)[1][0] = (char)'b';
+  (*ptr_array)[2][0] = (char)'c';
+  (*ptr_array)[3][0] = (char)'f';
+  (*ptr_array)[4][0] = (char)'e';
+  (*ptr_array)[5][0] = (char)'c';
+  (*ptr_array)[6][0] = (char)'b';
+  (*ptr_array)[7][0] = (char)'d';
+  (*ptr_array)[0][1] = (char)'a';
+  (*ptr_array)[1][1] = (char)'a';
+  (*ptr_array)[2][1] = (char)'a';
+  (*ptr_array)[3][1] = (char)'a';
+  (*ptr_array)[4][1] = (char)'a';
+  (*ptr_array)[5][1] = (char)'a';
+  (*ptr_array)[6][1] = (char)'a';
+  (*ptr_array)[7][1] = (char)'a';
+  (*ptr_array)[0][6] = (char)'g';
+  (*ptr_array)[1][6] = (char)'g';
+  (*ptr_array)[2][6] = (char)'g';
+  (*ptr_array)[3][6] = (char)'g';
+  (*ptr_array)[4][6] = (char)'g';
+  (*ptr_array)[5][6] = (char)'g';
+  (*ptr_array)[6][6] = (char)'g';
+  (*ptr_array)[7][6] = (char)'g';
+  (*ptr_array)[0][7] = (char)'j';
+  (*ptr_array)[1][7] = (char)'h';
+  (*ptr_array)[2][7] = (char)'i';
+  (*ptr_array)[3][7] = (char)'l';
+  (*ptr_array)[4][7] = (char)'k';
+  (*ptr_array)[5][7] = (char)'i';
+  (*ptr_array)[6][7] = (char)'h';
+  (*ptr_array)[7][7] = (char)'j';
+  return;
+}
+
+char cgc_getPiece(Location loc)
+{
+  char __retres;
+  __retres = (*ptr_array)[loc.x][loc.y];
+  return __retres;
+}
+
+int cgc_checkNoCollision(Move move)
+{
+  int __retres;
+  int squares[8][2];
+  int tmp_3;
+  int tmp_6;
+  Location src = move.src;
+  Location dst = move.dst;
+  int square_cnt = 0;
+  char piece = cgc_getPiece(move.src);
+  if ((int)piece == 'b') goto _LOR;
+  else 
+    if ((int)piece == 'h') {
+      _LOR:
+      {
+        int tmp_0;
+        int tmp_2;
+        char tmp_1;
+        tmp_0 = cgc_getColor(piece);
+        tmp_1 = cgc_getPiece(dst);
+        tmp_2 = cgc_getColor(tmp_1);
+        if (tmp_0 != tmp_2) {
+          __retres = 1;
+          goto return_label;
+        }
+        else {
+          __retres = 0;
+          goto return_label;
+        }
+      }
+    }
+  tmp_3 = cgc_getColor(piece);
+  if (tmp_3 == 1) {
+    int tmp_5;
+    char tmp_4;
+    tmp_4 = cgc_getPiece(move.dst);
+    tmp_5 = cgc_getColor(tmp_4);
+    if (tmp_5 == 1) {
+      __retres = 0;
+      goto return_label;
+    }
+  }
+  tmp_6 = cgc_getColor(piece);
+  if (tmp_6 == 0) {
+    int tmp_8;
+    char tmp_7;
+    tmp_7 = cgc_getPiece(move.dst);
+    tmp_8 = cgc_getColor(tmp_7);
+    if (tmp_8 == 0) {
+      __retres = 0;
+      goto return_label;
+    }
+  }
+  if (move.src.x == move.dst.x) 
+    if (move.src.y < move.dst.y) {
+      int i = move.src.y + 1;
+      while (i <= move.dst.y) {
+        if (square_cnt < 8) {
+          int tmp_9;
+          squares[square_cnt][0] = move.src.x;
+          tmp_9 = square_cnt;
+          square_cnt ++;
+          squares[tmp_9][1] = i;
+        }
+        i ++;
+      }
+    }
+    else {
+      int i_0 = move.src.y - 1;
+      while (i_0 >= move.dst.y) {
+        if (square_cnt < 8) {
+          int tmp_10;
+          squares[square_cnt][0] = move.src.x;
+          tmp_10 = square_cnt;
+          square_cnt ++;
+          squares[tmp_10][1] = i_0;
+        }
+        i_0 --;
+      }
+    }
+  else 
+    if (move.src.y == move.dst.y) 
+      if (move.src.x < move.dst.x) {
+        int i_1 = move.src.x + 1;
+        while (i_1 <= move.dst.x) {
+          if (square_cnt < 8) {
+            int tmp_11;
+            squares[square_cnt][0] = i_1;
+            tmp_11 = square_cnt;
+            square_cnt ++;
+            squares[tmp_11][1] = move.src.y;
+          }
+          i_1 ++;
+        }
+      }
+      else {
+        int i_2 = move.src.x - 1;
+        while (i_2 >= move.dst.x) {
+          if (square_cnt < 8) {
+            int tmp_12;
+            squares[square_cnt][0] = i_2;
+            tmp_12 = square_cnt;
+            square_cnt ++;
+            squares[tmp_12][1] = move.src.y;
+          }
+          i_2 --;
+        }
+      }
+    else {
+      int tmp_18;
+      int num = abs(move.dst.x - move.src.x);
+      tmp_18 = abs(move.dst.y - move.src.y);
+      ;
+      if (num == tmp_18) {
+        int i_3 = 1;
+        while (i_3 <= num) {
+          if (dst.y > src.y) {
+            if (dst.x > src.x) {
+              int tmp_14;
+              squares[square_cnt][0] = src.x + i_3;
+              tmp_14 = square_cnt;
+              square_cnt ++;
+              squares[tmp_14][1] = src.y + i_3;
+            }
+            else goto _LAND_1;
+          }
+          else {
+            _LAND_1: ;
+            if (dst.y > src.y) {
+              if (dst.x < src.x) {
+                int tmp_15;
+                squares[square_cnt][0] = src.x - i_3;
+                tmp_15 = square_cnt;
+                square_cnt ++;
+                squares[tmp_15][1] = src.y + i_3;
+              }
+              else goto _LAND_0;
+            }
+            else {
+              _LAND_0: ;
+              if (dst.y < src.y) {
+                if (dst.x > src.x) {
+                  int tmp_16;
+                  squares[square_cnt][0] = src.x + i_3;
+                  tmp_16 = square_cnt;
+                  square_cnt ++;
+                  squares[tmp_16][1] = src.y - i_3;
+                }
+                else goto _LAND;
+              }
+              else {
+                _LAND: ;
+                if (dst.y < src.y) 
+                  if (dst.x < src.x) {
+                    int tmp_17;
+                    squares[square_cnt][0] = src.x - i_3;
+                    tmp_17 = square_cnt;
+                    square_cnt ++;
+                    squares[tmp_17][1] = src.y - i_3;
+                  }
+              }
+            }
+          }
+          i_3 ++;
+        }
+      }
+    }
+  int boop = 0;
+  {
+    int i_4 = 0;
+    while (i_4 < square_cnt) {
+      {
+        int tmp_20;
+        int tmp_21;
+        if (boop >= 1) {
+          __retres = 0;
+          goto return_label;
+        }
+        Location loc = {.x = squares[i_4][0], .y = squares[i_4][1]};
+        char spot = cgc_getPiece(loc);
+        if ((int)spot == '.') goto __Cont;
+        tmp_20 = cgc_getColor(piece);
+        tmp_21 = cgc_getColor(spot);
+        if (tmp_20 != tmp_21) boop ++;
+        else {
+          __retres = 0;
+          goto return_label;
+        }
+      }
+      __Cont: i_4 ++;
+    }
+  }
+  __retres = 1;
+  return_label: return __retres;
+}
+
+int cgc_performMove(Move move)
+{
+  int __retres;
+  char tmp;
+  Location src = move.src;
+  Location dst = move.dst;
+  tmp = cgc_getPiece(src);
+  int piece = (int)tmp;
+  if ((int)current_team == 1) {
+    int tmp_0;
+    tmp_0 = cgc_getColor((char)piece);
+    if (tmp_0 == 0) {
+      __retres = 0;
+      goto return_label;
+    }
+  }
+  else {
+    int tmp_1;
+    tmp_1 = cgc_getColor((char)piece);
+    if (tmp_1 == 1) {
+      __retres = 0;
+      goto return_label;
+    }
+  }
+  if (dst.x > 8 - 1) {
+    __retres = 0;
+    goto return_label;
+  }
+  else 
+    if (dst.x < 0) {
+      __retres = 0;
+      goto return_label;
+    }
+    else 
+      if (dst.y > 8 - 1) {
+        __retres = 0;
+        goto return_label;
+      }
+      else 
+        if (dst.y < 0) {
+          __retres = 0;
+          goto return_label;
+        }
+  if (piece == '.') {
+    __retres = 0;
+    goto return_label;
+  }
+  if (piece == 'a') 
+    if (dst.x == src.x) 
+      if (dst.y == src.y + 1) {
+        int tmp_2;
+        tmp_2 = cgc_checkNoCollision(move);
+        if (tmp_2) {
+          cgc_swap(move);
+          __retres = 1;
+          goto return_label;
+        }
+      }
+      else {
+        __retres = 0;
+        goto return_label;
+      }
+    else {
+      __retres = 0;
+      goto return_label;
+    }
+  if (piece == 'g') 
+    if (dst.x == src.x) 
+      if (dst.y == src.y - 1) {
+        int tmp_3;
+        tmp_3 = cgc_checkNoCollision(move);
+        if (tmp_3) {
+          cgc_swap(move);
+          __retres = 1;
+          goto return_label;
+        }
+      }
+      else {
+        __retres = 0;
+        goto return_label;
+      }
+    else {
+      __retres = 0;
+      goto return_label;
+    }
+  if (piece == 'b') {
+    if (dst.x == src.x + 2) goto _LOR_0;
+    else 
+      if (dst.x == src.x - 2) 
+        _LOR_0:
+        if (dst.y == src.y + 1) goto _LOR;
+        else 
+          if (dst.y == src.y - 1) {
+            _LOR:
+            {
+              int tmp_4;
+              tmp_4 = cgc_checkNoCollision(move);
+              if (tmp_4) {
+                cgc_swap(move);
+                __retres = 1;
+                goto return_label;
+              }
+            }
+          }
+    if (dst.y == src.y + 2) goto _LOR_2;
+    else 
+      if (dst.y == src.y - 2) 
+        _LOR_2:
+        if (dst.x == src.x + 1) goto _LOR_1;
+        else 
+          if (dst.x == src.x - 1) {
+            _LOR_1:
+            {
+              int tmp_5;
+              tmp_5 = cgc_checkNoCollision(move);
+              if (tmp_5) {
+                cgc_swap(move);
+                __retres = 1;
+                goto return_label;
+              }
+            }
+          }
+    __retres = 0;
+    goto return_label;
+  }
+  if (piece == 'h') {
+    if (dst.x == src.x + 2) goto _LOR_4;
+    else 
+      if (dst.x == src.x - 2) 
+        _LOR_4:
+        if (dst.y == src.y + 1) goto _LOR_3;
+        else 
+          if (dst.y == src.y - 1) {
+            _LOR_3:
+            {
+              int tmp_6;
+              tmp_6 = cgc_checkNoCollision(move);
+              if (tmp_6) {
+                cgc_swap(move);
+                __retres = 1;
+                goto return_label;
+              }
+            }
+          }
+    if (dst.y == src.y + 2) goto _LOR_6;
+    else 
+      if (dst.y == src.y - 2) 
+        _LOR_6:
+        if (dst.x == src.x + 1) goto _LOR_5;
+        else 
+          if (dst.x == src.x - 1) {
+            _LOR_5:
+            {
+              int tmp_7;
+              tmp_7 = cgc_checkNoCollision(move);
+              if (tmp_7) {
+                cgc_swap(move);
+                __retres = 1;
+                goto return_label;
+              }
+            }
+          }
+    __retres = 0;
+    goto return_label;
+  }
+  if (piece == 'c') goto _LOR_7;
+  else 
+    if (piece == 'i') {
+      _LOR_7:
+      {
+        int tmp_10;
+        int num = abs(dst.x - src.x);
+        tmp_10 = abs(dst.y - src.y);
+        ;
+        if (num == tmp_10) {
+          int tmp_9;
+          tmp_9 = cgc_checkNoCollision(move);
+          if (tmp_9) {
+            cgc_swap(move);
+            __retres = 1;
+            goto return_label;
+          }
+        }
+        __retres = 0;
+        goto return_label;
+      }
+    }
+  if (piece == 'f') goto _LOR_9;
+  else 
+    if (piece == 'l') {
+      _LOR_9:
+      {
+        int tmp_13;
+        int num_0 = abs(dst.x - src.x);
+        tmp_13 = abs(dst.y - src.y);
+        ;
+        if (num_0 == tmp_13) {
+          int tmp_12;
+          tmp_12 = cgc_checkNoCollision(move);
+          if (tmp_12) {
+            cgc_swap(move);
+            __retres = 1;
+            goto return_label;
+          }
+        }
+        if (dst.x == src.x) goto _LOR_8;
+        else 
+          if (dst.y == src.y) {
+            _LOR_8:
+            {
+              int tmp_14;
+              tmp_14 = cgc_checkNoCollision(move);
+              if (tmp_14) {
+                cgc_swap(move);
+                __retres = 1;
+                goto return_label;
+              }
+            }
+          }
+        __retres = 0;
+        goto return_label;
+      }
+    }
+  if (piece == 'e') goto _LOR_10;
+  else 
+    if (piece == 'k') {
+      _LOR_10:
+      {
+        int tmp_15;
+        int tmp_17;
+        int diffx = dst.x - src.x;
+        int diffy = dst.y - src.y;
+        tmp_15 = abs(diffx);
+        if (tmp_15 > 1) {
+          __retres = 0;
+          goto return_label;
+        }
+        else {
+          int tmp_16;
+          tmp_16 = abs(diffy);
+          if (tmp_16 > 1) {
+            __retres = 0;
+            goto return_label;
+          }
+        }
+        tmp_17 = cgc_checkNoCollision(move);
+        if (tmp_17) {
+          cgc_swap(move);
+          __retres = 1;
+          goto return_label;
+        }
+        __retres = 0;
+        goto return_label;
+      }
+    }
+  if (piece == 'j') goto _LOR_12;
+  else 
+    if (piece == 'd') {
+      _LOR_12:
+      {
+        if (dst.x == src.x) goto _LOR_11;
+        else 
+          if (dst.y == src.y) {
+            _LOR_11:
+            {
+              int tmp_18;
+              tmp_18 = cgc_checkNoCollision(move);
+              if (tmp_18) {
+                cgc_swap(move);
+                __retres = 1;
+                goto return_label;
+              }
+            }
+          }
+        __retres = 0;
+        goto return_label;
+      }
+    }
+  __retres = 0;
+  return_label: return __retres;
+}
+
+void cgc_swap(Move move)
+{
+  char tmp;
+  tmp = (*ptr_array)[move.dst.x][move.dst.y];
+  (*ptr_array)[move.dst.x][move.dst.y] = (*ptr_array)[move.src.x][move.src.y];
+  (*ptr_array)[move.src.x][move.src.y] = tmp;
+  return;
+}
+
+int cgc_verifyFormat(char *buf, int len)
+{
+  int __retres;
+  *(buf + len) = (char)'\000';
+  if ((int)*(buf + 0) >= '0') 
+    if ((int)*(buf + 0) <= '9') 
+      if ((int)*(buf + 1) == ',') 
+        if ((int)*(buf + 2) >= '0') 
+          if ((int)*(buf + 2) <= '9') 
+            if ((int)*(buf + 3) == ' ') 
+              if ((int)*(buf + 4) >= '0') 
+                if ((int)*(buf + 4) <= '9') 
+                  if ((int)*(buf + 5) == ',') 
+                    if ((int)*(buf + 6) >= '0') 
+                      if ((int)*(buf + 6) <= '9') {
+                        __retres = 1;
+                        goto return_label;
+                      }
+  __retres = 0;
+  return_label: return __retres;
+}
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_2(char const * __restrict format);
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_3(char const * __restrict format);
+
+/*@ ensures
+      \result ≡ 1 ⇒
+      \initialized(&\old(movers)->dst) ∧ \initialized(&\old(movers)->src);
+    assigns *movers;
+    assigns *movers \from \nothing;
+ */
+int cgc_parseUserInput(Move *movers)
+{
+  int __retres;
+  char buf[15];
+  int status;
+  int tmp_0;
+  size_t size = (unsigned int)0;
+  int num = 0;
+  Move tmp = {.src = {.x = 77, .y = 77}, .dst = {.x = 77, .y = 77}};
+  bzero((void *)(buf),(unsigned int)15);
+  status = cgc_receive(0,(void *)(buf),sizeof(buf) - (unsigned int)1,& size);
+  if (status != 0) {
+    __retres = -1;
+    goto return_label;
+  }
+  if (size > (size_t)0) 
+    if ((int)buf[size - (size_t)1] == '\n') size -= (size_t)1;
+  if (size == (size_t)1) {
+    if ((int)buf[0] == '9') {
+      __retres = 2;
+      goto return_label;
+    }
+  }
+  else 
+    if (size == (size_t)3) {
+      if ((int)buf[0] == '6') 
+        if ((int)buf[1] == '6') 
+          if ((int)buf[2] == '6') {
+            __retres = 3;
+            goto return_label;
+          }
+    }
+    else 
+      if (size != (size_t)7) {
+        printf_va_2("incorrect input\n");
+        __retres = 0;
+        goto return_label;
+      }
+  tmp_0 = cgc_verifyFormat(buf,(int)size);
+  if (! tmp_0) {
+    printf_va_3("incorrect input\n");
+    __retres = 0;
+    goto return_label;
+  }
+  {
+    int i = 0;
+    while ((unsigned int)i < sizeof(buf)) {
+      if ((int)buf[i] <= '9') 
+        if ((int)buf[i] >= '0') 
+          if (i == 0) {
+            tmp.src.x = atoi((char const *)(& buf[i]));
+            /*@ assert 0 ≤ tmp.src.x ≤ 9; */ ;
+          }
+          else 
+            if (i == 2) {
+              tmp.src.y = atoi((char const *)(& buf[i]));
+              /*@ assert 0 ≤ tmp.src.y ≤ 9; */ ;
+            }
+            else 
+              if (i == 4) {
+                tmp.dst.x = atoi((char const *)(& buf[i]));
+                /*@ assert 0 ≤ tmp.dst.x ≤ 9; */ ;
+              }
+              else 
+                if (i == 6) {
+                  tmp.dst.y = atoi((char const *)(& buf[i]));
+                  /*@ assert 0 ≤ tmp.dst.y ≤ 9; */ ;
+                }
+      i ++;
+    }
+  }
+  if (tmp.src.x != 77) {
+    if (tmp.src.y != 77) {
+      if (tmp.dst.x != 77) {
+        if (tmp.dst.y != 77) {
+          movers->src = tmp.src;
+          movers->dst = tmp.dst;
+          __retres = 1;
+          goto return_label;
+        }
+        else goto _LAND_1;
+      }
+      else goto _LAND_1;
+    }
+    else goto _LAND_1;
+  }
+  else {
+    _LAND_1: {
+               __retres = 0;
+               goto return_label;
+             }
+  }
+  return_label: return __retres;
+}
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_4(char const * __restrict format);
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_5(char const * __restrict format);
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_6(char const * __restrict format);
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_7(char const * __restrict format);
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_8(char const * __restrict format);
+
+/*@ requires valid_read_string(format);
+    assigns \result, __fc_stdout->__fc_FILE_data;
+    assigns \result
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            (indirect: __fc_stdout->__fc_FILE_data),
+            (indirect: *(format + (0 ..)));
+    assigns __fc_stdout->__fc_FILE_data
+      \from (indirect: __fc_stdout->__fc_FILE_id),
+            __fc_stdout->__fc_FILE_data, (indirect: *(format + (0 ..)));
+ */
+int printf_va_9(char const * __restrict format);
+
+int main(int cgc_argc, char **cgc_argv)
+{
+  int __retres;
+  void (*displayer)();
+  char array[8][8];
+  Move move;
+  displayer = (void (*)())(& cgc_displayboard);
+  ptr_array = & array;
+  cgc_initboard();
+  (*displayer)();
+  while (1) {
+    {
+      int tmp_0;
+      if ((int)current_team == 1) printf_va_4("WHITE: ");
+      else printf_va_5("BLACK: ");
+      int ret = cgc_parseUserInput(& move);
+      if (ret == 0) {
+        printf_va_6("Not a legal move format\n");
+        continue;
+      }
+      else 
+        if (ret == 2) {
+          (*displayer)();
+          continue;
+        }
+        else 
+          if (ret == 3) {
+            printf_va_7("good game\n");
+            cgc__terminate((unsigned int)0);
+          }
+          else 
+            if (ret == -1) cgc__terminate((unsigned int)0);
+      tmp_0 = cgc_performMove(move);
+      if (tmp_0) {
+        printf_va_8("OK\n");
+        if ((int)current_team == 1) current_team = (char)0;
+        else current_team = (char)1;
+      }
+      else printf_va_9("NO\n");
+    }
+  }
+  __retres = 0;
+  return __retres;
+}
+
+
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/metrics.log b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/metrics.log
new file mode 100644
index 0000000000000000000000000000000000000000..c4276ceeb3fa8e6894ff753512e11a3bfcf0180c
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/metrics.log
@@ -0,0 +1,40 @@
+[metrics] Defined functions (22)
+======================
+ cgc__terminate (2 calls); cgc_allocate (0 call);
+ cgc_checkNoCollision (11 calls); cgc_check_timeout (1 call);
+ cgc_copy_cgc_fd_set (2 calls); cgc_copy_os_fd_set (2 calls);
+ cgc_deallocate (0 call); cgc_displayboard (address taken) (0 call);
+ cgc_fdwait (0 call); cgc_getColor (10 calls); cgc_getPiece (6 calls);
+ cgc_initboard (1 call); cgc_parseUserInput (1 call);
+ cgc_performMove (1 call); cgc_random (0 call); cgc_receive (2 calls);
+ cgc_swap (11 calls); cgc_transmit (1 call); cgc_try_init_prng (1 call);
+ cgc_verifyFormat (1 call); main (0 call); receive_bytes_iPcz (0 call); 
+
+Undefined functions (5)
+=======================
+ cgc_aes_get_bytes (1 call); cgc_init_prng (1 call);
+ cgc_initialize_flag_page (0 call); cgc_prng (0 call); seed_prng (0 call); 
+
+'Extern' global variables (0)
+=============================
+ 
+
+Potential entry points (6)
+==========================
+ cgc_allocate; cgc_deallocate; cgc_fdwait; cgc_random; main;
+  receive_bytes_iPcz; 
+
+Global metrics
+============== 
+Sloc = 781
+Decision point = 184
+Global variables = 4
+If = 184
+Loop = 16
+Goto = 88
+Assignment = 279
+Exit point = 22
+Function = 27
+Function call = 98
+Pointer dereferencing = 66
+Cyclomatic complexity = 206
diff --git a/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/warnings.log b/cgc-challenges/chess_mimic/.frama-c/chess_mimic.parse/warnings.log
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/cgc-challenges/chess_mimic/.frama-c/path.mk b/cgc-challenges/chess_mimic/.frama-c/path.mk
new file mode 120000
index 0000000000000000000000000000000000000000..222d0e04958ae14f92c8910637128c93b6f3dd09
--- /dev/null
+++ b/cgc-challenges/chess_mimic/.frama-c/path.mk
@@ -0,0 +1 @@
+../../frama-c-cgc-path.mk
\ No newline at end of file
diff --git a/cgc-challenges/chess_mimic/README.md b/cgc-challenges/chess_mimic/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..5c70e3d676f7ecd8a8b2365d18af8bb4525da571
--- /dev/null
+++ b/cgc-challenges/chess_mimic/README.md
@@ -0,0 +1,49 @@
+# CGC Challenge Binary Template
+
+## Author Information
+
+"James Nuttall" <james@cromulence.co>
+
+### DARPA performer group
+Cromulence
+
+## Description
+
+This is a service that mimics a chess board and pieces. Each piece on the board moves similarly to its respective chess piece. Unlike chess, however, collisions on the board result in a swap of location rather than the opponent's piece being removed from the board. The user must find the combination of valid moves that will prove the vulnerability.
+
+### Feature List
+
+The game opens by printing the state of the board:
+
+	jhilkihj
+	gggggggg
+	........
+	........
+	........
+	........
+	aaaaaaaa
+	dbcfecbd
+
+The user must take turns entering moves as both the white and black player. Each move must follow the chess piece's valid move: pawn, rook, knight, bishop, king, and queen.
+
+The user may print the current board layout, make a move, or quit the game.
+
+The game accepts input in the form of source coordinates and destionation coordinates x,y x,y
+
+If a piece is located at the source coordinates the game will attempt to move it to the destination. It will check to see if the move is a valid one for that particular piece (following standard chess rules) and to make sure the path is clear from source to destination. If an opponent's piece is located at the destionation and it is an otherwise legal move, the game will swap the pieces. 
+
+Play continues until the user exits the game (or the vulnerable condition is achieved). 
+
+## Vulnerability
+User must move a white knight (using legal moves) to the spot behind the rook's H8 rook (location 7,8 on this board).This will cause a one byte overwrite beyond the array to the function pointer controlling the display of the board. If the user then tries to display the board, there is an opportunity to jump to this overflowed pointer.
+
+Specifically, in service.c:performMove, the white knight move-validator is before the bounds checking of the board. This allows the piece to jump off the board. Jumping off the board in the (7,8) location will overwite a function pointer located on the stack. The function pointer is subsequently accessed at service.c:164 by the user entering the '9' option (displayBoard).
+
+### Generic class of vulnerability
+Out of bounds write resulting in function pointer overwrite
+
+### CWE classification
+CWE-787 Out of Bounds Write
+
+## Challenges
+Due to the size of this board, the various pieces, and the allowable moves the possible states of the game quickly explode. This requires the CRS to analyze the source to find the incorrectly bounded piece and focus fuzzing on that piece. The CRS will be required to learn the complicated rules necessary for valid movement. This requires some slightly complex mathematical reasoning due to the way valid moves are calculated. Until this knowledge is deduced, the CRS will not be able to develop a POV. 
diff --git a/cgc-challenges/chess_mimic/include/cgc_service.h b/cgc-challenges/chess_mimic/include/cgc_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..c91f52d028a026fd8bed18fbc54c1253428f29f6
--- /dev/null
+++ b/cgc-challenges/chess_mimic/include/cgc_service.h
@@ -0,0 +1,90 @@
+/*
+
+Author: James Nuttall (james@cromulence.co)
+
+Copyright (c) 2014 Cromulence LLC
+
+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.
+
+*/
+
+// dimensions of the chess board
+#define WIDTH 8
+#define HEIGHT 8
+
+// Defines a single location on the 8x8 board
+typedef struct Location
+{
+	int x;
+	int y;
+} Location;
+
+// Defines a move: source and destination locations
+typedef struct Move
+{
+	Location src;
+	Location dst;
+} Move;
+
+void cgc_initboard(void);
+int checklegal(Move);
+void cgc_swap(Move);
+int cgc_parseUserInput(Move*);
+
+/* CHESS PIECES */
+
+// white
+#define PAWN_WHITE 'a'
+#define KNIGHT_WHITE 'b'
+#define BISHOP_WHITE 'c'
+#define ROOK_WHITE 'd'
+#define KING_WHITE 'e'
+#define QUEEN_WHITE 'f'
+
+// black
+#define PAWN_BLACK 'g'
+#define KNIGHT_BLACK 'h'
+#define BISHOP_BLACK 'i'
+#define ROOK_BLACK 'j'
+#define KING_BLACK 'k'
+#define QUEEN_BLACK 'l'
+
+#define EMPTY '.'
+#define BLACK_PIECE 0
+#define WHITE_PIECE 1
+
+#define BLACK_TEAM	0
+#define WHITE_TEAM  1
+
+#define PROMPT_WHITE "WHITE: "
+#define PROMPT_BLACK "BLACK: "
+#define WARNING "Not a legal move format\n"
+#define OK "OK\n"
+#define NO "NO\n"
+
+// parseUserInput return values
+#define INPUT_ERROR -1
+#define INVALID_INPUT 0
+#define GOOD_INPUT 1
+#define DISPLAY_BOARD 2
+#define END_GAME 3
+
+#define COLLISION 0
+#define NO_COLLISION 1
+
diff --git a/cgc-challenges/chess_mimic/lib/cgc_stdarg.h b/cgc-challenges/chess_mimic/lib/cgc_stdarg.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc2458195e83e6616a38e03781c2f21453b49fe7
--- /dev/null
+++ b/cgc-challenges/chess_mimic/lib/cgc_stdarg.h
@@ -0,0 +1,42 @@
+/*
+
+Author: Jason Williams <jdw@cromulence.com>
+
+Copyright (c) 2014 Cromulence LLC
+
+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 __STDARG_H__
+#define __STDARG_H__
+
+#ifdef WIN
+#include <stdarg.h>
+#else
+typedef __builtin_va_list __gnuc_va_list;
+
+#define va_start(v,l)   __builtin_va_start(v,l)
+#define va_end(v)       __builtin_va_end(v)
+#define va_arg(v,l)     __builtin_va_arg(v,l)
+
+
+typedef __gnuc_va_list va_list;
+#endif
+
+#endif // __STDARG_H__
diff --git a/cgc-challenges/chess_mimic/lib/cgc_stdint.h b/cgc-challenges/chess_mimic/lib/cgc_stdint.h
new file mode 100644
index 0000000000000000000000000000000000000000..6946c5ef352ce1f60c6ecb9790c55c12061ca89b
--- /dev/null
+++ b/cgc-challenges/chess_mimic/lib/cgc_stdint.h
@@ -0,0 +1,39 @@
+/*
+
+Author: Jason Williams <jdw@cromulence.com>
+
+Copyright (c) 2014 Cromulence LLC
+
+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 __STDINT_H__
+#define __STDINT_H__
+
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef long long int int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long int uint64_t;
+
+#endif // __STDINT_H__
diff --git a/cgc-challenges/chess_mimic/lib/printf.c b/cgc-challenges/chess_mimic/lib/printf.c
new file mode 100644
index 0000000000000000000000000000000000000000..ecfdf2e28ae94941f696a458e723f724dd2111bd
--- /dev/null
+++ b/cgc-challenges/chess_mimic/lib/printf.c
@@ -0,0 +1,250 @@
+/*
+
+Author: Jason Williams <jdw@cromulence.com>
+
+Copyright (c) 2014 Cromulence LLC
+
+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.
+
+*/
+#include "libcgc.h"
+
+#include "common.h"
+
+// 5 digits of precision
+#define F32_PRECISION       0.00001
+
+int cgc_putc( int c )
+{
+    size_t tx_count;
+
+    if ( cgc_transmit( STDOUT, &c, 1, &tx_count ) != 0 )
+        cgc__terminate(2);
+
+    return c;
+}
+
+void cgc_int_to_str( int val, char *buf )
+{
+    char temp_buf[32];
+    char *c = temp_buf;
+    int count = 0;
+
+    if ( buf == NULL )
+        return;
+
+    if ( val < 0 )
+    {
+        *buf = '-';
+        buf++;
+
+        val *= -1;
+    }
+
+    do
+    {
+        *c = (val % 10) + '0';
+        val /= 10;
+
+        c++;
+        count++;
+    } while ( val != 0 );
+
+    while ( count-- > 0 )
+    {
+        c--;
+        *buf = *c;
+        buf++;
+    }
+
+    *buf = '\0';
+}
+
+void cgc_float_to_str( double val, char *buf )
+{
+    if ( buf == NULL )
+        return;
+
+    if ( isnan( val ) )
+    {
+        strcpy( buf, "nan" );
+    }
+    else if ( isinf( val ) )
+    {
+        strcpy( buf, "inf" );
+    }
+    else if ( val == 0.0 )
+    {
+        strcpy( buf, "0.00000" );
+    }
+    else
+    {
+        int digit;
+        int m;
+        int m1;
+        int fraction_digit;
+        int in_fraction;
+        int neg = 0;
+        char *c = buf;
+
+        if ( val > 0.0 )
+            val = val + (F32_PRECISION * 0.5);
+        else
+            val = val - (F32_PRECISION * 0.5);
+
+        // Negative numbers
+        if ( val < 0.0 )
+        {
+            neg = 1;
+            *(c++) = '-';
+            val = -val;
+        }
+
+        // Calculate magnitude
+        m = log10( val );
+
+        if ( m < 1.0 )
+            m = 0;
+
+        fraction_digit = 0;
+        in_fraction = 0;
+        while ( val > F32_PRECISION || m >= 0 )
+        {
+            double weight = pow( 10.0, m );
+            if ( weight > 0 && !isinf(weight) )
+            {
+                digit = floor( val / weight );
+                val -= (digit * weight);
+
+                *(c++) = '0' + digit;
+
+                if ( in_fraction )
+                    fraction_digit++;
+            }
+
+            if ( m == 0 && val > 0.0 )
+            {
+                *(c++) = '.';
+                in_fraction = 1;
+                fraction_digit = 0;
+            }
+
+            m--;
+        }
+
+        while ( in_fraction && fraction_digit < 5 )
+        {
+            *(c++) = '0';
+            fraction_digit++;
+        }
+
+        *c = '\0';
+    }
+}
+
+int vprintf( const char *fmt, va_list arg )
+{
+    int character_count = 0;
+    char temp_buf[64];
+
+    if ( fmt == NULL )
+        return -1;
+
+    while ( *fmt )
+    {
+        if ( *fmt == '@' )
+        {
+            fmt++;
+
+            // We don't handle any special formatting
+            switch ( *fmt )
+            {
+            case '@':
+                cgc_putc( '@' );
+                break;
+
+            case 'd':
+                // Integer
+                {
+                    int int_arg = va_arg( arg, int );
+                    char *c;
+
+                    cgc_int_to_str( int_arg, temp_buf );
+
+                    c = temp_buf;
+                    while ( *c )
+                    {
+                        cgc_putc( *c );
+                        character_count++;
+                        c++;
+                    }
+                }
+                break;
+
+            case 'f':
+                // Float
+                {
+                    double float_arg = va_arg( arg, double );
+                    char *c;
+
+                    cgc_float_to_str( float_arg, temp_buf );
+
+                    c = temp_buf;
+                    while ( *c )
+                    {
+                        cgc_putc( *c );
+                        character_count++;
+                        c++;
+                    }
+                }
+                break;
+
+            case '\0':
+                return -1;
+
+            default:
+                // Unknown
+                return -1;
+            }
+
+            fmt++;
+        }
+        else
+        {
+            cgc_putc( *fmt );
+            fmt++;
+
+            character_count++;
+        }
+    }
+
+    return (character_count);
+}
+
+int printf( const char *fmt, ... )
+{
+    va_list arg;
+    int done;
+
+    va_start( arg, fmt );
+    done = vprintf( fmt, arg );
+    va_end( arg );
+
+    return done;
+}
diff --git a/cgc-challenges/chess_mimic/lib/stdlib.c b/cgc-challenges/chess_mimic/lib/stdlib.c
new file mode 100644
index 0000000000000000000000000000000000000000..b7c07473c4e045e2994ae12f49fa4afa0c7e16fd
--- /dev/null
+++ b/cgc-challenges/chess_mimic/lib/stdlib.c
@@ -0,0 +1,346 @@
+/*
+
+Author: Jason Williams <jdw@cromulence.com>
+
+Copyright (c) 2014 Cromulence LLC
+
+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.
+
+*/
+#include "libcgc.h"
+
+#include "common.h"
+
+int isspace( int c )
+{
+    if ( c == ' ' ||
+         c == '\t' ||
+         c == '\n' ||
+         c == '\v' ||
+         c == '\f' ||
+         c == '\r' )
+        return 1;
+    else
+        return 0;
+}
+
+int isdigit( int c )
+{
+    if ( c >= '0' && c <= '9' )
+        return 1;
+    else
+        return 0;
+}
+
+double cgc_atof(const char* str)
+{
+    if ( str == NULL )
+        return 0.0;
+
+    double val = 0.0;
+    double scale = 0.1;
+    int sign = 1;
+    int part;
+
+    // Skip whitespace
+    while ( isspace( str[0] ) )
+        str++;
+
+    part = 0; // First part (+/-/./number is acceptable)
+
+    while( str[0] != '\0' )
+    {
+        if ( str[0] == '-' )
+        {
+            if ( part != 0 )
+                return 0.0;
+
+            sign = -1;
+            part++;
+        }
+        else if ( str[0] == '+' )
+        {
+            if ( part != 0 )
+                return 0.0;
+
+            part++;
+        }
+        else if ( str[0] == '.' )
+        {
+            if ( part == 0 || part == 1 )
+                part = 2;
+            else
+                return 0.0;
+        }
+        else if ( isdigit( *str ) )
+        {
+            if ( part == 0 || part == 1 )
+            {
+                // In integer part
+                part = 1;
+                val = (val * 10.0) + (*str - '0');
+            }
+            else if ( part == 2 )
+            {
+                val += ((*str - '0') * scale);
+                scale /= 10.0;
+            }
+            else
+            {
+                // part invalid
+                return 0.0;
+            }
+        }
+        else
+            break;
+
+        str++;
+    }
+
+    return (sign * val);
+}
+
+
+int atoi(const char* str)
+{
+    if ( str == NULL )
+        return 0;
+
+    int integer_part = 0;
+    int sign = 1;
+    int part;
+    int digit_count = 0;
+
+    // Skip whitespace
+    while ( isspace( str[0] ) )
+        str++;
+
+    part = 0; // First part (+/-/number is acceptable)
+
+    while( str[0] != '\0' )
+    {
+        if ( str[0] == '-' )
+        {
+            if ( part != 0 )
+                return 0;
+
+            sign = -1;
+            part++;
+        }
+        else if ( str[0] == '+' )
+        {
+            if ( part != 0 )
+                return 0;
+
+            part++;
+        }
+        else if ( isdigit( *str ) )
+        {
+            if ( part == 0 || part == 1 )
+            {
+                // In integer part
+                part = 1;
+                integer_part = (integer_part * 10) + (*str - '0');
+
+                digit_count++;
+
+                if ( digit_count == 9 )
+                    break;
+            }
+            else
+            {
+                // part invalid
+                return 0;
+            }
+        }
+        else
+            break;
+
+        str++;
+    }
+
+    return (sign * integer_part);
+}
+
+char *strcpy( char *dest, char *src )
+{
+    size_t i;
+
+    for ( i = 0; ; i++ )
+    {
+        if ( src[i] == '\0' )
+            break;
+
+        dest[i] = src[i];
+    }
+    dest[i] = '\0';
+
+    return (dest);
+}
+
+void bzero( void *buff, size_t len )
+{
+    size_t index = 0;
+    unsigned char *c = buff;
+
+    if ( buff == NULL ) {
+        goto end;
+    }
+
+    if ( len == 0 ) {
+        goto end;
+    }
+
+    for ( index = 0; index < len; index++ ) {
+        c[index] = 0x00;
+    }
+
+end:
+    return;
+}
+
+int strcmp( const char *s1, const char *s2 ) 
+{
+    while ( *s1 && (*s1 == *s2) ) 
+    {
+      s1++,s2++;
+    }
+    return (*(const unsigned char *)s1 - *(const unsigned char *)s2);
+}
+
+char *cgc_strncat ( char *dest, const char *src, size_t n ) 
+{
+    size_t dest_len = strlen(dest);
+    size_t i;
+
+    if (dest == NULL || src == NULL) 
+    {
+      return(dest);
+    }
+    for (i = 0; i < n && src[i] != '\0'; i++) 
+    {
+      dest[dest_len+i] = src[i];
+    }
+    dest[dest_len+i] = '\0';
+
+    return(dest);
+}
+
+size_t cgc_receive_until( char *dst, char delim, size_t max )
+{
+    size_t len = 0;
+    size_t rx = 0;
+    char c = 0;
+
+    while( len < max ) {
+        dst[len] = 0x00;
+
+        if ( cgc_receive( STDIN, &c, 1, &rx ) != 0 ) {
+            len = 0;
+            goto end;
+        }
+
+        if ( c == delim ) {
+            goto end;
+        }
+   
+        dst[len] = c;
+        len++;
+    }
+end:
+    return len;
+}
+
+size_t cgc_strcat( char *dest, char*src )
+{
+    size_t length = 0;
+    size_t start = 0;
+
+    if ( dest == NULL || src == NULL) {
+        goto end;
+    }
+
+    start = strlen( dest );
+
+    for ( ; src[length] != 0x00 ; start++, length++ ) {
+        dest[start] = src[length];
+    }
+
+    length = start;
+end:
+    return length;
+}
+
+size_t strlen( char * str )
+{
+    size_t length = 0;
+
+    if ( str == NULL ) {
+        goto end;
+    }
+
+    while ( str[length] ) { length++; }
+
+end:
+    return length;
+}
+
+size_t cgc_itoa( char *out, size_t val, size_t max )
+{
+    size_t length = 0;
+    size_t end = 0;
+    size_t temp = 0;
+
+    if ( out == NULL ) {
+        goto end;
+    }
+
+    // Calculate the needed length
+    temp = val;
+    do {
+        end++;
+        temp /= 10;
+    } while ( temp );
+
+    // ensure we have enough room
+    if ( end >= max ) {
+        goto end;
+    }
+
+    length = end;
+
+    // Subtract one to skip the null
+    end--;
+
+    do {
+        out[end] = (val % 10) + 0x30;
+        val /= 10;
+        end--;
+    } while ( val );
+
+    out[length] = 0x00;
+end:
+    return length;
+}
+
+void cgc_puts( char *t )
+{
+    size_t size;
+    cgc_transmit(STDOUT, t, strlen(t), &size);
+}
diff --git a/cgc-challenges/chess_mimic/src/service.c b/cgc-challenges/chess_mimic/src/service.c
new file mode 100644
index 0000000000000000000000000000000000000000..74c4a77f0eab7705f37ea903c070293011c80143
--- /dev/null
+++ b/cgc-challenges/chess_mimic/src/service.c
@@ -0,0 +1,710 @@
+/*
+
+Author: James Nuttall (james@cromulence.co)
+
+Copyright (c) 2014 Cromulence LLC
+
+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.
+
+*/
+
+#include "libcgc.h"
+
+#include "cgc_service.h"
+
+#include "common.h"
+
+/*
+   This CB emulates a chess board. The board is an 8x8 array; the pieces are unique chars saved within the array.
+
+   User takes turns between white and black side, moving pieces according to chess rules (mostly).
+
+   The pieces do not 'take' each other, they will only switch positions.
+   Pawns do not take diagonally, they only move forward one step at a time.
+   As in chess, pieces can not jump over each other; the knight is the only exception to this rule.
+
+   To exploit:
+   If a white knight makes it to 7,8 and then tries to display the board (the '9' option), it will crash. 
+   As seen in the pov.xml.
+   */
+
+
+// global variables for use by all other functions
+char (*ptr_array)[WIDTH][HEIGHT]; // pointer to board array 
+char current_team = WHITE_TEAM;  // white/black
+
+// Returns color of piece (BLACK_PIECE, WHITE_PIECE, or EMPTY)
+int cgc_getColor(char piece)
+{
+	if (piece <= QUEEN_WHITE && piece >= PAWN_WHITE)
+		return WHITE_PIECE;
+	if (piece <= QUEEN_BLACK && piece >= PAWN_BLACK)
+		return BLACK_PIECE;
+	return EMPTY;
+}
+
+// display contents of board
+void cgc_displayboard(void)
+{
+	for(int i = HEIGHT - 1; i >= 0; i--)
+	{
+		for(int j = 0; j < WIDTH; j++)
+		{
+			cgc_transmit(0, (char*)&(*ptr_array)[j][i], 1, NULL);
+		}
+		printf("\n");
+	}
+}
+
+// place all the pieces on the board
+void cgc_initboard()
+{
+	// all the empty squares get a '.'
+	for(int i = 0; i < HEIGHT; i++)
+	{
+		for(int j = 0; j < WIDTH; j++)
+		{
+			(*ptr_array)[i][j] = EMPTY;
+		}
+	}
+
+	// putting WHITE pieces in position
+	(*ptr_array)[0][0] = ROOK_WHITE;
+	(*ptr_array)[1][0] = KNIGHT_WHITE;
+	(*ptr_array)[2][0] = BISHOP_WHITE;
+	(*ptr_array)[3][0] = QUEEN_WHITE;
+	(*ptr_array)[4][0] = KING_WHITE;
+	(*ptr_array)[5][0] = BISHOP_WHITE;
+	(*ptr_array)[6][0] = KNIGHT_WHITE;
+	(*ptr_array)[7][0] = ROOK_WHITE;
+
+	(*ptr_array)[0][1] = PAWN_WHITE;
+	(*ptr_array)[1][1] = PAWN_WHITE;
+	(*ptr_array)[2][1] = PAWN_WHITE;
+	(*ptr_array)[3][1] = PAWN_WHITE;
+	(*ptr_array)[4][1] = PAWN_WHITE;
+	(*ptr_array)[5][1] = PAWN_WHITE;
+	(*ptr_array)[6][1] = PAWN_WHITE;
+	(*ptr_array)[7][1] = PAWN_WHITE;
+
+	// putting BLACK pieces in position
+	(*ptr_array)[0][6] = PAWN_BLACK;
+	(*ptr_array)[1][6] = PAWN_BLACK;
+	(*ptr_array)[2][6] = PAWN_BLACK;
+	(*ptr_array)[3][6] = PAWN_BLACK;
+	(*ptr_array)[4][6] = PAWN_BLACK;
+	(*ptr_array)[5][6] = PAWN_BLACK;
+	(*ptr_array)[6][6] = PAWN_BLACK;
+	(*ptr_array)[7][6] = PAWN_BLACK;
+
+	(*ptr_array)[0][7] = ROOK_BLACK;
+	(*ptr_array)[1][7] = KNIGHT_BLACK;
+	(*ptr_array)[2][7] = BISHOP_BLACK;
+	(*ptr_array)[3][7] = QUEEN_BLACK;
+	(*ptr_array)[4][7] = KING_BLACK;
+	(*ptr_array)[5][7] = BISHOP_BLACK;
+	(*ptr_array)[6][7] = KNIGHT_BLACK;
+	(*ptr_array)[7][7] = ROOK_BLACK;
+}
+
+// returns the piece at the given location
+char cgc_getPiece(Location loc)
+{
+	return (*ptr_array)[loc.x][loc.y];
+}
+
+// Checks for a collision
+// returns COLLISION or NO_COLLISION
+int cgc_checkNoCollision(Move move)
+{
+	Location src = move.src;
+	Location dst = move.dst;
+
+	int squares[WIDTH][2]; // squares between src and dst
+	int square_cnt = 0; 
+
+	char piece = cgc_getPiece(move.src);
+
+	// pieces cannot pass through each other (except KNIGHT)
+	if (piece == KNIGHT_WHITE || piece == KNIGHT_BLACK)
+	{
+		// make sure the knight isn't landing on a piece of its own color
+		if (cgc_getColor(piece) != cgc_getColor(cgc_getPiece(dst)))
+			return NO_COLLISION;
+		else
+		{
+			return COLLISION;
+		}
+	}
+	// if piece is white and the destination is white, collision
+	if (cgc_getColor(piece) == WHITE_PIECE && cgc_getColor(cgc_getPiece(move.dst)) == WHITE_PIECE )
+		return COLLISION;
+
+	// if piece is black and the destination is black, collision
+	if (cgc_getColor(piece) == BLACK_PIECE && cgc_getColor(cgc_getPiece(move.dst)) == BLACK_PIECE)
+		return COLLISION;
+
+	// determine squares between src and dst on a FILE
+	if (move.src.x == move.dst.x)
+	{
+		if (move.src.y < move.dst.y)
+		{
+			for(int i = move.src.y+1; i <= move.dst.y; i++)
+			{
+#ifdef __FC_PATCHED
+				if (square_cnt < 8)
+				{
+					squares[square_cnt][0] = move.src.x;
+					squares[square_cnt++][1] = i;
+				}
+#else
+				squares[square_cnt][0] = move.src.x;
+				squares[square_cnt++][1] = i;
+#endif
+			}
+		}
+		else
+			for(int i = move.src.y-1; i >= move.dst.y; i--)
+			{
+#ifdef __FC_PATCHED
+				if (square_cnt < 8)
+				{
+					squares[square_cnt][0] = move.src.x;
+					squares[square_cnt++][1] = i;
+				}
+#else
+				squares[square_cnt][0] = move.src.x;
+				squares[square_cnt++][1] = i;
+#endif
+			}
+	}
+	// determine squares between src and dst on a RANK
+	else if (move.src.y == move.dst.y)
+	{
+		if (move.src.x < move.dst.x)
+		{
+			for(int i = move.src.x+1; i <= move.dst.x; i++)
+			{
+#ifdef __FC_PATCHED
+				if (square_cnt < 8)
+				{
+					squares[square_cnt][0] = i;
+					squares[square_cnt++][1] = move.src.y;
+				}
+#else
+				squares[square_cnt][0] = i;
+				squares[square_cnt++][1] = move.src.y;
+#endif
+			}
+		}
+		else
+			for(int i = move.src.x-1; i >= move.dst.x; i--)
+			{
+#ifdef __FC_PATCHED
+				if (square_cnt < 8)
+				{
+					squares[square_cnt][0] = i;
+					squares[square_cnt++][1] = move.src.y;
+				}
+#else
+				squares[square_cnt][0] = i;
+				squares[square_cnt++][1] = move.src.y;
+#endif
+			}
+	}
+	else
+	{ 
+		// determine squares between src and dst on a DIAGONAL
+		int num = abs(move.dst.x - move.src.x);
+		if (num == abs(move.dst.y - move.src.y))
+		{
+			for (int i = 1; i <= num; i++)
+			{
+				if (dst.y > src.y && dst.x > src.x)
+				{
+					squares[square_cnt][0] = src.x + i;
+					squares[square_cnt++][1] = src.y + i;
+				}
+				else if (dst.y > src.y && dst.x < src.x)
+				{
+					squares[square_cnt][0] = src.x - i;
+					squares[square_cnt++][1] = src.y + i;
+				}
+				else if (dst.y < src.y && dst.x > src.x)
+				{
+					squares[square_cnt][0] = src.x + i;
+					squares[square_cnt++][1] = src.y - i;
+				}
+				else if (dst.y < src.y && dst.x < src.x)
+				{
+					squares[square_cnt][0] = src.x - i;
+					squares[square_cnt++][1] = src.y - i;
+				}
+			}
+		}
+	}
+
+	int boop = 0; // track how many pieces we go through in transit
+	// now 'squares' has a list of all squares being passed through
+	for (int i = 0; i < square_cnt; i++)
+	{
+		// if we've already seen a piece in the way and we're still 
+		//   trying to move, collision
+		if (boop >= 1)
+			return COLLISION;
+
+		Location loc = {squares[i][0], squares[i][1]};
+		char spot = cgc_getPiece(loc);
+
+		if (spot == EMPTY)
+		{
+			continue; // no penalty for empty squares. keep going
+		}
+
+		if (cgc_getColor(piece) != cgc_getColor(spot))
+		{
+			boop++; // we ran into one enemy piece. track that we did, becuase we can't go through 2 or more
+		}
+		else
+		{
+			return COLLISION;
+		}	
+	}
+
+	return NO_COLLISION;
+}
+
+// Attemps to perform the move, pieces are swapped if landed on
+// Returns 1 if the move succeded
+// Returns 0 if the move was illegal (based on the piece moved and the state of board)
+int cgc_performMove(Move move)
+{
+	Location src = move.src;
+	Location dst = move.dst;
+	int piece = cgc_getPiece(src);
+
+	if (current_team == WHITE_TEAM)	
+	{
+		// WHITE's turn
+		if (cgc_getColor(piece) == BLACK_PIECE)
+		{
+			return 0; // trying to move a black piece during white's turn
+		}
+	}
+	else
+	{
+		// BLACK's turn
+		if (cgc_getColor(piece) == WHITE_PIECE)
+		{
+			return 0; // trying to move a white piece during black's turn
+		}
+	}
+
+
+	// NOTE: Vulnerability is here
+	// the knight move check is placed before the bounds check, which is the vulnerability
+#ifndef PATCHED
+	if (piece == KNIGHT_WHITE)
+	{
+		if (dst.x == src.x + 2 || dst.x == src.x - 2)
+		{
+			if (dst.y == src.y + 1 || dst.y == src.y - 1)
+			{
+				if (cgc_checkNoCollision(move))
+				{
+					cgc_swap(move);
+					return 1;
+				}
+			}
+		}
+		if (dst.y == src.y + 2 || dst.y == src.y - 2)
+		{
+			if (dst.x == src.x + 1 || dst.x == src.x - 1)
+			{
+				if (cgc_checkNoCollision(move))
+				{
+					cgc_swap(move);
+					return 1;
+				}
+			}
+		}
+		return 0;
+	}
+#endif
+
+	// make sure they're moving within the bounds of the board
+	if (dst.x > WIDTH - 1 || dst.x < 0 || dst.y > HEIGHT - 1 || dst.y < 0)
+		return 0;
+
+	if (piece == EMPTY)
+		return 0;
+
+	if (piece == PAWN_WHITE)
+	{
+		if (dst.x == src.x && dst.y == (src.y + 1))
+		{
+			if (cgc_checkNoCollision(move))
+			{
+				cgc_swap(move);
+				return 1;
+			}
+		}
+		else
+			return 0;
+	}
+	if (piece == PAWN_BLACK)
+	{
+		if (dst.x == src.x && dst.y == (src.y - 1))
+		{
+			if (cgc_checkNoCollision(move))
+			{
+				cgc_swap(move);
+				return 1;
+			}
+		}
+		else
+			return 0;
+	}
+
+	// This is where the knight move check should happen (after the bounds check, above)
+#ifdef PATCHED
+	if (piece == KNIGHT_WHITE)
+	{
+		if (dst.x == src.x + 2 || dst.x == src.x - 2)
+		{
+			if (dst.y == src.y + 1 || dst.y == src.y - 1)
+			{
+				if (cgc_checkNoCollision(move))
+				{
+					cgc_swap(move);
+					return 1;
+				}
+			}
+		}
+		if (dst.y == src.y + 2 || dst.y == src.y - 2)
+		{
+			if (dst.x == src.x + 1 || dst.x == src.x - 1)
+			{
+				if (cgc_checkNoCollision(move))
+				{
+					cgc_swap(move);
+					return 1;
+				}
+			}
+		}
+		return 0;
+	}
+#endif
+
+	if (piece == KNIGHT_BLACK)
+	{
+		if (dst.x == src.x + 2 || dst.x == src.x - 2)
+		{
+			if (dst.y == src.y + 1 || dst.y == src.y - 1)
+			{
+				if (cgc_checkNoCollision(move))
+				{
+					cgc_swap(move);
+					return 1;
+				}
+			}
+		}
+		if (dst.y == src.y + 2 || dst.y == src.y - 2)
+		{
+			if (dst.x == src.x + 1 || dst.x == src.x - 1)
+			{
+				if (cgc_checkNoCollision(move))
+				{
+					cgc_swap(move);
+					return 1;
+				}
+			}
+		}
+		return 0;
+	}
+	if (piece == BISHOP_WHITE || piece == BISHOP_BLACK)
+	{
+		// bishop traveling to the right
+		int num = abs(dst.x - src.x);
+		if (num == abs(dst.y - src.y))
+		{	// good
+			if (cgc_checkNoCollision(move))
+			{
+				cgc_swap(move);
+				return 1;
+			}
+		}
+		return 0;
+	}
+	if (piece == QUEEN_WHITE || piece == QUEEN_BLACK)
+	{
+		int num = abs(dst.x - src.x);
+		// moving diagonal
+		if (num == abs(dst.y - src.y))
+		{	// good
+			if (cgc_checkNoCollision(move))
+			{
+				cgc_swap(move);
+				return 1;
+			}
+		}
+		// moving on RANK or FILE
+		if (dst.x == src.x || dst.y == src.y)
+		{
+			if (cgc_checkNoCollision(move))
+			{
+				cgc_swap(move);
+				return 1;
+			}
+		}
+		return 0;
+	}
+	if (piece == KING_WHITE || piece == KING_BLACK)
+	{
+		int diffx = dst.x - src.x;
+		int diffy = dst.y - src.y;
+
+		// king can only move 1 square.
+		if (abs(diffx) > 1 || abs(diffy) > 1)
+			return 0;
+
+		if (cgc_checkNoCollision(move))
+		{
+			cgc_swap(move);
+			return 1;
+		}
+		return 0;
+	}
+	if (piece == ROOK_BLACK || piece == ROOK_WHITE)
+	{
+		// moving on RANK or FILE
+		if (dst.x == src.x || dst.y == src.y)
+		{
+			if (cgc_checkNoCollision(move))
+			{
+				cgc_swap(move);
+				return 1;
+			}
+		}
+		return 0;
+	}
+
+	return 0;
+}
+
+// swap two array locations
+void cgc_swap(Move move)
+{
+	char tmp;
+	tmp = (*ptr_array)[move.dst.x][move.dst.y];
+	(*ptr_array)[move.dst.x][move.dst.y] = (*ptr_array)[move.src.x][move.src.y];
+	(*ptr_array)[move.src.x][move.src.y] = tmp;	
+}
+
+// Verifies input is in correct move format x,y x,y
+// return 1 if format is correct
+// return 0 otherwise
+int cgc_verifyFormat(char *buf, int len)
+{
+
+	buf[len] = '\x00';
+	// #,# #,#
+	if (buf[0] >= '0' && buf[0] <= '9')
+		if (buf[1] == ',')
+			if (buf[2] >= '0' && buf[2] <= '9')
+				if (buf[3] == ' ')
+					if (buf[4] >= '0' && buf[4] <= '9')
+						if (buf[5] == ',')
+							if (buf[6] >= '0' && buf[6] <= '9')
+								return 1;
+
+	return 0;
+}
+
+// receive input, parse into 'move' structure
+// return GOOD_INPUT for good input
+// return INVALID_INPUT for bad input
+// return DISPLAY_BOARD for request to display board
+
+/*@assigns *movers \from \nothing;
+  ensures (\result == GOOD_INPUT ==> \initialized(&movers->dst) && \initialized(&movers->src));
+  */
+int cgc_parseUserInput(Move *movers)
+{
+	size_t size = 0; // number of bytes user input
+	char buf[15]; // will hold user input
+	int num = 0;
+
+	Move tmp = {77,77,77,77}; // arbitrary default values. used later to ensure we received values
+
+	bzero(buf,15);
+	int status;
+	status = cgc_receive(STDIN, buf, sizeof(buf) - 1, &size);
+	if (status != 0)
+	{
+		// Error on receive
+		return INPUT_ERROR;
+	}
+
+	// Discard newline from manual input
+#ifdef __FC_PATCHED
+	if (size > 0 && buf[size-1] == '\n')
+#else
+		if (buf[size-1] == '\n')
+# endif
+		{
+			size--;
+		}
+
+	if (size == 1)
+	{
+		if (buf[0] == '9')
+		{
+			// display board
+			return DISPLAY_BOARD;
+		}
+	}
+	else if (size == 3)
+	{
+		if (buf[0] == '6' && buf[1] == '6' && buf[2] == '6')
+		{
+			return END_GAME;
+		}
+	}
+	else if (size != 7) 
+	{
+		printf("incorrect input\n");
+		return INVALID_INPUT;
+	}
+
+	if (!cgc_verifyFormat(buf, size))
+	{
+		printf("incorrect input\n");
+		return INVALID_INPUT;
+	}
+
+	for (int i = 0; i < sizeof(buf); i++)
+	{	
+		if (buf[i] <= '9' && buf[i] >= '0')
+		{
+			if (i == 0)
+			{
+				tmp.src.x = atoi(&buf[i]);
+				/*@ assert 0 <= tmp.src.x <= 9;
+				*/
+			}
+			else if (i == 2)
+			{
+				tmp.src.y = atoi(&buf[i]);
+				/*@ assert 0 <= tmp.src.y <= 9;
+				*/
+			}
+			else if (i == 4)
+			{
+				tmp.dst.x = atoi(&buf[i]);
+				/*@ assert 0 <= tmp.dst.x <= 9;
+				*/
+			}
+			else if (i == 6)
+			{
+				tmp.dst.y = atoi(&buf[i]);
+				/*@ assert 0 <= tmp.dst.y <= 9;
+				*/
+			}
+		}
+	}
+
+	if (tmp.src.x != 77 && tmp.src.y != 77 && tmp.dst.x != 77 && tmp.dst.y != 77)
+	{
+		movers->src = tmp.src;
+		movers->dst = tmp.dst;
+		return GOOD_INPUT;
+	}
+	else
+	{
+		return INVALID_INPUT;
+	}
+}
+
+int main(int cgc_argc, char *cgc_argv[])
+{
+	// function pointer to print chess board
+	void (*displayer)(); // overwriting the below array will destroy this function pointer
+	// chess board
+	char array[WIDTH][HEIGHT];
+
+	displayer = cgc_displayboard;
+	ptr_array = &array;
+
+	cgc_initboard();
+	displayer();
+
+	Move move;
+
+	while(1)
+	{
+		// print prompt
+		if (current_team == WHITE_TEAM)
+			printf(PROMPT_WHITE);
+		else
+			printf(PROMPT_BLACK);
+
+		// receive: x,y x,y
+		int ret = cgc_parseUserInput(&move);
+		if (ret == INVALID_INPUT)
+		{
+			printf(WARNING);
+			continue;
+		}
+		else if (ret == DISPLAY_BOARD)
+		{
+			displayer();
+			continue;
+		}
+		else if (ret == END_GAME)
+		{
+			printf("good game\n");
+			cgc__terminate(0);
+		}
+		else if (ret == INPUT_ERROR)
+		{
+			cgc__terminate(0);
+		}
+
+		if(cgc_performMove(move))
+		{
+			// Move suceeded
+			printf(OK);
+
+			// Switch teams
+			if (current_team == WHITE_TEAM)
+				current_team = BLACK_TEAM;
+			else
+				current_team = WHITE_TEAM;
+		}
+		else
+		{
+			// Move was illegal
+			printf(NO);
+		}
+	}
+
+	return 0;
+}
+
diff --git a/cgc-challenges/normalize.sh b/cgc-challenges/normalize.sh
index 28d2ae0945fa33f318dcfba504df4295f92f5208..9dd67756b3f779b8c50aefc5aa5e09b20fc8bfea 100755
--- a/cgc-challenges/normalize.sh
+++ b/cgc-challenges/normalize.sh
@@ -5,6 +5,7 @@ if [ $# -lt 1 ]; then
     exit 1
 fi
 
+sed -i 's/cgc_abs/abs/g' $*
 sed -i 's/cgc_atoi/atoi/g' $*
 sed -i 's/cgc_bzero/bzero/g' $*
 sed -i 's/cgc_calloc/calloc/g' $*
@@ -14,7 +15,9 @@ sed -i 's/cgc_exit/exit/g' $*
 sed -i 's/cgc_floor/floor/g' $*
 sed -i 's/cgc_isalpha/isalpha/g' $*
 sed -i 's/cgc_isdigit/isdigit/g' $*
+sed -i 's/cgc_isinf/isinf/g' $*
 sed -i 's/cgc_islower/islower/g' $*
+sed -i 's/cgc_isnan/isnan/g' $*
 sed -i 's/cgc_isupper/isupper/g' $*
 sed -i 's/cgc_isspace/isspace/g' $*
 sed -i 's/cgc_free/free/g' $*
@@ -40,6 +43,7 @@ sed -i 's/cgc_strtok/strtok/g' $*
 sed -i 's/cgc_strtol/strtol/g' $*
 sed -i 's/cgc_tolower/tolower/g' $*
 sed -i 's/cgc_toupper/toupper/g' $*
+sed -i 's/cgc_vprintf/vprintf/g' $*
 
 sed -i 's/#include "cgc_ctype.h"//' $*
 sed -i 's/#include "cgc_stdarg.h"//' $*