#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, ...);
int main(int argc, char *argv[]) {
  int i;
  char c;
  char *ptr;
  char s;
  c = 'w';
  i = (int)c;
  printf("i = %d, %c\n", i, i);
  s = 'x';
  ptr = &s;
  i = (int)ptr;
  printf("i = %x\n", i);
  i = 3000;
  c = (char)i;
  printf("c = %d\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x77,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%edx
lea    0xec2(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x78,-0x21(%rbp)
lea    -0x21(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
lea    0xea7(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xbb8,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x15(%rbp)
lea    0xe91(%rip),%rdi
movsbl -0x15(%rbp),%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x77,%esi
mov    $0x77,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0x78,0x7(%rsp)
lea    0x7(%rsp),%rax
movsbl %al,%esi
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0xffffffb8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"i = %d, %c\0A\00"
@.str.1 = [8 x i8] c"i = %x\0A\00"
@.str.2 = [8 x i8] c"c = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext 119, i32 119)
store i8 120, i8* %3
%5 = ptrtoint i8* %3 to i64
%6 = trunc i64 %5 to i8
%7 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8 signext %6)
%8 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8 signext -72)
ret i32 0
}