void fn5(void) {
  unsigned short a[23940];
  unsigned int b[1140];
  int j;
  bar(b);
  for (j = 0; j < 1140; j++)
    a[23940 + j - 950] = b[j];
  bar(a);
}


x86 assembly (clang, -O0):
<fn5>:
push   %rbp
mov    %rsp,%rbp
sub    $0xccf0,%rsp
lea    -0xcce0(%rbp),%rdi
mov    $0x0,%al
call   1030 <bar@plt>
movl   $0x0,-0xcce4(%rbp)
cmpl   $0x474,-0xcce4(%rbp)
jge    1182 <fn5+0x72>
movslq -0xcce4(%rbp),%rax
mov    -0xcce0(%rbp,%rax,4),%eax
mov    %ax,%cx
mov    -0xcce4(%rbp),%eax
add    $0x5d84,%eax
sub    $0x3b6,%eax
cltq
mov    %cx,-0xbb10(%rbp,%rax,2)
ff
mov    -0xcce4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcce4(%rbp)
jmp    1133 <fn5+0x23>
lea    -0xbb10(%rbp),%rdi
mov    $0x0,%al
call   1030 <bar@plt>
add    $0xccf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn5>:
push   %rbx
sub    $0xcce0,%rsp
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %eax,%eax
call   1030 <bar@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
pshuflw $0xe8,(%rsp,%rbx,4),%xmm0
pshufhw $0xe8,%xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshuflw $0xe8,0x10(%rsp,%rbx,4),%xmm1
pshufhw $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpcklqdq %xmm1,%xmm0
movdqu %xmm0,0xc56c(%rsp,%rbx,2)
pshuflw $0xe8,0x20(%rsp,%rbx,4),%xmm0
pshufhw $0xe8,%xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshuflw $0xe8,0x30(%rsp,%rbx,4),%xmm1
pshufhw $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpcklqdq %xmm1,%xmm0
movdqu %xmm0,0xc57c(%rsp,%rbx,2)
add    $0x10,%rbx
cmp    $0x470,%rbx
jne    1130 <fn5+0x20>
movzwl 0x11c0(%rsp),%eax
movzwl 0x11c4(%rsp),%ecx
mov    %ax,0xce4c(%rsp)
mov    %cx,0xce4e(%rsp)
movzwl 0x11c8(%rsp),%eax
mov    %ax,0xce50(%rsp)
movzwl 0x11cc(%rsp),%eax
mov    %ax,0xce52(%rsp)
lea    0x11d0(%rsp),%rdi
xor    %eax,%eax
call   1030 <bar@plt>
add    $0xcce0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @fn5() {
%1 = alloca [23940 x i16]
%2 = alloca [1140 x i32]
%3 = alloca i32
%4 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 0
%5 = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* %4)
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 1140
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = trunc i32 %13 to i16
%15 = load i32, i32* %3
%16 = add nsw i32 23940, %15
%17 = sub nsw i32 %16, 950
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 %18
store i16 %14, i16* %19
br label %20
20: ; preds = %9
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %6
23: ; preds = %6
%24 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 0
%25 = call i32 (i16*, ...) bitcast (i32 (...)* @bar to i32 (i16*, ...)*)(i16* %24)
ret void
}

LLVM IR (-O2):
define void @fn5() {
%1 = alloca [23940 x i16]
%2 = alloca [1140 x i32]
%3 = bitcast [23940 x i16]* %1 to i8*
%4 = bitcast [1140 x i32]* %2 to i8*
%5 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 0
%6 = call i32 (i32*, ...) bitcast (i32 (...)* @bar to i32 (i32*, ...)*)(i32* %5)
br label %7
7: ; preds = %7, %0
%8 = phi i64 [ 0, %0 ], [ %36, %7 ]
%9 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 %8
%10 = bitcast i32* %9 to <4 x i32>*
%11 = load <4 x i32>, <4 x i32>* %10
%12 = getelementptr inbounds i32, i32* %9, i64 4
%13 = bitcast i32* %12 to <4 x i32>*
%14 = load <4 x i32>, <4 x i32>* %13
%15 = trunc <4 x i32> %11 to <4 x i16>
%16 = trunc <4 x i32> %14 to <4 x i16>
%17 = add nuw nsw i64 %8, 22990
%18 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 %17
%19 = bitcast i16* %18 to <4 x i16>*
store <4 x i16> %15, <4 x i16>* %19
%20 = getelementptr inbounds i16, i16* %18, i64 4
%21 = bitcast i16* %20 to <4 x i16>*
store <4 x i16> %16, <4 x i16>* %21
%22 = or i64 %8, 8
%23 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 %22
%24 = bitcast i32* %23 to <4 x i32>*
%25 = load <4 x i32>, <4 x i32>* %24
%26 = getelementptr inbounds i32, i32* %23, i64 4
%27 = bitcast i32* %26 to <4 x i32>*
%28 = load <4 x i32>, <4 x i32>* %27
%29 = trunc <4 x i32> %25 to <4 x i16>
%30 = trunc <4 x i32> %28 to <4 x i16>
%31 = add nuw nsw i64 %8, 22998
%32 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 %31
%33 = bitcast i16* %32 to <4 x i16>*
store <4 x i16> %29, <4 x i16>* %33
%34 = getelementptr inbounds i16, i16* %32, i64 4
%35 = bitcast i16* %34 to <4 x i16>*
store <4 x i16> %30, <4 x i16>* %35
%36 = add nuw nsw i64 %8, 16
%37 = icmp eq i64 %36, 1136
br i1 %37, label %38, label %7
38: ; preds = %7
%39 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 1136
%40 = load i32, i32* %39
%41 = trunc i32 %40 to i16
%42 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 24126
store i16 %41, i16* %42
%43 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 1137
%44 = load i32, i32* %43
%45 = trunc i32 %44 to i16
%46 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 24127
store i16 %45, i16* %46
%47 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 1138
%48 = load i32, i32* %47
%49 = trunc i32 %48 to i16
%50 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 24128
store i16 %49, i16* %50
%51 = getelementptr inbounds [1140 x i32], [1140 x i32]* %2, i64 0, i64 1139
%52 = load i32, i32* %51
%53 = trunc i32 %52 to i16
%54 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 24129
store i16 %53, i16* %54
%55 = getelementptr inbounds [23940 x i16], [23940 x i16]* %1, i64 0, i64 0
%56 = call i32 (i16*, ...) bitcast (i32 (...)* @bar to i32 (i16*, ...)*)(i16* %55)
ret void
}