Recreate the following C program in x86-64 and aarch64 assembly manually: #include typedef struct _v2d { long x; long y; } v2d_t; static long dot(v2d_t a, v2d_t b) { return a.x * b.x + a.y * b.y; } static long dot_ptr(v2d_t *a, v2d_t *b) { return a->x * b->x + a->y * b->y; } int main(void) { v2d_t a, b; scanf("%ld %ld %ld %ld", &a.x, &a.y, &b.x, &b.y); long res1 = dot(a, b); printf("%ld\n", res1); long res2 = dot_ptr(&a, &b); printf("%ld\n", res2); return 0; }
Recreate the following C program in x86-64 and aarch64 assembly manually: #include typedef struct _v2d { long x; long y; } v2d_t; static long dot(v2d_t a, v2d_t b) { return a.x * b.x + a.y * b.y; } static long dot_ptr(v2d_t *a, v2d_t *b) { return a->x * b->x + a->y * b->y; } int main(void) { v2d_t a, b; scanf("%ld %ld %ld %ld", &a.x, &a.y, &b.x, &b.y); long res1 = dot(a, b); printf("%ld\n", res1); long res2 = dot_ptr(&a, &b); printf("%ld\n", res2); return 0; }
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7RQ
Related questions
Question
Recreate the following C
#include <stdio.h>
typedef struct _v2d {
long x;
long y;
} v2d_t;
static long dot(v2d_t a, v2d_t b)
{
return a.x * b.x + a.y * b.y;
}
static long dot_ptr(v2d_t *a, v2d_t *b)
{
return a->x * b->x + a->y * b->y;
}
int main(void)
{
v2d_t a, b;
scanf("%ld %ld %ld %ld", &a.x, &a.y, &b.x, &b.y);
long res1 = dot(a, b);
printf("%ld\n", res1);
long res2 = dot_ptr(&a, &b);
printf("%ld\n", res2);
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT