int main(void) {
  check_vect();
  unsigned char a[50], b[50];
  int expected = 0x12345;
  for (int i = 0; i < 50; ++i) {
    a[i] = ((unsigned int)-1 < 0 ? -126 : 4) + i * 5;
    b[i] = ((unsigned int)-1 < 0 ? -126 : 4) + 20 + i * 4;
    asm volatile("" ::: "memory");
    expected += (signed short)(a[i] * b[i]);
  }
  if (f(0x12345, a, b) != expected)
    __builtin_abort();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <check_vect@plt>
movl   $0x12345,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
cmpl   $0x32,-0x88(%rbp)
jge    11d6 <main+0xa6>
imul   $0x5,-0x88(%rbp),%eax
add    $0x4,%eax
mov    %al,%cl
movslq -0x88(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
shl    $0x2,%eax
add    $0x18,%eax
mov    %al,%cl
movslq -0x88(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
movslq -0x88(%rbp),%rax
movzbl -0x40(%rbp,%rax,1),%eax
movslq -0x88(%rbp),%rcx
movzbl -0x80(%rbp,%rcx,1),%ecx
imul   %ecx,%eax
cwtl
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    115d <main+0x2d>
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    $0x12345,%edi
mov    $0x0,%al
call   1050 <f@plt>
cmp    -0x84(%rbp),%eax
je     11fb <main+0xcb>
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <check_vect@plt>
mov    $0x4,%al
mov    $0x18,%cl
cs nopw 0x0(%rax,%rax,1)
nop
mov    %al,0x40(%rsp,%rbx,1)
mov    %cl,(%rsp,%rbx,1)
add    $0x1,%rbx
add    $0x5,%al
add    $0x4,%cl
cmp    $0x32,%rbx
jne    1150 <main+0x20>
lea    0x40(%rsp),%rsi
mov    %rsp,%rdx
mov    $0x12345,%edi
xor    %eax,%eax
call   1050 <f@plt>
cmp    $0x41701,%eax
jne    118c <main+0x5c>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @check_vect()
store i32 74565, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %40, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 50
br i1 %9, label %10, label %43
10: ; preds = %7
%11 = load i32, i32* %5
%12 = mul nsw i32 %11, 5
%13 = add nsw i32 4, %12
%14 = trunc i32 %13 to i8
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %16
store i8 %14, i8* %17
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 4
%20 = add nsw i32 24, %19
%21 = trunc i32 %20 to i8
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %23
store i8 %21, i8* %24
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = mul nsw i32 %29, %34
%36 = trunc i32 %35 to i16
%37 = sext i16 %36 to i32
%38 = load i32, i32* %4
%39 = add nsw i32 %38, %37
store i32 %39, i32* %4
br label %40
40: ; preds = %10
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %7
43: ; preds = %7
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%45 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%46 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @f to i32 (i32, i8*, i8*, ...)*)(i32 74565, i8* %44, i8* %45)
%47 = load i32, i32* %4
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %43
unreachable
50: ; preds = %43
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = tail call i32 (...) @check_vect()
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
br label %9
6: ; preds = %9
%7 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @f to i32 (i32, i8*, i8*, ...)*)(i32 74565, i8* %4, i8* %5)
%8 = icmp eq i32 %7, 268033
br i1 %8, label %21, label %20
9: ; preds = %0, %9
%10 = phi i64 [ 0, %0 ], [ %18, %9 ]
%11 = trunc i64 %10 to i8
%12 = mul nuw i8 %11, 5
%13 = add nuw i8 %12, 4
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %10
store i8 %13, i8* %14
%15 = shl nuw i8 %11, 2
%16 = add nuw i8 %15, 24
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %10
store i8 %16, i8* %17
tail call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
%18 = add nuw nsw i64 %10, 1
%19 = icmp eq i64 %18, 50
br i1 %19, label %6, label %9
20: ; preds = %6
unreachable
21: ; preds = %6
ret i32 0
}