# 10 inputs
# 1 outputs
# 8 D-type flipflops
# 38 inverters
# 66 gates (21 ANDs + 15 NANDs + 14 ORs + 16 NORs)

INPUT(P.0)
INPUT(C.8)
INPUT(C.7)
INPUT(C.6)
INPUT(C.5)
INPUT(C.4)
INPUT(C.3)
INPUT(C.2)
INPUT(C.1)
INPUT(C.0)

OUTPUT(Z)

X.4 = DFF(I12)
X.3 = DFF(I13)
X.2 = DFF(I14)
X.1 = DFF(I15)
X.8 = DFF(I110)
X.7 = DFF(I111)
X.6 = DFF(I112)
X.5 = DFF(I113)

I73.1 = NOT(I69)
I73.2 = NOT(X.3)
I7.1 = NOT(I66)
I7.2 = NOT(X.2)
I88.1 = NOT(X.1)
I88.2 = NOT(P.0)
I48 = NOT(P.0)
I49 = NOT(X.4)
I50 = NOT(X.3)
I68 = NOT(I69)
I105.1 = NOT(I163)
I105.2 = NOT(X.6)
I182.1 = NOT(X.5)
I182.2 = NOT(I1.2)
I148 = NOT(X.7)
I149 = NOT(X.6)
I161 = NOT(I162)
I164 = NOT(I163)
I212 = NOT(P.0)
I213 = NOT(X.1)
I214 = NOT(X.2)
I215 = NOT(X.3)
I216 = NOT(X.4)
I225 = NOT(I224)
I240 = NOT(P.0)
I241 = NOT(X.5)
I242 = NOT(X.6)
I243 = NOT(X.7)
I244 = NOT(X.8)
I252 = NOT(I251)
I282 = NOT(P.2)
I283 = NOT(P.3)
I286 = NOT(C.2)
I287 = NOT(C.3)
I306 = NOT(P.6)
I307 = NOT(P.7)
I310 = NOT(C.6)
I311 = NOT(C.7)

I73.3 = AND(I69, I73.2)
I73.4 = AND(X.3, I73.1)
I7.3 = AND(I66, I7.2)
I7.4 = AND(X.2, I7.1)
I88.3 = AND(X.1, I88.2)
I88.4 = AND(P.0, I88.1)
I105.3 = AND(I163, I105.2)
I105.4 = AND(X.6, I105.1)
I182.3 = AND(X.5, I182.2)
I182.4 = AND(I1.2, I182.1)
I191.1 = AND(I164, X.6)
I1.2 = AND(I2.1, P.0)
P.5 = AND(I209.1, I205.2)
P.6 = AND(I209.1, I206.2)
P.7 = AND(I209.1, I207.2)
P.8 = AND(I209.1, I208.2)
I295.1 = AND(P.1, C.1)
I295.2 = AND(P.0, C.0)
I319.1 = AND(P.5, C.5)
I319.2 = AND(P.4, C.4)
I270.3 = AND(P.8, C.8)

I70.1 = OR(I68, X.4, I50)
I13 = OR(I73.3, I73.4)
I15 = OR(I88.3, I88.4)
I95.1 = OR(I64, I50, I48)
I167.1 = OR(I165, X.8, I148)
I170.1 = OR(I165, X.7)
I113 = OR(I182.3, I182.4)
I188.1 = OR(I163, I149, I148)
I291.1 = OR(I283, I287)
I291.2 = OR(I282, I286)
I315.1 = OR(I307, I311)
I315.2 = OR(I306, I310)
I270.2 = OR(I269.1, I269.2)
Z = OR(I270.2, I270.3)

I12 = NAND(I70.1, I62)
I62 = NAND(I95.1, X.4)
I64 = NAND(X.1, X.2)
I66 = NAND(X.1, P.0)
I110 = NAND(I167.1, I159)
I111 = NAND(I170.1, I161)
I159 = NAND(I188.1, X.8)
I163 = NAND(X.5, I1.2)
I165 = NAND(I164, X.6)
I222 = NAND(I225, I214)
I224 = NAND(I213, P.0)
I249 = NAND(I252, I242)
I251 = NAND(I241, P.0)
I269.1 = NAND(I291.1, I291.2, I290)
I269.2 = NAND(I315.1, I315.2, I314)

I14 = NOR(I7.3, I7.4)
I2.1 = NOR(I64, I49, I50)
I69 = NOR(I64, I48)
I112 = NOR(I105.3, I105.4)
I162 = NOR(I148, I191.1)
P.1 = NOR(I212, I213)
P.2 = NOR(I214, I224)
P.3 = NOR(I215, I222)
P.4 = NOR(X.3, I222, I216)
I209.1 = NOR(X.4, X.2, X.3, X.1)
I205.2 = NOR(I240, I241)
I206.2 = NOR(I242, I251)
I207.2 = NOR(I243, I249)
I208.2 = NOR(X.7, I249, I244)
I290 = NOR(I295.1, I295.2)
I314 = NOR(I319.1, I319.2)

