Skip to content

Instantly share code, notes, and snippets.

View tobycmurray's full-sized avatar

Toby Murray tobycmurray

View GitHub Profile
@tobycmurray
tobycmurray / signed_overflow.c
Created July 27, 2016 02:39
Signed Integer Overflow as Undefined Behaviour
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
int main(const int argc, const char * argv[]){
int32_t x, y;
if (argc < 3){
fprintf(stderr,"Usage: %s num1 num2\n",argv[0]);
exit(1);
}
@tobycmurray
tobycmurray / HoareProcCall.thy
Created January 20, 2017 00:52
Hoare logic soundness sketch for procedure calls
theory HoareProcCall
imports Main
begin
typedecl state
typedecl procname
typedecl bexpr
datatype com = Call procname | Skip | Cond bexpr com com
enum answer {
GREY,
YELLOW,
GREEN
};
typedef enum answer ans;
int choose_ct(int c, int a, int b)
{
return ((c * a) + ((1 - c) * b));
}