#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 float_to_Q16_16(double);
char *test_float_to_Q() {
  do {
    if (!(float_to_Q16_16(1) == 0x00010000))
      return "error in float_to_Q16_16(1) != 0x00010000";
  } while (0);
  do {
    if (!(float_to_Q16_16(1.5) == 0x00018000))
      return "error in float_to_Q16_16(1.5) != 0x00018000";
  } while (0);
  do {
    if (!(float_to_Q16_16(-1) == 0xFFFF0000))
      return "error in float_to_Q16_16(-1) == 0xFFFF0000";
  } while (0);
  do {
    if (!(float_to_Q16_16(-1.5) == 0xFFFE8000))
      return "error in float_to_Q16_16(-1.5) == 0xFFFF8000";
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<test_float_to_Q>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  0xee0(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0x10000,%eax
je     1140 <test_float_to_Q+0x30>
lea    0xee9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <test_float_to_Q+0xd3>
jmp    1145 <test_float_to_Q+0x35>
jmp    114a <test_float_to_Q+0x3a>
movsd  0xeb6(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0x18000,%eax
je     1172 <test_float_to_Q+0x62>
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <test_float_to_Q+0xd3>
jmp    1177 <test_float_to_Q+0x67>
jmp    117c <test_float_to_Q+0x6c>
movsd  0xe8c(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0xffff0000,%eax
je     11a4 <test_float_to_Q+0x94>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <test_float_to_Q+0xd3>
jmp    11a9 <test_float_to_Q+0x99>
jmp    11ae <test_float_to_Q+0x9e>
movsd  0xe62(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0xfffe8000,%eax
je     11d6 <test_float_to_Q+0xc6>
lea    0xed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <test_float_to_Q+0xd3>
jmp    11db <test_float_to_Q+0xcb>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_float_to_Q>:
push   %rax
movsd  0xee7(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0x10000,%eax
jne    1171 <test_float_to_Q+0x61>
movsd  0xedb(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0x18000,%eax
jne    117a <test_float_to_Q+0x6a>
movsd  0xecf(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
cmp    $0xffff0000,%eax
jne    1183 <test_float_to_Q+0x73>
movsd  0xec3(%rip),%xmm0
call   1030 <float_to_Q16_16@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xfffe8000,%ecx
lea    0xf36(%rip),%rcx
cmovne %rcx,%rax
pop    %rcx
ret
lea    0xea8(%rip),%rax
pop    %rcx
ret
lea    0xec9(%rip),%rax
pop    %rcx
ret
lea    0xeec(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"error in float_to_Q16_16(1) != 0x00010000\00"
@.str.1 = [44 x i8] c"error in float_to_Q16_16(1.5) != 0x00018000\00"
@.str.2 = [43 x i8] c"error in float_to_Q16_16(-1) == 0xFFFF0000\00"
@.str.3 = [45 x i8] c"error in float_to_Q16_16(-1.5) == 0xFFFF8000\00"
define i8* @test_float_to_Q() {
%1 = alloca i8*
br label %2
2: ; preds = %0
%3 = call i32 @float_to_Q16_16(double 1.000000e+00)
%4 = icmp eq i32 %3, 65536
br i1 %4, label %6, label %5
5: ; preds = %2
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8** %1
br label %26
6: ; preds = %2
br label %7
7: ; preds = %6
br label %8
8: ; preds = %7
%9 = call i32 @float_to_Q16_16(double 1.500000e+00)
%10 = icmp eq i32 %9, 98304
br i1 %10, label %12, label %11
11: ; preds = %8
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %26
12: ; preds = %8
br label %13
13: ; preds = %12
br label %14
14: ; preds = %13
%15 = call i32 @float_to_Q16_16(double -1.000000e+00)
%16 = icmp eq i32 %15, -65536
br i1 %16, label %18, label %17
17: ; preds = %14
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %26
18: ; preds = %14
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = call i32 @float_to_Q16_16(double -1.500000e+00)
%22 = icmp eq i32 %21, -98304
br i1 %22, label %24, label %23
23: ; preds = %20
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %26
24: ; preds = %20
br label %25
25: ; preds = %24
store i8* null, i8** %1
br label %26
26: ; preds = %25, %23, %17, %11, %5
%27 = load i8*, i8** %1
ret i8* %27
}

LLVM IR (-O2):
@.str = [42 x i8] c"error in float_to_Q16_16(1) != 0x00010000\00"
@.str.1 = [44 x i8] c"error in float_to_Q16_16(1.5) != 0x00018000\00"
@.str.2 = [43 x i8] c"error in float_to_Q16_16(-1) == 0xFFFF0000\00"
@.str.3 = [45 x i8] c"error in float_to_Q16_16(-1.5) == 0xFFFF8000\00"
define i8* @test_float_to_Q() {
%1 = tail call i32 @float_to_Q16_16(double 1.000000e+00)
%2 = icmp eq i32 %1, 65536
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = tail call i32 @float_to_Q16_16(double 1.500000e+00)
%5 = icmp eq i32 %4, 98304
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = tail call i32 @float_to_Q16_16(double -1.000000e+00)
%8 = icmp eq i32 %7, -65536
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i32 @float_to_Q16_16(double -1.500000e+00)
%11 = icmp eq i32 %10, -98304
%12 = select i1 %11, i8* null, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0)
br label %13
13: ; preds = %9, %6, %3, %0
%14 = phi i8* [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), %6 ], [ %12, %9 ]
ret i8* %14
}