-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,019 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
uint64_t b; | ||
uint64_t c; | ||
uint64_t *x; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
a = 0; | ||
b = 0; | ||
|
||
c = read(0, x, 1); | ||
a = *x; | ||
|
||
if (a == 1) { | ||
exit(0); | ||
} | ||
if (c == 0) { | ||
exit(0); | ||
} | ||
|
||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
|
||
c = read(0, x, 1); | ||
b = *x; | ||
|
||
if (b == 1) { | ||
exit(0); | ||
} | ||
if (c == 0) { | ||
exit(0); | ||
} | ||
|
||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
uint64_t b; | ||
uint64_t c; | ||
uint64_t *x; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
a = 0; | ||
b = 0; | ||
|
||
c = read(0, x, 2); | ||
a = *x; | ||
|
||
if (c == 0) { | ||
exit(0); | ||
} | ||
|
||
a = a - 1; | ||
|
||
if (a == 1) { | ||
if (c == 1) | ||
exit(0); | ||
} | ||
|
||
a = a - 1; | ||
|
||
if (c == 1) { | ||
exit(0); | ||
} | ||
|
||
a = a - 1; | ||
|
||
b = (*x + 1); | ||
|
||
if (b == 1) { | ||
exit(0); | ||
} | ||
if (c == 0) { | ||
exit(0); | ||
} | ||
|
||
a = a - 1; | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
uint64_t b; | ||
uint64_t c; | ||
uint64_t *x; | ||
|
||
a = 1; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
while (a <= 3) { | ||
b = read(0, x, SIZEOFUINT8); | ||
|
||
if (b == 0) { | ||
return 0; | ||
} | ||
|
||
b = 0; | ||
while (b < a * a) { | ||
c = 0; | ||
while (c < 20) { | ||
c = c + 1; | ||
} | ||
|
||
b = b + 1; | ||
} | ||
|
||
a = a + 1; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t b; | ||
uint64_t c; | ||
uint64_t d; | ||
uint64_t *x; | ||
|
||
d = 0; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
b = read(0, x, SIZEOFUINT32); | ||
d = *x; | ||
|
||
c = b; | ||
while (c > 0) { | ||
c = c - 1; | ||
} | ||
if (d == 1) | ||
exit(0); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
uint64_t b; | ||
uint64_t c; | ||
uint64_t d; | ||
uint64_t *x; | ||
|
||
d = 0; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
b = read(0, x, SIZEOFUINT32); | ||
d = *x; | ||
|
||
c = b; | ||
while (c > 0) { | ||
c = c - 1; | ||
} | ||
if (d == 1) | ||
exit(0); | ||
|
||
a = 0; | ||
while (a < b * b) { | ||
c = 0; | ||
while (c < 20) { | ||
c = c + 1; | ||
} | ||
a = a + 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
|
||
a = VERIFIER_nondet_uchar(); | ||
|
||
if (a == 0) | ||
exit(0); | ||
else { | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
a = a - 1; | ||
exit(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
uint64_t b; | ||
uint64_t *x; | ||
|
||
a = 0; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
while (a < 3) { | ||
b = read(0, x, SIZEOFUINT8); | ||
|
||
if (b == 0) { | ||
return 0; | ||
} | ||
a = a + 1; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = 1 | ||
// @UNROLL = 100 | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
uint64_t main() { | ||
uint64_t a; | ||
uint64_t b; | ||
uint64_t c; | ||
uint64_t *x; | ||
|
||
a = 0; | ||
|
||
x = malloc(8); | ||
*x = 0; | ||
|
||
while (a < 3) { | ||
b = read(0, x, 1); | ||
|
||
c = *x; | ||
|
||
if (c == 1) { | ||
return 0; | ||
} | ||
|
||
if (b == 0) { | ||
return 0; | ||
} | ||
a = a + 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// cksystemsgroup.github.io/unicorn | ||
// @SOLUTIONS = TODO | ||
// @UNROLL = TODO | ||
|
||
/*#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <unistd.h>*/ | ||
|
||
uint64_t found_position(uint64_t m, uint64_t* arr, uint64_t p, uint64_t to_swap) { | ||
if (m > 0) | ||
if (*(arr + p) > to_swap) | ||
return 1; | ||
|
||
return 0; | ||
} | ||
|
||
uint64_t main() { | ||
uint64_t* arr; | ||
uint64_t* buffer; | ||
uint64_t size; | ||
|
||
uint64_t to_swap; | ||
|
||
uint64_t n; | ||
uint64_t m; | ||
|
||
uint64_t read_bytes; | ||
|
||
size = 8; | ||
|
||
arr = malloc(size * SIZEOFUINT64); | ||
buffer = malloc(SIZEOFUINT64); | ||
|
||
*buffer = 0; | ||
|
||
// initialize array with user input | ||
// printf("Insert initial values.\n"); | ||
n = 0; | ||
while (n < size) { | ||
read_bytes = read(0, buffer, SIZEOFUINT32); | ||
|
||
if (read_bytes == 0) | ||
size = n; | ||
else | ||
*(arr + n) = *buffer; | ||
|
||
n = n + 1; | ||
} | ||
|
||
// debug | ||
/*printf("Unsorted array: [ "); | ||
n = 0; | ||
while (n < size) { | ||
printf("%ld ", *(arr + n)); | ||
n = n + 1; | ||
} | ||
printf("]\n"); | ||
fflush(stdout);*/ | ||
|
||
// sort array using insertion sort | ||
// worst-case time complexity: O(n^2) | ||
// best-case time complexity: O(n) | ||
n = 1; | ||
while (n < size) { | ||
// next element to insert into correct slot | ||
to_swap = *(arr + n); | ||
|
||
// find correct slot | ||
m = n; | ||
while (found_position(m, arr, m - 1, to_swap)) { | ||
*(arr + m) = *(arr + m - 1); | ||
|
||
m = m - 1; | ||
} | ||
|
||
// swap next element into correct slot | ||
*(arr + m) = to_swap; | ||
|
||
n = n + 1; | ||
} | ||
|
||
// debug | ||
/*printf("Sorted array: [ "); | ||
n = 0; | ||
while (n < size) { | ||
printf("%ld ", *(arr + n)); | ||
n = n + 1; | ||
} | ||
printf("]\n"); | ||
fflush(stdout); | ||
// gcc / valgrind | ||
free(arr);*/ | ||
} |
Oops, something went wrong.