#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
void fmt_convert_double_to_s20(void *dest_v, void *src_v, int n) {
  int32_t *dest = dest_v;
  double *src = src_v;
  int i;
  for (i = 0; i < n; i++)
    dest[i] = (int32_t)((((((src[i] * 524288))) > ((524287))
                              ? ((524287))
                              : (((src[i] * 524288))))) > ((-524288))
                            ? (((((src[i] * 524288))) > ((524287))
                                    ? ((524287))
                                    : (((src[i] * 524288)))))
                            : ((-524288)));
}


x86 assembly (clang, -O0):
<fmt_convert_double_to_s20>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1234 <fmt_convert_double_to_s20+0x134>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xec6(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xeb1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116b <fmt_convert_double_to_s20+0x6b>
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1185 <fmt_convert_double_to_s20+0x85>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe8d(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11fe <fmt_convert_double_to_s20+0xfe>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe5c(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xe47(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d5 <fmt_convert_double_to_s20+0xd5>
movsd  0xe35(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11ef <fmt_convert_double_to_s20+0xef>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe23(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1210 <fmt_convert_double_to_s20+0x110>
movsd  0xe0a(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1210 <fmt_convert_double_to_s20+0x110>
movsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%rdx
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1126 <fmt_convert_double_to_s20+0x26>
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmt_convert_double_to_s20>:
test   %edx,%edx
jle    1176 <fmt_convert_double_to_s20+0x76>
mov    %edx,%r8d
cmp    $0x1,%edx
jne    1177 <fmt_convert_double_to_s20+0x77>
xor    %eax,%eax
test   $0x1,%r8b
je     1176 <fmt_convert_double_to_s20+0x76>
movsd  (%rsi,%rax,8),%xmm1
mulsd  0xedf(%rip),%xmm1
movsd  0xedf(%rip),%xmm0
movapd %xmm0,%xmm3
minsd  %xmm1,%xmm3
movsd  0xed7(%rip),%xmm4
ucomisd %xmm4,%xmm3
movapd %xmm4,%xmm2
cmpnltsd %xmm3,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm0,%xmm2
orpd   %xmm4,%xmm2
cmpltsd %xmm1,%xmm0
movapd %xmm0,%xmm3
andpd  %xmm2,%xmm3
jbe    1165 <fmt_convert_double_to_s20+0x65>
movapd %xmm1,%xmm2
andnpd %xmm2,%xmm0
orpd   %xmm3,%xmm0
cvttsd2si %xmm0,%rcx
mov    %rcx,(%rdi,%rax,8)
ret
mov    %r8d,%edx
and    $0xfffffffe,%edx
xor    %eax,%eax
movsd  0xe79(%rip),%xmm0
movsd  0xe79(%rip),%xmm1
movsd  0xe79(%rip),%xmm2
jmp    11cc <fmt_convert_double_to_s20+0xcc>
nopl   0x0(%rax)
movapd %xmm1,%xmm6
cmpltsd %xmm3,%xmm6
andpd  %xmm6,%xmm4
andnpd %xmm5,%xmm6
orpd   %xmm4,%xmm6
cvttsd2si %xmm6,%rcx
mov    %rcx,0x8(%rdi,%rax,8)
add    $0x2,%rax
cmp    %rax,%rdx
je     110e <fmt_convert_double_to_s20+0xe>
movsd  (%rsi,%rax,8),%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm1,%xmm5
minsd  %xmm3,%xmm5
ucomisd %xmm2,%xmm5
movapd %xmm2,%xmm4
cmpnltsd %xmm5,%xmm4
movapd %xmm4,%xmm5
andpd  %xmm2,%xmm5
andnpd %xmm1,%xmm4
orpd   %xmm5,%xmm4
movapd %xmm4,%xmm5
jbe    1204 <fmt_convert_double_to_s20+0x104>
movapd %xmm3,%xmm5
movapd %xmm1,%xmm6
cmpltsd %xmm3,%xmm6
andpd  %xmm6,%xmm4
andnpd %xmm5,%xmm6
orpd   %xmm4,%xmm6
cvttsd2si %xmm6,%rcx
mov    %rcx,(%rdi,%rax,8)
movsd  0x8(%rsi,%rax,8),%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm1,%xmm5
minsd  %xmm3,%xmm5
ucomisd %xmm2,%xmm5
movapd %xmm2,%xmm4
cmpnltsd %xmm5,%xmm4
movapd %xmm4,%xmm5
andpd  %xmm2,%xmm5
andnpd %xmm1,%xmm4
orpd   %xmm5,%xmm4
movapd %xmm4,%xmm5
jbe    11a0 <fmt_convert_double_to_s20+0xa0>
movapd %xmm3,%xmm5
jmp    11a0 <fmt_convert_double_to_s20+0xa0>

LLVM IR (-O0):
define void @fmt_convert_double_to_s20(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64*
%8 = alloca double*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to i64*
store i64* %11, i64** %7
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to double*
store double* %13, double** %8
store i32 0, i32* %9
br label %14
14: ; preds = %63, %3
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %66
18: ; preds = %14
%19 = load double*, double** %8
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = fmul double %23, 5.242880e+05
%25 = fcmp ogt double %24, 5.242870e+05
br i1 %25, label %26, label %27
26: ; preds = %18
br label %34
27: ; preds = %18
%28 = load double*, double** %8
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = fmul double %32, 5.242880e+05
br label %34
34: ; preds = %27, %26
%35 = phi double [ 5.242870e+05, %26 ], [ %33, %27 ]
%36 = fcmp ogt double %35, -5.242880e+05
br i1 %36, label %37, label %55
37: ; preds = %34
%38 = load double*, double** %8
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = fmul double %42, 5.242880e+05
%44 = fcmp ogt double %43, 5.242870e+05
br i1 %44, label %45, label %46
45: ; preds = %37
br label %53
46: ; preds = %37
%47 = load double*, double** %8
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = fmul double %51, 5.242880e+05
br label %53
53: ; preds = %46, %45
%54 = phi double [ 5.242870e+05, %45 ], [ %52, %46 ]
br label %56
55: ; preds = %34
br label %56
56: ; preds = %55, %53
%57 = phi double [ %54, %53 ], [ -5.242880e+05, %55 ]
%58 = fptosi double %57 to i64
%59 = load i64*, i64** %7
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i64, i64* %59, i64 %61
store i64 %58, i64* %62
br label %63
63: ; preds = %56
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %14
66: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @fmt_convert_double_to_s20(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = bitcast i8* %0 to i64*
%5 = bitcast i8* %1 to double*
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %57
7: ; preds = %3
%8 = zext i32 %2 to i64
%9 = and i64 %8, 1
%10 = icmp eq i32 %2, 1
br i1 %10, label %42, label %11
11: ; preds = %7
%12 = and i64 %8, 4294967294
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %39, %13 ]
%15 = phi i64 [ 0, %11 ], [ %40, %13 ]
%16 = getelementptr inbounds double, double* %5, i64 %14
%17 = load double, double* %16
%18 = fmul double %17, 5.242880e+05
%19 = fcmp ogt double %18, 5.242870e+05
%20 = select i1 %19, double 5.242870e+05, double %18
%21 = fcmp ule double %20, -5.242880e+05
%22 = or i1 %19, %21
%23 = select i1 %21, double -5.242880e+05, double 5.242870e+05
%24 = select i1 %22, double %23, double %18
%25 = fptosi double %24 to i64
%26 = getelementptr inbounds i64, i64* %4, i64 %14
store i64 %25, i64* %26
%27 = or i64 %14, 1
%28 = getelementptr inbounds double, double* %5, i64 %27
%29 = load double, double* %28
%30 = fmul double %29, 5.242880e+05
%31 = fcmp ogt double %30, 5.242870e+05
%32 = select i1 %31, double 5.242870e+05, double %30
%33 = fcmp ule double %32, -5.242880e+05
%34 = or i1 %31, %33
%35 = select i1 %33, double -5.242880e+05, double 5.242870e+05
%36 = select i1 %34, double %35, double %30
%37 = fptosi double %36 to i64
%38 = getelementptr inbounds i64, i64* %4, i64 %27
store i64 %37, i64* %38
%39 = add nuw nsw i64 %14, 2
%40 = add i64 %15, 2
%41 = icmp eq i64 %40, %12
br i1 %41, label %42, label %13
42: ; preds = %13, %7
%43 = phi i64 [ 0, %7 ], [ %39, %13 ]
%44 = icmp eq i64 %9, 0
br i1 %44, label %57, label %45
45: ; preds = %42
%46 = getelementptr inbounds double, double* %5, i64 %43
%47 = load double, double* %46
%48 = fmul double %47, 5.242880e+05
%49 = fcmp ogt double %48, 5.242870e+05
%50 = select i1 %49, double 5.242870e+05, double %48
%51 = fcmp ule double %50, -5.242880e+05
%52 = or i1 %49, %51
%53 = select i1 %51, double -5.242880e+05, double 5.242870e+05
%54 = select i1 %52, double %53, double %48
%55 = fptosi double %54 to i64
%56 = getelementptr inbounds i64, i64* %4, i64 %43
store i64 %55, i64* %56
br label %57
57: ; preds = %45, %42, %3
ret void
}