#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

char ffff[] = {0x49, 0x47, 0x43, 0x54, 0x46, 0x7b, 0x52, 0x00};

void f1() { printf("Let's play a fun game, I'm very good at this!\n"); }

void f2() {
  printf("Because I'm such a pro in this game, I'll up the stakes.\n");
}

char llll[] = {0x65, 0x76, 0x33, 0x72, 0x73, 0x65, 0x45, 0x00};

void f3() { printf("If you beat me, I'll give you a flag, how about that?\n"); }

void f4() {
  printf("The game is quite simple, type 'roll' to roll the dice.\n");
}

void f5() {
  printf(
      "Because I upped the stakes, I also win if I roll the same number. Fair "
      "game.\n");
}

char aaaa[] = {0x6e, 0x67, 0x31, 0x6e, 0x33, 0x33, 0x72, 0x00};

void f6(int p) { printf("\nYou rolled: %i\n", p); }
void f7(int c) { printf("I rolled: %i\n", c); }

int f9() { return (rand() % 6) + 1; }

char gggg[] = {0x31, 0x6e, 0x67, 0x31, 0x30, 0x31, 0x7d, 0x00};

int f10(int a) { return (rand() % (6 - a + 1)) + a; }

int main(int argc, char const *argv[]) {
  f1();
  char x = 0x62;
  char y = 0x61;
  f2();
  char z = 0x69;
  srand(time(0));
  f3();
  char input[128];
  f4();
  char a = 0x74;
  f5();
  printf("\nRoll the dice!\n");
  fgets(input, sizeof(input), stdin);
  if (strcmp(input, "roll\n")) {
    printf(
        "I thought the instructions were simple? Simply type 'roll' to roll "
        "the dice!\n");
  } else {
    int player = f9();
    f6(player);
    int cpu = f10(player);
    f7(cpu);
    if (cpu >= player) {
      printf("\nAha, I won! I keep on winning!\n");
    } else {
      printf("\nWow, you actually beat me. Here is, as promised, your flag:\n");
      printf("%s", ffff);
      printf("%s", llll);
      printf("%s", aaaa);
      printf("%s", gggg);
    }
  }
}
