char t0s(char a, char b) {
  printf("%s: a: %d\n", __func__, a);
  printf("%s: b: %d\n", __func__, b);
  printf("%d\n", a + b);
  int x = (int)a;
  return a + b;
}


x86 assembly (clang, -O0):
<t0s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movsbl -0x1(%rbp),%edx
lea    0xed1(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x2(%rbp),%edx
lea    0xec7(%rip),%rdi
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x1(%rbp),%esi
movsbl -0x2(%rbp),%eax
add    %eax,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
movsbl -0x2(%rbp),%ecx
add    %ecx,%eax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t0s>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xee1(%rip),%rdi
lea    0xee5(%rip),%r14
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    %ebp,%ebx
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s: a: %d\0A\00"
@__func__.t0s = [4 x i8] c"t0s\00"
@.str.1 = [11 x i8] c"%s: b: %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define signext i8 @t0s(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__func__.t0s, i64 0, i64 0), i32 %7)
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__func__.t0s, i64 0, i64 0), i32 %10)
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = add nsw i32 %13, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
store i32 %19, i32* %5
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = add nsw i32 %21, %23
%25 = trunc i32 %24 to i8
ret i8 %25
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s: a: %d\0A\00"
@__func__.t0s = [4 x i8] c"t0s\00"
@.str.1 = [11 x i8] c"%s: b: %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define signext i8 @t0s(i8 signext %0, i8 signext %1) {
%3 = sext i8 %0 to i32
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__func__.t0s, i64 0, i64 0), i32 %3)
%5 = sext i8 %1 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__func__.t0s, i64 0, i64 0), i32 %5)
%7 = add nsw i32 %5, %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = trunc i32 %7 to i8
ret i8 %9
}