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; }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

Recreate the following C program in x86-64 and aarch64 assembly manually:

#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
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT