A compound of formula, or a pharmaceutically acceptable salt thereof: wherein: m is 0 or 1; n is 0, 1 or 2; X is selected from -O-, -S-, -CR d R d -, -CH 2 -O-, -NR d -, -C - and - S -; wherein each occurrence of R d is independently selected from: hydrogen and halogen; R a is selected from: hydrogen and C 1-6 alkyl; each occurrence of R b is independently selected from: hydrogen, halogen and C 1-6 alkyl; or alternatively, two R b groups on the same ring carbon form a 3-4 membered spiro cycloalkyl; or alternatively, two R b groups on adjacent ring carbons together with the two ring carbons form a 3-4 membered fused cycloalkyl; or alternatively, two R b groups on non-adjacent ring carbons together with the nitrogen ring atom form a 5-6 membered nitrogen-containing bridged heterocyclyl; R c is selected from: hydrogen and halogen; R 1 and R 2 together with the carbons to which they are attached form a 5-9 membered monocyclic or bicyclic carbocyclyl; R is seleted from -O-C 1-6 alkyl, C 1-6 alkyl optionally substituted with -OH and each of R 3 and R 4 is independently selected from: hydrogen and C 1-6 alkyl; or alternatively, R 3 and R 4 together with the nitrogen to which they are attached form a 5-6 membered heterocyclyl containing the one nitrogen to which they are attached and zero to two additional hetero atoms independently selected from N, S and O, wherein the heterocyclyl is optionally substituted with one to four substituents independently selected from: (a) halogen, (b) -OH, (c) C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH, (b) halogen and (c) -C -NHR e, wherein R e is selected from (i) hydrogen and (ii) C 1-6 alkyl, (d) -O-C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH and (b) halogen, (e) -NHR f, wherein R f is selected from (i) hydrogen, (ii) C 1-6 alkyl and (iii) -C -C 1-6 alkyl, and (f) -C -C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH and (b) halogen; and R 5 is selected from carbocyclyl and heterocyclyl, wherein each of the carbocyclyl and heterocyclyl is optionally substituted with one to three substituents independently selected from: (a) halogen, (b) C 1-6 alkyl, optionally substituted with one to four halogens, (c) -O-C 1-6 alkyl, optionally substituted with one to four halogens, and (d) -CN. m is 0 or 1; n is 0, 1 or 2; X is selected from -O-, -S-, -CR d R d -, -CH 2 -O-, -NR d -, -C - and - S -; wherein each occurrence of R d is independently selected from: hydrogen and halogen; R a is selected from: hydrogen and C 1-6 alkyl; each occurrence of R b is independently selected from: hydrogen, halogen and C 1-6 alkyl; or alternatively, two R b groups on the same ring carbon form a 3-4 membered spiro cycloalkyl; or alternatively, two R b groups on adjacent ring carbons together with the two ring carbons form a 3-4 membered fused cycloalkyl; or alternatively, two R b groups on non-adjacent ring carbons together with the nitrogen ring atom form a 5-6 membered nitrogen-containing bridged heterocyclyl; R c is selected from: hydrogen and halogen; R 1 and R 2 together with the carbons to which they are attached form a 5-9 membered monocyclic or bicyclic carbocyclyl; R is seleted from -O-C 1-6 alkyl, C 1-6 alkyl optionally substituted with -OH and each of R 3 and R 4 is independently selected from: hydrogen and C 1-6 alkyl; or alternatively, R 3 and R 4 together with the nitrogen to which they are attached form a 5-6 membered heterocyclyl containing the one nitrogen to which they are attached and zero to two additional hetero atoms independently selected from N, S and O, wherein the heterocyclyl is optionally substituted with one to four substituents independently selected from: (a) halogen, (b) -OH, (c) C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH, (b) halogen and (c) -C -NHR e, wherein R e is selected from (i) hydrogen and (ii) C 1-6 alkyl, (d) -O-C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH and (b) halogen, (e) -NHR f, wherein R f is selected from (i) hydrogen, (ii) C 1-6 alkyl and (iii) -C -C 1-6 alkyl, and (f) -C -C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH and (b) halogen; and (a) halogen, (b) -OH, (c) C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH, (b) halogen and (c) -C -NHR e, wherein R e is selected from (i) hydrogen and (ii) C 1-6 alkyl, (d) -O-C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH and (b) halogen, (e) -NHR f, wherein R f is selected from (i) hydrogen, (ii) C 1-6 alkyl and (iii) -C -C 1-6 alkyl, and (f) -C -C 1-6 alkyl, optionally substituted with one to four substituents independently selected from (a) -OH and (b) halogen; and R 5 is selected from carbocyclyl and heterocyclyl, wherein each of the carbocyclyl and heterocyclyl is optionally substituted with one to three substituents independently selected from: (a) halogen, (b) C 1-6 alkyl, optionally substituted with one to four halogens, (c) -O-C 1-6 alkyl, optionally substituted with one to four halogens, and (d) -CN. (a) halogen, (b) C 1-6 alkyl, optionally substituted with one to four halogens, (c) -O-C 1-6 alkyl, optionally substituted with one to four halogens, and (d) -CN.