void init_ramp(signed short buf[], int n) {
  int k;
  for (k = 0; k < 200; k++)
    buf[k] = 4096 * (k % 200) / 200 - 2047;
  buf[200 - 1] = 0;
}


x86 assembly (clang, -O0):
<init_ramp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xc8,-0x10(%rbp)
jge    1159 <init_ramp+0x59>
mov    -0x10(%rbp),%eax
mov    $0xc8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
shl    $0xc,%eax
mov    $0xc8,%ecx
cltd
idiv   %ecx
sub    $0x7ff,%eax
mov    %ax,%dx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <init_ramp+0x12>
mov    -0x8(%rbp),%rax
movw   $0x0,0x18e(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_ramp>:
movdqa 0xef8(%rip),%xmm0
movdqa 0xf00(%rip),%xmm5
mov    $0x8,%eax
movdqa 0xf02(%rip),%xmm11
movdqa 0xf0a(%rip),%xmm3
movdqa 0xf11(%rip),%xmm9
movdqa 0xf18(%rip),%xmm8
movdqa 0xf1f(%rip),%xmm10
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqa %xmm5,%xmm1
pslld  $0xc,%xmm1
movdqa %xmm0,%xmm7
pslld  $0xc,%xmm7
movdqa %xmm7,%xmm4
pand   %xmm11,%xmm4
movdqa %xmm1,%xmm6
pand   %xmm11,%xmm6
pshufd $0xf5,%xmm6,%xmm2
pmuludq %xmm3,%xmm6
pshufd $0xed,%xmm6,%xmm6
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm6
psrld  $0x6,%xmm6
pshufd $0xf5,%xmm4,%xmm2
pmuludq %xmm3,%xmm4
pshufd $0xed,%xmm4,%xmm4
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm4
psrld  $0x6,%xmm4
packssdw %xmm4,%xmm6
paddw  %xmm9,%xmm6
movdqu %xmm6,-0x10(%rdi,%rax,2)
cmp    $0xc8,%rax
je     1240 <init_ramp+0x140>
paddd  %xmm8,%xmm1
paddd  %xmm8,%xmm7
pand   %xmm11,%xmm7
pand   %xmm11,%xmm1
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm3,%xmm1
pshufd $0xed,%xmm1,%xmm1
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
psrld  $0x6,%xmm1
pshufd $0xf5,%xmm7,%xmm2
pmuludq %xmm3,%xmm7
pshufd $0xed,%xmm7,%xmm4
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm4
psrld  $0x6,%xmm4
packssdw %xmm4,%xmm1
paddw  %xmm9,%xmm1
movdqu %xmm1,(%rdi,%rax,2)
paddd  %xmm10,%xmm5
paddd  %xmm10,%xmm0
add    $0x10,%rax
jmp    1150 <init_ramp+0x50>
movw   $0x0,0x18e(%rdi)
ret

LLVM IR (-O0):
define void @init_ramp(i16* %0, i32 %1) {
%3 = alloca i16*
%4 = alloca i32
%5 = alloca i32
store i16* %0, i16** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 200
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %5
%11 = srem i32 %10, 200
%12 = mul nsw i32 4096, %11
%13 = sdiv i32 %12, 200
%14 = sub nsw i32 %13, 2047
%15 = trunc i32 %14 to i16
%16 = load i16*, i16** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i16, i16* %16, i64 %18
store i16 %15, i16* %19
br label %20
20: ; preds = %9
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
%24 = load i16*, i16** %3
%25 = getelementptr inbounds i16, i16* %24, i64 199
store i16 0, i16* %25
ret void
}

LLVM IR (-O2):
define void @init_ramp(i16* nocapture writeonly %0, i32 %1) {
br label %3
3: ; preds = %15, %2
%4 = phi i64 [ 0, %2 ], [ %24, %15 ]
%5 = phi <8 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>, %2 ], [ %25, %15 ]
%6 = shl <8 x i32> %5, <i32 12, i32 12, i32 12, i32 12, i32 12, i32 12, i32 12, i32 12>
%7 = and <8 x i32> %6, <i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480>
%8 = udiv <8 x i32> %7, <i32 200, i32 200, i32 200, i32 200, i32 200, i32 200, i32 200, i32 200>
%9 = trunc <8 x i32> %8 to <8 x i16>
%10 = add nsw <8 x i16> %9, <i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047>
%11 = getelementptr inbounds i16, i16* %0, i64 %4
%12 = bitcast i16* %11 to <8 x i16>*
store <8 x i16> %10, <8 x i16>* %12
%13 = or i64 %4, 8
%14 = icmp eq i64 %13, 200
br i1 %14, label %26, label %15
15: ; preds = %3
%16 = shl <8 x i32> %5, <i32 12, i32 12, i32 12, i32 12, i32 12, i32 12, i32 12, i32 12>
%17 = add <8 x i32> %16, <i32 32768, i32 32768, i32 32768, i32 32768, i32 32768, i32 32768, i32 32768, i32 32768>
%18 = and <8 x i32> %17, <i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480, i32 1044480>
%19 = udiv <8 x i32> %18, <i32 200, i32 200, i32 200, i32 200, i32 200, i32 200, i32 200, i32 200>
%20 = trunc <8 x i32> %19 to <8 x i16>
%21 = add nsw <8 x i16> %20, <i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047, i16 -2047>
%22 = getelementptr inbounds i16, i16* %0, i64 %13
%23 = bitcast i16* %22 to <8 x i16>*
store <8 x i16> %21, <8 x i16>* %23
%24 = add nuw nsw i64 %4, 16
%25 = add <8 x i32> %5, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
br label %3
26: ; preds = %3
%27 = getelementptr inbounds i16, i16* %0, i64 199
store i16 0, i16* %27
ret void
}