int control_digit(char *egn, int *multiplier) {
  int sum = 0, i;
  for (i = 0; i < 9; i++) {
    sum += (egn[i] - '0') * multiplier[i];
  }
  sum = sum % 11;
  if (sum == 10)
    return 0;
  else
    return sum;
}


x86 assembly (clang, -O0):
<control_digit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x9,-0x20(%rbp)
jge    1153 <control_digit+0x53>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
imul   (%rcx,%rdx,4),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <control_digit+0x1a>
mov    -0x1c(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jne    1177 <control_digit+0x77>
movl   $0x0,-0x4(%rbp)
jmp    117d <control_digit+0x7d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<control_digit>:
movsbl (%rdi),%eax
add    $0xffffffd0,%eax
imul   (%rsi),%eax
movq   0x1(%rdi),%xmm0
punpcklbw %xmm0,%xmm0
punpckhwd %xmm0,%xmm1
psrad  $0x18,%xmm1
punpcklwd %xmm0,%xmm0
psrad  $0x18,%xmm0
movdqa 0xed4(%rip),%xmm2
paddd  %xmm2,%xmm0
paddd  %xmm2,%xmm1
movdqu 0x4(%rsi),%xmm2
movdqu 0x14(%rsi),%xmm3
pshufd $0xf5,%xmm1,%xmm4
pshufd $0xf5,%xmm3,%xmm5
pmuludq %xmm4,%xmm5
pshufd $0xf5,%xmm0,%xmm4
pshufd $0xf5,%xmm2,%xmm6
pmuludq %xmm4,%xmm6
shufps $0x88,%xmm5,%xmm6
pmuludq %xmm3,%xmm1
pmuludq %xmm2,%xmm0
shufps $0x88,%xmm1,%xmm0
paddd  %xmm6,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%ecx
add    %eax,%ecx
movslq %ecx,%rcx
imul   $0x2e8ba2e9,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rax
add    %edx,%eax
lea    (%rax,%rax,4),%edx
lea    (%rax,%rdx,2),%eax
sub    %eax,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
cmovne %ecx,%eax
ret

LLVM IR (-O0):
define i32 @control_digit(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %27, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 9
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 48
%19 = load i32*, i32** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = mul nsw i32 %18, %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, %24
store i32 %26, i32* %6
br label %27
27: ; preds = %11
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %8
30: ; preds = %8
%31 = load i32, i32* %6
%32 = srem i32 %31, 11
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 0, i32* %3
br label %38
36: ; preds = %30
%37 = load i32, i32* %6
store i32 %37, i32* %3
br label %38
38: ; preds = %36, %35
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @control_digit(i8* nocapture %0, i32* nocapture %1) {
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
%5 = add nsw i32 %4, -48
%6 = load i32, i32* %1
%7 = mul nsw i32 %5, %6
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = getelementptr inbounds i32, i32* %1, i64 1
%10 = bitcast i8* %8 to <8 x i8>*
%11 = load <8 x i8>, <8 x i8>* %10
%12 = sext <8 x i8> %11 to <8 x i32>
%13 = add nsw <8 x i32> %12, <i32 -48, i32 -48, i32 -48, i32 -48, i32 -48, i32 -48, i32 -48, i32 -48>
%14 = bitcast i32* %9 to <8 x i32>*
%15 = load <8 x i32>, <8 x i32>* %14
%16 = mul nsw <8 x i32> %13, %15
%17 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %16)
%18 = add nsw i32 %17, %7
%19 = srem i32 %18, 11
%20 = icmp eq i32 %19, 10
%21 = select i1 %20, i32 0, i32 %19
ret i32 %21
}