Convert into C program

Hi,

in this forum I was able to find a logic written by perderabo to write packed decimals. the code works fine. However, I would want to convert it to a c program. so as to do that I am not able to understand the below mentioned logic. Can someone please help me understand that?

if ((packswitch)) ; then
                char1=$dig
                octal=16#${char1}${char2}
                result=${octal#??}
                echo packing $olength $char1 $char2 $octal $result
                output[olength]=$(print -n \\${result})
                ((olength=olength-1))

        else
                char2=$dig
        fi

Link to perderabo's code