Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ int main(void)

if (is_sorted(numbers, 6))
/* TODO use goto instead of break */
break;
goto end;
}

end:
for (i = 0; i < 6; i++)
printf("%d ", numbers[i]);
printf("\n");
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ int main(void)
float x = 42;

/* drunk, fix later */
begin:
while (ago < 0x2a) {
printf("http://stackoverflow.com/questions/184618/what-is-the-best
-comment-in-source-code-you-have-ever-encountered\n");
printf("http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered\n");
ago++;
continue; /* TODO: use goto for Pete's sake! */
goto begin; /* TODO: use goto for Pete's sake! */
printf("Fast inverse square root: %f\n", Q_rsqrt(x)); /* i'm sorry */
}

Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ int main(void)
/* TODO: Implement finding the maximum value in the vector */
max = v[0];
i = 1;
loop:
if (i >= 7)
goto end;
if (v[i] > max)
max = v[i];
i++;
goto loop;

end:
printf("%d\n", max);
(void) i;
(void) max;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
// SPDX-License-Identifier: BSD-3-Clause

#include <stdio.h>

int main(void)
{
int v[] = {1, 2, 15, 51, 53, 66, 202, 7000};
int dest = v[2]; /* 15 */
int start = 0;
int end = sizeof(v) / sizeof(int) - 1;
int main(void) {
int v[] = {1, 2, 15, 51, 53, 66, 202, 7000};
int dest = v[2]; /* 15 */
int start = 0;
int end = sizeof(v) / sizeof(int) - 1;
int found = 0;
int mid;

binary_search:
if (start > end)
goto not_found;
mid = (start + end) / 2;
if (v[mid] == dest) {
found = 1;
goto found;
} else if (v[mid] < dest) {
start = mid + 1;
goto binary_search;
} else {
end = mid - 1;
goto binary_search;
}

not_found:
printf("not found.\n");
goto end_prog;

/* TODO: Implement binary search */
(void) dest;
(void) start;
(void) end;
found:
printf("index %d.\n", mid);
goto end_prog;

end_prog:
return 0;
}

Binary file not shown.
Binary file modified laborator/content/toolchain-decompilare/4-tutorial-ghidra/crackme
100644 → 100755
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./crackme AAAEAAAA
Binary file not shown.