#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_u16(int);
int /*<<< orphan*/ printf(char *, int);
void test_u16() {
  assertTrue("downcast_u16(0) == 0", downcast_u16(0) == 0);
  ;
  assertTrue("downcast_u16(0xF) == 15", downcast_u16(0xF) == 15);
  ;
  assertTrue("downcast_u16(0xFE) == 254", downcast_u16(0xFE) == 254);
  ;
  assertTrue("downcast_u16(0xFF) == 0xFF", downcast_u16(0xFF) == 0xFF);
  ;
  assertTrue("downcast_u16(0xFFF) == 0xFFF", downcast_u16(0xFFF) == 0xFFF);
  ;
  printf("0xFFFF -> %d\n", downcast_u16(0xFFFF));
}


x86 assembly (clang, -O0):
<test_u16>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1050 <downcast_u16@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xeb3(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xf,%edi
call   1050 <downcast_u16@plt>
cmp    $0xf,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xea7(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xfe,%edi
call   1050 <downcast_u16@plt>
cmp    $0xfe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe9c(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xff,%edi
call   1050 <downcast_u16@plt>
cmp    $0xff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe93(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xfff,%edi
call   1050 <downcast_u16@plt>
cmp    $0xfff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe8b(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xffff,%edi
call   1050 <downcast_u16@plt>
mov    %eax,%esi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_u16>:
push   %rax
xor    %edi,%edi
call   1050 <downcast_u16@plt>
xor    %esi,%esi
test   %eax,%eax
sete   %sil
lea    0xeb9(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xf,%edi
call   1050 <downcast_u16@plt>
xor    %esi,%esi
cmp    $0xf,%eax
sete   %sil
lea    0xeaf(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xfe,%edi
call   1050 <downcast_u16@plt>
xor    %esi,%esi
cmp    $0xfe,%eax
sete   %sil
lea    0xea6(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xff,%edi
call   1050 <downcast_u16@plt>
xor    %esi,%esi
cmp    $0xff,%eax
sete   %sil
lea    0xe9f(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xfff,%edi
call   1050 <downcast_u16@plt>
xor    %esi,%esi
cmp    $0xfff,%eax
sete   %sil
lea    0xe99(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xffff,%edi
call   1050 <downcast_u16@plt>
lea    0xea0(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1030 <printf@plt>

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

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