It's interesting how much more "optimization" gcc will do if you take the strlen() call out of the loop. Optimization is an arcane art.
Code:
void decrypt(char *text) {
char key = 'q';
size_t i;
size_t len = strlen(text);
for (i = 0; i < len; i++)
text[i] ^= key;
}
00401334 <_decrypt>:
401334: 55 push %ebp
401335: 57 push %edi
401336: 56 push %esi
401337: 53 push %ebx
401338: 52 push %edx
401339: 8b 5c 24 18 mov 0x18(%esp),%ebx
40133d: 31 c0 xor %eax,%eax
40133f: b9 ff ff ff ff mov $0xffffffff,%ecx
401344: 89 df mov %ebx,%edi
401346: f2 ae repnz scas %es:(%edi),%al
401348: f7 d1 not %ecx
40134a: 49 dec %ecx
40134b: 74 58 je 4013a5 <_decrypt+0x71>
40134d: 89 d8 mov %ebx,%eax
40134f: f7 d8 neg %eax
401351: 83 e0 03 and $0x3,%eax
401354: 89 ce mov %ecx,%esi
401356: 39 c1 cmp %eax,%ecx
401358: 77 52 ja 4013ac <_decrypt+0x78>
40135a: 83 f9 04 cmp $0x4,%ecx
40135d: 77 51 ja 4013b0 <_decrypt+0x7c>
40135f: 89 ce mov %ecx,%esi
401361: 31 c0 xor %eax,%eax
401363: 90 nop
401364: 80 34 03 71 xorb $0x71,(%ebx,%eax,1)
401368: 40 inc %eax
401369: 39 f0 cmp %esi,%eax
40136b: 72 f7 jb 401364 <_decrypt+0x30>
40136d: 39 f1 cmp %esi,%ecx
40136f: 74 34 je 4013a5 <_decrypt+0x71>
401371: 89 cd mov %ecx,%ebp
401373: 29 f5 sub %esi,%ebp
401375: 89 ef mov %ebp,%edi
401377: c1 ef 02 shr $0x2,%edi
40137a: 89 fa mov %edi,%edx
40137c: c1 e2 02 shl $0x2,%edx
40137f: 89 14 24 mov %edx,(%esp)
401382: 74 18 je 40139c <_decrypt+0x68>
401384: 01 de add %ebx,%esi
401386: 31 d2 xor %edx,%edx
401388: 81 34 96 71 71 71 71 xorl $0x71717171,(%esi,%edx,4)
40138f: 42 inc %edx
401390: 39 d7 cmp %edx,%edi
401392: 77 f4 ja 401388 <_decrypt+0x54>
401394: 03 04 24 add (%esp),%eax
401397: 3b 2c 24 cmp (%esp),%ebp
40139a: 74 09 je 4013a5 <_decrypt+0x71>
40139c: 80 34 03 71 xorb $0x71,(%ebx,%eax,1)
4013a0: 40 inc %eax
4013a1: 39 c1 cmp %eax,%ecx
4013a3: 77 f7 ja 40139c <_decrypt+0x68>
4013a5: 58 pop %eax
4013a6: 5b pop %ebx
4013a7: 5e pop %esi
4013a8: 5f pop %edi
4013a9: 5d pop %ebp
4013aa: c3 ret
4013ac: 89 c6 mov %eax,%esi
4013ae: eb aa jmp 40135a <_decrypt+0x26>
4013b0: 85 f6 test %esi,%esi
4013b2: 75 ad jne 401361 <_decrypt+0x2d>
4013b4: 31 c0 xor %eax,%eax
4013b6: eb b9 jmp 401371 <_decrypt+0x3d>