'Inline assembly in C with a jump and two return statements

I would like to have a void function which prints whether carry (overflow) happened and print the value of the (possibly overflowed) summand.

This is my try, but it does want to compile:

#include <stdio.h>

typedef unsigned long ulong;

void
func()
{
    ulong a = 3;
    ulong b = 1;
    ulong c;

    __asm__(
            "\taddq\t%2, %q0\n"     /* Add b to a and store in c */
            "\tjc\tcarry"
            : "=r" (c)              /* Outputs */
            : "0" (a), "rme" (b)    /* Inputs */
            );
    printf("no carry\nc = %lu\n", c);
    return;
    __asm__("carry:");
    printf("carry\nc = %lu\n", c);
    return;
}

int
main()
{
    func();
}

However, it runs when I remove the first return statement, but then it prints twice if no carry happened.

How can I do this with two return statements?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source