'how to deal with inline assembly

why sum2 result is 6?? ,here is the code

#if defined(__aarch64__)
    
        int tmp=0;
        int sum2=0;
        int a1=2;
           __asm__ __volatile__
        (
            "mov %0,3\n\t"         //tmp=3
            "add %1,%0,%2\n\t"     //sum2=tmp+a1=3+2 ???
            :"=r"(tmp),"=r"(sum2)
            :"r"(a1)
        );
    
    
           LOG_D(TAG,"a=%d\n",sum2);
#endif


Sources

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

Source: Stack Overflow

Solution Source