#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 */
char getSC();
unsigned char getUC();
int /*<<< orphan*/ printf(char *, char, unsigned char, char, char);
int main() {
  signed char SC80 = getSC();
  unsigned char UC80 = getUC();
  unsigned short us = (unsigned short)SC80;
  unsigned short us2 = (unsigned short)UC80;
  short s = (short)SC80;
  short s2 = (short)UC80;
  printf("%d %d --> unsigned: us = %d, us2 = %d\n", SC80, UC80, us, us2);
  printf("%d %d -->   signed:  s = %d,  s2 = %d\n", SC80, UC80, s, s2);
  unsigned char uc = (unsigned char)SC80;
  unsigned char uc2 = (unsigned char)UC80;
  signed char sc = (signed char)SC80;
  signed char sc2 = (signed char)UC80;
  printf("%d %d --> unsigned: uc = %d, uc2 = %d\n", SC80, UC80, uc, uc2);
  printf("%d %d -->   signed: sc = %d, sc2 = %d\n", SC80, UC80, sc, sc2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getSC@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1050 <getUC@plt>
mov    %al,-0x6(%rbp)
movsbl -0x5(%rbp),%eax
mov    %ax,-0x8(%rbp)
movzbl -0x6(%rbp),%eax
mov    %ax,-0xa(%rbp)
movsbl -0x5(%rbp),%eax
mov    %ax,-0xc(%rbp)
movzbl -0x6(%rbp),%eax
mov    %ax,-0xe(%rbp)
mov    -0x5(%rbp),%sil
mov    -0x6(%rbp),%dl
mov    -0x8(%rbp),%ax
mov    %al,%cl
mov    -0xa(%rbp),%ax
lea    0xe75(%rip),%rdi
movsbl %sil,%esi
movzbl %dl,%edx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1040 <printf@plt>
mov    -0x5(%rbp),%sil
mov    -0x6(%rbp),%dl
mov    -0xc(%rbp),%ax
mov    %al,%cl
mov    -0xe(%rbp),%ax
lea    0xe71(%rip),%rdi
movsbl %sil,%esi
movzbl %dl,%edx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1040 <printf@plt>
mov    -0x5(%rbp),%al
mov    %al,-0xf(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0x10(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x5(%rbp),%dl
mov    -0x6(%rbp),%cl
mov    -0xf(%rbp),%al
lea    0xe5d(%rip),%rdi
movsbl %dl,%esi
movzbl %cl,%edx
movsbl %al,%ecx
movsbl -0x10(%rbp),%r8d
call   1040 <printf@plt>
mov    -0x5(%rbp),%dl
mov    -0x6(%rbp),%cl
mov    -0x11(%rbp),%al
lea    0xe61(%rip),%rdi
movsbl %dl,%esi
movzbl %cl,%edx
movsbl %al,%ecx
movsbl -0x12(%rbp),%r8d
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <getSC@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getUC@plt>
movsbl %bl,%ebx
movzbl %al,%ebp
movsbl %bpl,%r14d
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"%d %d --> unsigned: us = %d, us2 = %d\0A\00"
@.str.1 = [39 x i8] c"%d %d --> signed: s = %d, s2 = %d\0A\00"
@.str.2 = [39 x i8] c"%d %d --> unsigned: uc = %d, uc2 = %d\0A\00"
@.str.3 = [39 x i8] c"%d %d --> signed: sc = %d, sc2 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
store i32 0, i32* %1
%12 = call signext i8 (...) @getSC()
store i8 %12, i8* %2
%13 = call zeroext i8 (...) @getUC()
store i8 %13, i8* %3
%14 = load i8, i8* %2
%15 = sext i8 %14 to i16
store i16 %15, i16* %4
%16 = load i8, i8* %3
%17 = zext i8 %16 to i16
store i16 %17, i16* %5
%18 = load i8, i8* %2
%19 = sext i8 %18 to i16
store i16 %19, i16* %6
%20 = load i8, i8* %3
%21 = zext i8 %20 to i16
store i16 %21, i16* %7
%22 = load i8, i8* %2
%23 = load i8, i8* %3
%24 = load i16, i16* %4
%25 = trunc i16 %24 to i8
%26 = load i16, i16* %5
%27 = trunc i16 %26 to i8
%28 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8 signext %22, i8 zeroext %23, i8 signext %25, i8 signext %27)
%29 = load i8, i8* %2
%30 = load i8, i8* %3
%31 = load i16, i16* %6
%32 = trunc i16 %31 to i8
%33 = load i16, i16* %7
%34 = trunc i16 %33 to i8
%35 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8 signext %29, i8 zeroext %30, i8 signext %32, i8 signext %34)
%36 = load i8, i8* %2
store i8 %36, i8* %8
%37 = load i8, i8* %3
store i8 %37, i8* %9
%38 = load i8, i8* %2
store i8 %38, i8* %10
%39 = load i8, i8* %3
store i8 %39, i8* %11
%40 = load i8, i8* %2
%41 = load i8, i8* %3
%42 = load i8, i8* %8
%43 = load i8, i8* %9
%44 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8 signext %40, i8 zeroext %41, i8 signext %42, i8 signext %43)
%45 = load i8, i8* %2
%46 = load i8, i8* %3
%47 = load i8, i8* %10
%48 = load i8, i8* %11
%49 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8 signext %45, i8 zeroext %46, i8 signext %47, i8 signext %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"%d %d --> unsigned: us = %d, us2 = %d\0A\00"
@.str.1 = [39 x i8] c"%d %d --> signed: s = %d, s2 = %d\0A\00"
@.str.2 = [39 x i8] c"%d %d --> unsigned: uc = %d, uc2 = %d\0A\00"
@.str.3 = [39 x i8] c"%d %d --> signed: sc = %d, sc2 = %d\0A\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getSC()
%2 = tail call zeroext i8 (...) @getUC()
%3 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8 signext %1, i8 zeroext %2, i8 signext %1, i8 signext %2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8 signext %1, i8 zeroext %2, i8 signext %1, i8 signext %2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8 signext %1, i8 zeroext %2, i8 signext %1, i8 signext %2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8 signext %1, i8 zeroext %2, i8 signext %1, i8 signext %2)
ret i32 0
}