something like the following

IF A

BEGIN

IF B

BEGIN

SET x = x + 1

END

SET y = y + 1

END

IF NOT A

BEGIN

IF C

BEGIN

IF D

BEGIN

SET z = z + 1

END

IF NOT D

BEGIN

Set z = z - 1

END

SET ab = ab + 1

END

END

IF A

BEGIN

IF B

BEGIN

SET x = x + 1

END

SET y = y + 1

END

IF NOT A

BEGIN

IF C

BEGIN

IF D

BEGIN

SET z = z + 1

END

IF NOT D

BEGIN

Set z = z - 1

END

SET ab = ab + 1

END

END