src/codegen.c
char *
generateOr(Scope *scope, Expr *expr, bool *needsCopy) {

  int loc1 = getNewNum();

  char *tempExpr1 = generateExpr(scope, expr->binop.exp1, needsCopy);
  if (*needsCopy) {
    fprintf(context.out, "\t%%v%d =%s copy %s\n", loc1,
            generateType(expr->typeExpr), tempExpr1);
  } else {
    fprintf(context.out, "\t%%v%d =%s %s\n", loc1, generateType(expr->typeExpr),
            tempExpr1);
  }

  int jmp1 = getNewNum();
  int jmp2 = getNewNum();
  int jmp3 = getNewNum();
  int jmp4 = getNewNum();

  fprintf(context.out, "\tjnz %%v%d, @j%d, @j%d\n", loc1, jmp2, jmp1);
  fprintf(context.out, "@j%d\n", jmp1);

  int loc2 = getNewNum();

  char *tempExpr2 = generateExpr(scope, expr->binop.exp2, needsCopy);

  if (*needsCopy) {
    fprintf(context.out, "\t%%v%d =%s copy %s\n", loc2,
            generateType(expr->typeExpr), tempExpr2);
  } else {
    fprintf(context.out, "\t%%v%d =%s %s\n", loc2, generateType(expr->typeExpr),
            tempExpr2);
  }

  fprintf(context.out, "\tjnz %%v%d, @j%d, @j%d\n", loc2, jmp2, jmp3);

  fprintf(context.out, "@j%d\n", jmp2);

  int loc3 = getNewNum();

  fprintf(context.out, "\t%%v%d =l copy 1\n", loc3);
  fprintf(context.out, "\tjmp @j%d\n", jmp4);

  fprintf(context.out, "@j%d\n", jmp3);
  fprintf(context.out, "\t%%v%d =l copy 0\n", loc3);
  fprintf(context.out, "@j%d\n", jmp4);

  *needsCopy = true;

  return msprintf("%%v%d", loc3);
}
/* A boolean 'or' will not evaluate the right hand side if the first value
 * evaluates to true
 */
A boolean 'or' will not evaluate the right hand side if the first value
evaluates to true
A boolean ' or ' will not evaluate the right hand side if the first value evaluates to true
char *
generateOr(Scope *scope, Expr *expr, bool *needsCopy) {
  int loc1 = getNewNum();
  char *tempExpr1 = generateExpr(scope, expr->binop.exp1, needsCopy);
  if (*needsCopy) {
    fprintf(context.out, "\t%%v%d =%s copy %s\n", loc1,
            generateType(expr->typeExpr), tempExpr1);
  } else {
    fprintf(context.out, "\t%%v%d =%s %s\n", loc1, generateType(expr->typeExpr),
            tempExpr1);
  }
  int jmp1 = getNewNum();
  int jmp2 = getNewNum();
  int jmp3 = getNewNum();
  int jmp4 = getNewNum();
  fprintf(context.out, "\tjnz %%v%d, @j%d, @j%d\n", loc1, jmp2, jmp1);
  fprintf(context.out, "@j%d\n", jmp1);
  int loc2 = getNewNum();
  char *tempExpr2 = generateExpr(scope, expr->binop.exp2, needsCopy);
  if (*needsCopy) {
    fprintf(context.out, "\t%%v%d =%s copy %s\n", loc2,
            generateType(expr->typeExpr), tempExpr2);
  } else {
    fprintf(context.out, "\t%%v%d =%s %s\n", loc2, generateType(expr->typeExpr),
            tempExpr2);
  }
  fprintf(context.out, "\tjnz %%v%d, @j%d, @j%d\n", loc2, jmp2, jmp3);
  fprintf(context.out, "@j%d\n", jmp2);
  int loc3 = getNewNum();
  fprintf(context.out, "\t%%v%d =l copy 1\n", loc3);
  fprintf(context.out, "\tjmp @j%d\n", jmp4);
  fprintf(context.out, "@j%d\n", jmp3);
  fprintf(context.out, "\t%%v%d =l copy 0\n", loc3);
  fprintf(context.out, "@j%d\n", jmp4);
  *needsCopy = true;
  return msprintf("%%v%d", loc3);
}
char * generateOr ( Scope * scope , Expr * expr , bool * needsCopy ) { int loc1 = getNewNum ( ) ; char * tempExpr1 = generateExpr ( scope , expr -> binop . exp1 , needsCopy ) ; if ( * needsCopy ) { fprintf ( context . out , " \t \n " , loc1 , generateType ( expr -> typeExpr ) , tempExpr1 ) ; } else { fprintf ( context . out , " \t \n " , loc1 , generateType ( expr -> typeExpr ) , tempExpr1 ) ; } int jmp1 = getNewNum ( ) ; int jmp2 = getNewNum ( ) ; int jmp3 = getNewNum ( ) ; int jmp4 = getNewNum ( ) ; fprintf ( context . out , " \t \n " , loc1 , jmp2 , jmp1 ) ; fprintf ( context . out , " \n " , jmp1 ) ; int loc2 = getNewNum ( ) ; char * tempExpr2 = generateExpr ( scope , expr -> binop . exp2 , needsCopy ) ; if ( * needsCopy ) { fprintf ( context . out , " \t \n " , loc2 , generateType ( expr -> typeExpr ) , tempExpr2 ) ; } else { fprintf ( context . out , " \t \n " , loc2 , generateType ( expr -> typeExpr ) , tempExpr2 ) ; } fprintf ( context . out , " \t \n " , loc2 , jmp2 , jmp3 ) ; fprintf ( context . out , " \n " , jmp2 ) ; int loc3 = getNewNum ( ) ; fprintf ( context . out , " \t \n " , loc3 ) ; fprintf ( context . out , " \t \n " , jmp4 ) ; fprintf ( context . out , " \n " , jmp3 ) ; fprintf ( context . out , " \t \n " , loc3 ) ; fprintf ( context . out , " \n " , jmp4 ) ; * needsCopy = true ; return msprintf ( " " , loc3 ) ; }
A boolean 'or' will not evaluate the right hand side if the first value
 evaluates to true
A boolean ' or ' will not evaluate the right hand side if the first value evaluates to true