#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void write_filter(char *name, float *filter, int n) {
  int i;
  printf("s16 %s[%d]=\n{\n", name, n);
  for (i = 0; i < n; i++) {
    printf("%6d, ", (int)(filter[i] * 0x4000));
    if ((i % 8) == 7)
      printf("\n");
  }
  printf("\n};\n");
}


x86 assembly (clang, -O0):
<write_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a7 <write_filter+0x97>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  0xea5(%rip),%xmm0
mulss  (%rax,%rcx,4),%xmm0
cvttss2si %xmm0,%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    1194 <write_filter+0x84>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <write_filter+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <write_filter+0x2f>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_filter>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    1199 <write_filter+0x69>
mov    %ebp,%ebp
lea    0xeb9(%rip),%r14
xor    %ebx,%ebx
jmp    1169 <write_filter+0x39>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1199 <write_filter+0x69>
movss  (%r15,%rbx,4),%xmm0
mulss  0xe89(%rip),%xmm0
cvttss2si %xmm0,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0x7,%al
jne    1160 <write_filter+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1160 <write_filter+0x30>
lea    0xe79(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"s16 %s[%d]=\0A{\0A\00"
@.str.1 = [6 x i8] c"%6d, \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [5 x i8] c"\0A};\0A\00"
define void @write_filter(i8* %0, float* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store float* %1, float** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %30, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = load float*, float** %5
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds float, float* %16, i64 %18
%20 = load float, float* %19
%21 = fmul float %20, 1.638400e+04
%22 = fptosi float %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %7
%25 = srem i32 %24, 8
%26 = icmp eq i32 %25, 7
br i1 %26, label %27, label %29
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %11
33: ; preds = %11
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"s16 %s[%d]=\0A{\0A\00"
@.str.1 = [6 x i8] c"%6d, \00"
@str = [4 x i8] c"\0A};\00"
define void @write_filter(i8* %0, float* nocapture %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %19
%9 = phi i64 [ 0, %6 ], [ %20, %19 ]
%10 = getelementptr inbounds float, float* %1, i64 %9
%11 = load float, float* %10
%12 = fmul float %11, 1.638400e+04
%13 = fptosi float %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = and i64 %9, 7
%16 = icmp eq i64 %15, 7
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 @putchar(i32 10)
br label %19
19: ; preds = %8, %17
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %22, label %8
22: ; preds = %19, %3
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
}