void invertEnigmaRotor(unsigned *in, unsigned *out) {
  for (int i = 0; i < 26; ++i)
    out[(i + in[i]) % 26] = in[i];
}


x86 assembly (clang, -O0):
<invertEnigmaRotor>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1a,-0x14(%rbp)
jge    1166 <invertEnigmaRotor+0x66>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    $0x1a,%ecx
xor    %edx,%edx
div    %ecx
mov    -0x20(%rbp),%rax
mov    %edx,%ecx
mov    -0x18(%rbp),%edx
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <invertEnigmaRotor+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<invertEnigmaRotor>:
mov    $0x1,%r8d
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    (%rdi,%rcx,4),%r9d
lea    (%r9,%rcx,1),%eax
imul   $0x4ec4ec4f,%rax,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %eax,%edx
mov    %r9d,%eax
sub    %edx,%eax
add    %ecx,%eax
mov    %r9d,(%rsi,%rax,4)
mov    0x4(%rdi,%rcx,4),%r9d
lea    (%r9,%r8,1),%edx
imul   $0x4ec4ec4f,%rdx,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,4),%eax
lea    (%rax,%rax,4),%eax
add    %edx,%eax
mov    %r9d,%edx
sub    %eax,%edx
lea    (%rcx,%rdx,1),%eax
add    $0x1,%eax
mov    %r9d,(%rsi,%rax,4)
add    $0x2,%rcx
add    $0x2,%r8d
cmp    $0x1a,%rcx
jne    1110 <invertEnigmaRotor+0x10>
ret

LLVM IR (-O0):
define void @invertEnigmaRotor(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %26, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 26
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load i32, i32* %13
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = add i32 %16, %21
%23 = urem i32 %22, 26
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %15, i64 %24
store i32 %14, i32* %25
br label %26
26: ; preds = %9
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %6
29: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @invertEnigmaRotor(i32* nocapture %0, i32* nocapture writeonly %1) {
br label %4
3: ; preds = %4
ret void
4: ; preds = %4, %2
%5 = phi i64 [ 0, %2 ], [ %21, %4 ]
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = trunc i64 %5 to i32
%9 = add i32 %7, %8
%10 = urem i32 %9, 26
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %1, i64 %11
store i32 %7, i32* %12
%13 = or i64 %5, 1
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = trunc i64 %13 to i32
%17 = add i32 %15, %16
%18 = urem i32 %17, 26
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %1, i64 %19
store i32 %15, i32* %20
%21 = add nuw nsw i64 %5, 2
%22 = icmp eq i64 %21, 26
br i1 %22, label %3, label %4
}