aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/ask/lista5/zad1.c
diff options
context:
space:
mode:
Diffstat (limited to 'Semestr 4/ask/lista5/zad1.c')
-rw-r--r--Semestr 4/ask/lista5/zad1.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Semestr 4/ask/lista5/zad1.c b/Semestr 4/ask/lista5/zad1.c
new file mode 100644
index 0000000..9379bb2
--- /dev/null
+++ b/Semestr 4/ask/lista5/zad1.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdint.h>
+
+int puzzle(long x /* rdi */ , unsigned n /* rsi */) {
+ if (n == 0) {
+ return n;
+ }
+ int t = 0; // edx := 0
+ int result = 0; // eax := 0
+ do {
+ int m = x & 0xffffffff; // ecx := edi
+ m &= 1;
+ result += m;
+ x >>= 1;
+ t++;
+ } while (t != n);
+ return result; // ????
+}
+
+int main() {
+ long x;
+ unsigned n;
+ scanf("%ld%u", &x, &n);
+ return puzzle(x, n);
+} \ No newline at end of file