#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 */
typedef scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ assertTrue(char *, int);
int downcast_u8(int);
void testu_8() {
  uint8_t b1 = downcast_u8(0xFF);
  uint8_t b2 = 0xFF;
  assertTrue("b1 == b2", b1 == b2);
  ;
  assertTrue("downcast_u8(0) == 0", downcast_u8(0) == 0);
  ;
  assertTrue("downcast_u8(12) == 12", downcast_u8(12) == 12);
  ;
  assertTrue("downcast_u8(0xFF) == 0xFF", downcast_u8(0xFF) == 0xFF);
  ;
  assertTrue("downcast_u8(0xFFF) == 0xFF", downcast_u8(0xFFF) == 0xFF);
  ;
  assertTrue("downcast_u8(0xffffffffffffffff) == 0xFF",
             downcast_u8(0xffffffffffffffff) == 0xFF);
  ;
}


x86 assembly (clang, -O0):
<testu_8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xff,%edi
call   1030 <downcast_u8@plt>
cltq
mov    %rax,-0x8(%rbp)
movq   $0xff,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xea9(%rip),%rdi
call   1040 <assertTrue@plt>
xor    %edi,%edi
call   1030 <downcast_u8@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe94(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xc,%edi
call   1030 <downcast_u8@plt>
cmp    $0xc,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe87(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xff,%edi
call   1030 <downcast_u8@plt>
cmp    $0xff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe7a(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xfff,%edi
call   1030 <downcast_u8@plt>
cmp    $0xff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe71(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xffffffff,%edi
call   1030 <downcast_u8@plt>
cmp    $0xff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe69(%rip),%rdi
call   1040 <assertTrue@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testu_8>:
push   %rax
mov    $0xff,%edi
call   1030 <downcast_u8@plt>
xor    %esi,%esi
cmp    $0xff,%eax
sete   %sil
lea    0xec3(%rip),%rdi
call   1040 <assertTrue@plt>
xor    %edi,%edi
call   1030 <downcast_u8@plt>
xor    %esi,%esi
test   %eax,%eax
sete   %sil
lea    0xeb1(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xc,%edi
call   1030 <downcast_u8@plt>
xor    %esi,%esi
cmp    $0xc,%eax
sete   %sil
lea    0xea6(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xff,%edi
call   1030 <downcast_u8@plt>
xor    %esi,%esi
cmp    $0xff,%eax
sete   %sil
lea    0xe9b(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xfff,%edi
call   1030 <downcast_u8@plt>
xor    %esi,%esi
cmp    $0xff,%eax
sete   %sil
lea    0xe94(%rip),%rdi
call   1040 <assertTrue@plt>
mov    $0xffffffff,%edi
call   1030 <downcast_u8@plt>
xor    %esi,%esi
cmp    $0xff,%eax
sete   %sil
lea    0xe8e(%rip),%rdi
pop    %rax
jmp    1040 <assertTrue@plt>

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

LLVM IR (-O2):
@.str = [9 x i8] c"b1 == b2\00"
@.str.1 = [20 x i8] c"downcast_u8(0) == 0\00"
@.str.2 = [22 x i8] c"downcast_u8(12) == 12\00"
@.str.3 = [26 x i8] c"downcast_u8(0xFF) == 0xFF\00"
@.str.4 = [27 x i8] c"downcast_u8(0xFFF) == 0xFF\00"
@.str.5 = [40 x i8] c"downcast_u8(0xffffffffffffffff) == 0xFF\00"
define void @testu_8() {
%1 = tail call i32 @downcast_u8(i32 255)
%2 = icmp eq i32 %1, 255
%3 = zext i1 %2 to i32
%4 = tail call i32 @assertTrue(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @downcast_u8(i32 0)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assertTrue(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @downcast_u8(i32 12)
%10 = icmp eq i32 %9, 12
%11 = zext i1 %10 to i32
%12 = tail call i32 @assertTrue(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 @downcast_u8(i32 255)
%14 = icmp eq i32 %13, 255
%15 = zext i1 %14 to i32
%16 = tail call i32 @assertTrue(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = tail call i32 @downcast_u8(i32 4095)
%18 = icmp eq i32 %17, 255
%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_u8(i32 -1)
%22 = icmp eq i32 %21, 255
%23 = zext i1 %22 to i32
%24 = tail call i32 @assertTrue(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %23)
ret void
}