#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*/ printf(char *, ...);
void test_unsigned_and_signed(void) {
  printf("=======test         -1=======\n");
  signed char c7_1 = 0x00ff;
  unsigned char c7_2 = 0x00ff;
  printf("signed   %08x, %d\n", c7_1, c7_1);
  printf("unsigned %08x, %d\n", c7_2, c7_2);
  printf("\n=======test high bit 1=======\n");
  signed char cc1 = 0x80;
  unsigned char cc2 = 0x80;
  printf("signed   %08x, %d\n", cc1, cc1);
  printf("unsigned %08x, %d\n", cc2, cc2);
  printf("\n=======test high bit 0=======\n");
  signed char cc3 = 0x7f;
  unsigned char cc4 = 0x7f;
  printf("signed   %08x, %d\n", cc3, cc3);
  printf("unsigned %08x, %d\n", cc4, cc4);
}


x86 assembly (clang, -O0):
<test_unsigned_and_signed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0xff,-0x1(%rbp)
movb   $0xff,-0x2(%rbp)
movsbl -0x1(%rbp),%esi
movsbl -0x1(%rbp),%edx
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x2(%rbp),%esi
movzbl -0x2(%rbp),%edx
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x80,-0x3(%rbp)
movb   $0x80,-0x4(%rbp)
movsbl -0x3(%rbp),%esi
movsbl -0x3(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x4(%rbp),%esi
movzbl -0x4(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x7f,-0x5(%rbp)
movb   $0x7f,-0x6(%rbp)
movsbl -0x5(%rbp),%esi
movsbl -0x5(%rbp),%edx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x6(%rbp),%esi
movzbl -0x6(%rbp),%edx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_unsigned_and_signed>:
push   %r14
push   %rbx
push   %rax
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%r14
mov    %r14,%rdi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0xff,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0xffffff80,%esi
mov    $0xffffff80,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x80,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x7f,%esi
mov    $0x7f,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7f,%esi
mov    $0x7f,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"=======test -1=======\0A\00"
@.str.1 = [19 x i8] c"signed %08x, %d\0A\00"
@.str.2 = [19 x i8] c"unsigned %08x, %d\0A\00"
@.str.3 = [32 x i8] c"\0A=======test high bit 1=======\0A\00"
@.str.4 = [32 x i8] c"\0A=======test high bit 0=======\0A\00"
define void @test_unsigned_and_signed() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i8 -1, i8* %1
store i8 -1, i8* %2
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11)
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = load i8, i8* %2
%16 = zext i8 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i8 -128, i8* %3
store i8 -128, i8* %4
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22)
%24 = load i8, i8* %4
%25 = zext i8 %24 to i32
%26 = load i8, i8* %4
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
store i8 127, i8* %5
store i8 127, i8* %6
%30 = load i8, i8* %5
%31 = sext i8 %30 to i32
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %33)
%35 = load i8, i8* %6
%36 = zext i8 %35 to i32
%37 = load i8, i8* %6
%38 = zext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %38)
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"signed %08x, %d\0A\00"
@.str.2 = [19 x i8] c"unsigned %08x, %d\0A\00"
@str = [30 x i8] c"=======test -1=======\00"
@str.5 = [31 x i8] c"\0A=======test high bit 1=======\00"
@str.6 = [31 x i8] c"\0A=======test high bit 0=======\00"
define void @test_unsigned_and_signed() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 -1, i32 -1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 255, i32 255)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 -128, i32 -128)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 128, i32 128)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 127, i32 127)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 127, i32 127)
ret void
}