#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_8(int);
void test_8() {
  assertTrue("downcast_8(0) == 0", downcast_8(0) == 0);
  ;
  assertTrue("downcast_8(0xF) == 15", downcast_8(0xF) == 15);
  ;
  assertTrue("downcast_8(0xFE) == -2", downcast_8(0xFE) == -2);
  ;
  assertTrue("downcast_8(0xFF) == -1", downcast_8(0xFF) == -1);
  ;
  assertTrue("downcast_8(0xFFF) == -1", downcast_8(0xFFF) == -1);
  ;
  assertTrue("downcast_8(0xffffffffffffffff) == -1",
             downcast_8(0xffffffffffffffff) == -1);
  ;
}


x86 assembly (clang, -O0):
<test_8>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1040 <downcast_8@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_8@plt>
cmp    $0xf,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xeb5(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xfe,%edi
call   1040 <downcast_8@plt>
cmp    $0xfffffffe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xeaa(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xff,%edi
call   1040 <downcast_8@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xea0(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xfff,%edi
call   1040 <downcast_8@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe96(%rip),%rdi
call   1030 <assertTrue@plt>
mov    $0xffffffff,%edi
call   1040 <downcast_8@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe8d(%rip),%rdi
call   1030 <assertTrue@plt>
pop    %rbp
ret

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

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

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