#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 *, char);
main() {
  int i;
  char c;
  i = 'd';
  c = 2;
  printf("Before implicit type cast - Value of i is %d\n", i);
  printf("Before implicit type cast - Value of c is %d\n", c);
  i = c;
  c = i;
  printf("After implicit type cast  - Value of i is %d\n", i);
  printf("After implicit type cast  - Value of c is %d - Unchanged\n", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x64,-0x4(%rbp)
movb   $0x2,-0x5(%rbp)
mov    -0x4(%rbp),%eax
lea    0xed3(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
lea    0xf00(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x64,%esi
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0xf3f(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Before implicit type cast - Value of i is %d\0A\00"
@.str.1 = [46 x i8] c"Before implicit type cast - Value of c is %d\0A\00"
@.str.2 = [46 x i8] c"After implicit type cast - Value of i is %d\0A\00"
@.str.3 = [58 x i8] c"After implicit type cast - Value of c is %d - Unchanged\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 100, i32* %1
store i8 2, i8* %2
%3 = load i32, i32* %1
%4 = trunc i32 %3 to i8
%5 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8 signext %4)
%6 = load i8, i8* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8 signext %6)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = trunc i32 %10 to i8
store i8 %11, i8* %2
%12 = load i32, i32* %1
%13 = trunc i32 %12 to i8
%14 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8 signext %13)
%15 = load i8, i8* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8 signext %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Before implicit type cast - Value of i is %d\0A\00"
@.str.1 = [46 x i8] c"Before implicit type cast - Value of c is %d\0A\00"
@.str.2 = [46 x i8] c"After implicit type cast - Value of i is %d\0A\00"
@.str.3 = [58 x i8] c"After implicit type cast - Value of c is %d - Unchanged\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8 signext 100)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8 signext 2)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8 signext 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8 signext 2)
ret i32 0
}