#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*/ assertTrue(char *, int);
int downcast_16(int);
void test_16() {
  assertTrue("downcast_16(0) == 0", downcast_16(0) == 0);
  ;
  assertTrue("downcast_16(0xF) == 15", downcast_16(0xF) == 15);
  ;
  assertTrue("downcast_16(0xFE) == 254", downcast_16(0xFE) == 254);
  ;
  assertTrue("downcast_16(0xFF) == 255", downcast_16(0xFF) == 255);
  ;
  assertTrue("downcast_16(0xFFF) == 4095", downcast_16(0xFFF) == 4095);
  ;
  assertTrue("downcast_16(0xFFFF) == -1", downcast_16(0xFFFF) == -1);
  ;
  assertTrue("downcast_16(0xffffffffffffffff) == -1",
             downcast_16(0xffffffffffffffff) == -1);
  ;
}


x86 assembly (clang, -O0):
<test_16>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1040 <downcast_16@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xec3(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xf,%edi
call   1040 <downcast_16@plt>
cmp    $0xf,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xeb6(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xfe,%edi
call   1040 <downcast_16@plt>
cmp    $0xfe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xeaa(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xff,%edi
call   1040 <downcast_16@plt>
cmp    $0xff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xea0(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xfff,%edi
call   1040 <downcast_16@plt>
cmp    $0xfff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe96(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xffff,%edi
call   1040 <downcast_16@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe90(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xffffffff,%edi
call   1040 <downcast_16@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe89(%rip),%rdi
call   1030 <assertTrue@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_16>:
push   %rax
xor    %edi,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
test   %eax,%eax
sete   %sil
lea    0xec9(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xf,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
cmp    $0xf,%eax
sete   %sil
lea    0xebe(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xfe,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
cmp    $0xfe,%eax
sete   %sil
lea    0xeb4(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xff,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
cmp    $0xff,%eax
sete   %sil
lea    0xeac(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xfff,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
cmp    $0xfff,%eax
sete   %sil
lea    0xea4(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xffff,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
cmp    $0xffffffff,%eax
sete   %sil
lea    0xea0(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xffffffff,%edi
call   1040 <downcast_16@plt>
xor    %esi,%esi
cmp    $0xffffffff,%eax
sete   %sil
lea    0xe9b(%rip),%rdi
pop    %rax
jmp    1030 <assertTrue@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"downcast_16(0) == 0\00"
@.str.1 = [23 x i8] c"downcast_16(0xF) == 15\00"
@.str.2 = [25 x i8] c"downcast_16(0xFE) == 254\00"
@.str.3 = [25 x i8] c"downcast_16(0xFF) == 255\00"
@.str.4 = [27 x i8] c"downcast_16(0xFFF) == 4095\00"
@.str.5 = [26 x i8] c"downcast_16(0xFFFF) == -1\00"
@.str.6 = [38 x i8] c"downcast_16(0xffffffffffffffff) == -1\00"
define void @test_16() {
%1 = call i32 @downcast_16(i32 0)
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @assertTrue(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @downcast_16(i32 15)
%6 = icmp eq i32 %5, 15
%7 = zext i1 %6 to i32
%8 = call i32 @assertTrue(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @downcast_16(i32 254)
%10 = icmp eq i32 %9, 254
%11 = zext i1 %10 to i32
%12 = call i32 @assertTrue(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 @downcast_16(i32 255)
%14 = icmp eq i32 %13, 255
%15 = zext i1 %14 to i32
%16 = call i32 @assertTrue(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = call i32 @downcast_16(i32 4095)
%18 = icmp eq i32 %17, 4095
%19 = zext i1 %18 to i32
%20 = call i32 @assertTrue(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = call i32 @downcast_16(i32 65535)
%22 = icmp eq i32 %21, -1
%23 = zext i1 %22 to i32
%24 = call i32 @assertTrue(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = call i32 @downcast_16(i32 -1)
%26 = icmp eq i32 %25, -1
%27 = zext i1 %26 to i32
%28 = call i32 @assertTrue(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"downcast_16(0) == 0\00"
@.str.1 = [23 x i8] c"downcast_16(0xF) == 15\00"
@.str.2 = [25 x i8] c"downcast_16(0xFE) == 254\00"
@.str.3 = [25 x i8] c"downcast_16(0xFF) == 255\00"
@.str.4 = [27 x i8] c"downcast_16(0xFFF) == 4095\00"
@.str.5 = [26 x i8] c"downcast_16(0xFFFF) == -1\00"
@.str.6 = [38 x i8] c"downcast_16(0xffffffffffffffff) == -1\00"
define void @test_16() {
%1 = tail call i32 @downcast_16(i32 0)
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assertTrue(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @downcast_16(i32 15)
%6 = icmp eq i32 %5, 15
%7 = zext i1 %6 to i32
%8 = tail call i32 @assertTrue(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @downcast_16(i32 254)
%10 = icmp eq i32 %9, 254
%11 = zext i1 %10 to i32
%12 = tail call i32 @assertTrue(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 @downcast_16(i32 255)
%14 = icmp eq i32 %13, 255
%15 = zext i1 %14 to i32
%16 = tail call i32 @assertTrue(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = tail call i32 @downcast_16(i32 4095)
%18 = icmp eq i32 %17, 4095
%19 = zext i1 %18 to i32
%20 = tail call i32 @assertTrue(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = tail call i32 @downcast_16(i32 65535)
%22 = icmp eq i32 %21, -1
%23 = zext i1 %22 to i32
%24 = tail call i32 @assertTrue(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = tail call i32 @downcast_16(i32 -1)
%26 = icmp eq i32 %25, -1
%27 = zext i1 %26 to i32
%28 = tail call i32 @assertTrue(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %27)
ret void
}