#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 Q16_16_to_int32(int);
char *test_Q_to_int32() {
  do {
    if (!(Q16_16_to_int32(0x00010000) == 1))
      return "error in Q16_16_to_int32(0x00010000) == 1";
  } while (0);
  do {
    if (!(Q16_16_to_int32(0x00018000) == 1))
      return "error in Q16_16_to_int32(0x00018000) == 1";
  } while (0);
  do {
    if (!(Q16_16_to_int32(0xFFFF0000) == -1))
      return "error in Q16_16_to_int32(0xFFFF0000) == -1";
  } while (0);
  do {
    if (!(Q16_16_to_int32(0xFFFF8000) == -1))
      return "error in Q16_16_to_int32(0xFFFF8000) == -1";
  } while (0);
  do {
    if (!(Q16_16_to_int32(0xFFFFFFFF) == -1))
      return "error in Q16_16_to_int32(0xFFFFFFFF) == -1";
  } while (0);
  do {
    if (!(Q16_16_to_int32(0xFFFEFFFF) == -2))
      return "error in Q16_16_to_int32(0xFFFEFFFF) == -2";
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<test_Q_to_int32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x10000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0x1,%eax
je     113b <test_Q_to_int32+0x2b>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <test_Q_to_int32+0x119>
jmp    1140 <test_Q_to_int32+0x30>
jmp    1145 <test_Q_to_int32+0x35>
mov    $0x18000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0x1,%eax
je     1168 <test_Q_to_int32+0x58>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <test_Q_to_int32+0x119>
jmp    116d <test_Q_to_int32+0x5d>
jmp    1172 <test_Q_to_int32+0x62>
mov    $0xffff0000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xffffffff,%eax
je     1195 <test_Q_to_int32+0x85>
lea    0xec8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <test_Q_to_int32+0x119>
jmp    119a <test_Q_to_int32+0x8a>
jmp    119f <test_Q_to_int32+0x8f>
mov    $0xffff8000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xffffffff,%eax
je     11c2 <test_Q_to_int32+0xb2>
lea    0xec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <test_Q_to_int32+0x119>
jmp    11c7 <test_Q_to_int32+0xb7>
jmp    11cc <test_Q_to_int32+0xbc>
mov    $0xffffffff,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xffffffff,%eax
je     11ef <test_Q_to_int32+0xdf>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <test_Q_to_int32+0x119>
jmp    11f4 <test_Q_to_int32+0xe4>
jmp    11f9 <test_Q_to_int32+0xe9>
mov    $0xfffeffff,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xfffffffe,%eax
je     121c <test_Q_to_int32+0x10c>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <test_Q_to_int32+0x119>
jmp    1221 <test_Q_to_int32+0x111>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_Q_to_int32>:
push   %rax
mov    $0x10000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0x1,%eax
jne    1147 <test_Q_to_int32+0x37>
mov    $0x18000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0x1,%eax
jne    1150 <test_Q_to_int32+0x40>
mov    $0xffff0000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xffffffff,%eax
je     1159 <test_Q_to_int32+0x49>
lea    0xf0f(%rip),%rax
pop    %rcx
ret
lea    0xeb2(%rip),%rax
pop    %rcx
ret
lea    0xed3(%rip),%rax
pop    %rcx
ret
mov    $0xffff8000,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xffffffff,%eax
je     1171 <test_Q_to_int32+0x61>
lea    0xf10(%rip),%rax
pop    %rcx
ret
mov    $0xffffffff,%edi
call   1030 <Q16_16_to_int32@plt>
cmp    $0xffffffff,%eax
je     1189 <test_Q_to_int32+0x79>
lea    0xf23(%rip),%rax
pop    %rcx
ret
mov    $0xfffeffff,%edi
call   1030 <Q16_16_to_int32@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xfffffffe,%ecx
lea    0xf34(%rip),%rcx
cmovne %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"error in Q16_16_to_int32(0x00010000) == 1\00"
@.str.1 = [42 x i8] c"error in Q16_16_to_int32(0x00018000) == 1\00"
@.str.2 = [43 x i8] c"error in Q16_16_to_int32(0xFFFF0000) == -1\00"
@.str.3 = [43 x i8] c"error in Q16_16_to_int32(0xFFFF8000) == -1\00"
@.str.4 = [43 x i8] c"error in Q16_16_to_int32(0xFFFFFFFF) == -1\00"
@.str.5 = [43 x i8] c"error in Q16_16_to_int32(0xFFFEFFFF) == -2\00"
define i8* @test_Q_to_int32() {
%1 = alloca i8*
br label %2
2: ; preds = %0
%3 = call i32 @Q16_16_to_int32(i32 65536)
%4 = icmp eq i32 %3, 1
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 %38
6: ; preds = %2
br label %7
7: ; preds = %6
br label %8
8: ; preds = %7
%9 = call i32 @Q16_16_to_int32(i32 98304)
%10 = icmp eq i32 %9, 1
br i1 %10, label %12, label %11
11: ; preds = %8
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %38
12: ; preds = %8
br label %13
13: ; preds = %12
br label %14
14: ; preds = %13
%15 = call i32 @Q16_16_to_int32(i32 -65536)
%16 = icmp eq i32 %15, -1
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 %38
18: ; preds = %14
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = call i32 @Q16_16_to_int32(i32 -32768)
%22 = icmp eq i32 %21, -1
br i1 %22, label %24, label %23
23: ; preds = %20
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %38
24: ; preds = %20
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
%27 = call i32 @Q16_16_to_int32(i32 -1)
%28 = icmp eq i32 %27, -1
br i1 %28, label %30, label %29
29: ; preds = %26
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %38
30: ; preds = %26
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = call i32 @Q16_16_to_int32(i32 -65537)
%34 = icmp eq i32 %33, -2
br i1 %34, label %36, label %35
35: ; preds = %32
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %38
36: ; preds = %32
br label %37
37: ; preds = %36
store i8* null, i8** %1
br label %38
38: ; preds = %37, %35, %29, %23, %17, %11, %5
%39 = load i8*, i8** %1
ret i8* %39
}

LLVM IR (-O2):
@.str = [42 x i8] c"error in Q16_16_to_int32(0x00010000) == 1\00"
@.str.1 = [42 x i8] c"error in Q16_16_to_int32(0x00018000) == 1\00"
@.str.2 = [43 x i8] c"error in Q16_16_to_int32(0xFFFF0000) == -1\00"
@.str.3 = [43 x i8] c"error in Q16_16_to_int32(0xFFFF8000) == -1\00"
@.str.4 = [43 x i8] c"error in Q16_16_to_int32(0xFFFFFFFF) == -1\00"
@.str.5 = [43 x i8] c"error in Q16_16_to_int32(0xFFFEFFFF) == -2\00"
define i8* @test_Q_to_int32() {
%1 = tail call i32 @Q16_16_to_int32(i32 65536)
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %19
3: ; preds = %0
%4 = tail call i32 @Q16_16_to_int32(i32 98304)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = tail call i32 @Q16_16_to_int32(i32 -65536)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = tail call i32 @Q16_16_to_int32(i32 -32768)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = tail call i32 @Q16_16_to_int32(i32 -1)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i32 @Q16_16_to_int32(i32 -65537)
%17 = icmp eq i32 %16, -2
%18 = select i1 %17, i8* null, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0)
br label %19
19: ; preds = %15, %12, %9, %6, %3, %0
%20 = phi i8* [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), %12 ], [ %18, %15 ]
ret i8* %20
}