Big Integer Addition Simulation

/*
Time limit: 5000ms
Memory limit: 256mb

---------------------Copy the following code, complete it and submit---------------------
I, <Your Full Name>, am submitting the assignment for
an individual project.
I declare that the assignment here submitted is original except for
source material explicitly acknowledged, the piece of work, or a part
of the piece of work has not been submitted for more than one purpose
(i.e. to satisfy the requirements in two different courses) without
declaration. I also acknowledge that I am aware of University policy
and regulations on honesty in academic work, and of the disciplinary
guidelines and procedures applicable to breaches of such policy and
regulations, as contained in the University website
http://www.cuhk.edu.hk/policy/academichonesty/.
It is also understood that assignments without a properly signed
declaration by the student concerned will not be graded by the
teacher(s).
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN 1005

struct BigInt {
    int *digits;
};

// function prototypes
struct BigInt init_bigint(void);
void free_bigint(struct BigInt b);
struct BigInt create_bigint_from_string(const char *s);
struct BigInt add_bigint(struct BigInt b1, struct BigInt b2);
void print_bigint(struct BigInt b);


/**
 * @brief create a BigInt struct
 * @return a BigInt struct
 */
struct BigInt init_bigint(void) {
    struct BigInt b;
    b.digits = (int *)malloc(MAX_LEN * sizeof(int));
    for (int i = 0; i < MAX_LEN; i++) {
        b.digits[i] = 0;
    }
    return b;
}

/**
 * @brief free the memory allocated for a BigInt struct
 * @param b a BigInt struct
 */
void free_bigint(struct BigInt b) {
    free(b.digits);
}

/**
 * @brief create a BigInt struct from a string
 * @param s a string representing a number
 * @return a BigInt struct
 */
struct BigInt create_bigint_from_string(const char *s) {
    struct BigInt b;
    b = init_bigint();

    int len = strlen(s);
    for (int i = 0; i < len; i++) {
        b.digits[i] = s[len - i - 1] - '0';
    }
    return b;
}

/**
 * @brief add two BigInts
 * @param b1 a BigInt struct
 * @param b2 a BigInt struct
 * @return the sum of b1 and b2
 */
struct BigInt add_bigint(struct BigInt b1, struct BigInt b2) {
    // WRITE YOUR CODE HERE

}


/**
 * @brief print a BigInt struct
 * @param b a BigInt struct
 */
void print_bigint(struct BigInt b) {
    int i = MAX_LEN - 1;
    while (i >= 0 && b.digits[i] == 0) {
        i--;
    }
    if (i == -1) {
        printf("0");
    } else {
        for (; i >= 0; i--) {
            printf("%d", b.digits[i]);
        }
    }
    printf("\n");
}


// DO NOT MODIFY THE CODE BELOW
int main(void) {
    char s1[MAX_LEN], s2[MAX_LEN];
    scanf("%s%s", s1, s2);

    struct BigInt b1 = create_bigint_from_string(s1);
    struct BigInt b2 = create_bigint_from_string(s2);
    struct BigInt b = add_bigint(b1, b2);
    print_bigint(b);

    free_bigint(b1);
    free_bigint(b2);
    free_bigint(b);
    return 0;
}


---------------------------------------End of Code---------------------------------------

## Big Integer Addition Simulation

In C language, integers have size limitations. For example, 32-bit unsigned integers can only represent numbers up to $2^{32}-1$. To handle larger numbers, we need arbitrary-precision arithmetic.

A common approach is to store each digit of a large number in an array. For example, the number `12345` can be stored as `int a[5] = {5, 4, 3, 2, 1}`, where the least significant digit is at index 0.

To add two large numbers, we can simulate the traditional "vertical addition" method:
1. Start from the least significant digits (index 0)
2. Add corresponding digits from both numbers
3. Handle any carry to the next position
4. Continue until all digits are processed

Your task is to implement this arbitrary-precision addition for positive integers. We provide the `BigInt` data structure and helper methods. You need to implement the `add_bigint` function.

We guarantee that all input numbers are less than or equal to $1000$ digits long, and their sum will also be less than or equal to $1000$ digits.

### Input
- Two positive integers with length less than or equal to $1000$.
- Input is guaranteed to be strings containing only digits.

### Output
The sum of the two numbers as a string. 

### Example
**Input**
```
86734890123
2435788245623
```

**Output**
```
2522523135746
```

Submit