If you're going to certain kinds of parties, it's wise to arrive in disguise, or at least to have something interesting on under the surface. Rihanna's "S&M" doesn't seem to be much on subtext, at least at first—her performing persona has always had a touch of emotional masochism to it, and the lyrics and video just make that explicit. But it's actually got a lot going on beneath its frantic barrage of hooks: subtle acknowledgments of a little tradition of pop about reaching for release through eroticized physical pain.

Understandably, "S&M" plays a little too rough for some listeners: the BBC's censored version, for instance, removes not only the word "sex" (on which Rihanna's voice cracks just a little, deliciously) but "chains" and "whips." Still, it's managed to become a massive hit on the strength of its craft. The song was written by Ester Dean and Stargate—whose work for Rihanna I've discussed in this column before—along with a few other people, including French songwriter Sandy Vee, whose other credits include Katy Perry's "Firework" and Pitbull's "Hey Baby." (For the record, the catchphrase "Sticks and Stones May Break My Bones But Whips and Chains [sic] Excite Me" isn't original to them: it's a commonplace that's made the rounds for a few decades. Serial killer Joel Rifkin was reported to have it as a bumper sticker on his pickup truck in 1993.)

Listen at the two-and-a-half minute mark of "S&M," though, and you'll hear a little synth line that might be naggingly familiar if you ever went to a goth club after Ronald Reagan's first term. It's one of the hooks from Depeche Mode's 1984 single "Master and Servant"—a new-wave take on sadomasochism, complete with cracking-whip sound effects. (Points to songwriter Martin Gore for keeping his tongue firmly in cheek. Rihanna's song frames BDSM as a way of expressing her innermost self; Gore's lyric frames it as a way to get some healthy distance from that self—"it's a lot like life/and that's what's appealing.") Stargate have to know what they're nodding to: they remixed Depeche Mode's "Personal Jesus" very recently.

That snatch of melody didn't start there: it first surfaced in 1982, as the hook of the Cure's single "Let's Go to Bed." At the time, "Let's Go to Bed" was a startling departure for the Cure, whose four albums had been descending into increasingly deep despair: Pornography, earlier that year, had begun with singer Robert Smith gasping "it doesn't matter if we all die" and ended with him screaming "I must fight this sickness/Find a cure." "Let's Go to Bed" isn't exactly a well-adjusted song, but given their history, it was a weirdly chipper one: Smith's idea of a solution for existential detachment ("I don't care if you don't/And I don't feel if you don't"), it turned out, was finding sex in the air.

Rihanna's "come on," on the other hand, seems to come from a much less morose band. The Stooges were punk rock before there was such a thing, and the centerpiece of their 1969 debut album was "I Wanna Be Your Dog," a glazed-eyed masochistic headbang with the stupidest riff of all time and somebody hammering at a single piano note like it's the only thing possible to do any more. The desire that their singer Iggy Pop was yowling about was something like Rihanna's and something like the other end of it, but his "come on" at the end of every chorus was no less a demand than hers. (For a band that really only made three records, the Stooges were mighty influential—a couple of weeks ago, I discussed how their spectre haunts Lupe Fiasco's "The Show Goes On.")

Another piece of the puzzle might be Lacuna Coil's 2009 song "I Like It." They owe rather a lot to British new wave for an Italian goth-metal band, and if singer Cristina Scabbia's lyrics don't paint quite the same sort of picture of consensual submission as Rihanna's, they use the same language as both "S&M" and "Master & Servant": "You think you're the master, I'm the slave... You can kiss your fairy tale away/I like it, like it/How do you like it?" Come on!

The other notable "I like it, like it" in pop history, though, is signaled by the very last shot of the "S&M" video, in which Rihanna's got stickers and bandages all over her face. Her mouth is covered by a knockoff of the Rolling Stones' logo, a mouth with tongue extended. The Stones have never been shy about deploying sadomasochistic imagery—see, for instance, 1978's "When The Whip Comes Down," in which Mick Jagger sang in the persona of a gay hustler with a taste for rough action. But the best-known song in which he presents himself as being as much in the public eye as Rihanna does in her video, then imagines sexualized violence to himself, is "It's Only Rock 'n' Roll," from 1974: "If I could stick a knife in my heart/Suicide right on the stage/Would it be enough for your teenage lust?" And then he changes the subject to rock. "I like it, like it/Yes I do," he sings. It's amazing what people can like.