#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 INT_MAX;
int /*<<< orphan*/ printf(char *, short, ...);
int main() {
  float a = 1.999;
  double b = a;
  int c = b;
  printf("a: %f, b: %lf, c: %d\n", a, b, c);
  float d = -1.999;
  b = d;
  c = b;
  printf("d: %f, b: %lf, c: %d\n", d, b, c);
  int x = INT_MAX;
  printf("x %d(0x%x)\n", x, x);
  float y = (float)x;
  printf("y %f\n", y);
  x = (int)(float)x;
  printf("x %d(0x%x)\n", x, x);
  char cc = 0x81;
  printf("10000001b = %d\n", cc);
  cc = 0xff;
  printf("0xff= %d\n", cc);
  int xx = -12340;
  printf("%d\n", xx / 16);
  printf("%f\n", (float)xx / 16.0);
  short yy = (short)0xfcfc;
  printf("%d\n", yy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3fffdf3b,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvttss2si -0x8(%rbp),%eax
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edx
movswl %ax,%esi
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
mov    %al,-0x39(%rbp)
call   1030 <printf@plt>
mov    -0x39(%rbp),%al
movl   $0xbfffdf3b,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%ecx
mov    %ecx,-0x14(%rbp)
cvttss2si -0x18(%rbp),%ecx
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edx
movswl %cx,%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
mov    %dx,%ax
movswl %ax,%esi
lea    0xe7f(%rip),%rdi
mov    %rdi,-0x38(%rbp)
xor    %eax,%eax
mov    %al,-0x2b(%rbp)
call   1030 <printf@plt>
mov    -0x2b(%rbp),%al
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
cvttss2si -0x20(%rbp),%ecx
movswl %cx,%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2b(%rbp),%al
cvtsi2ssl -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%ecx
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
mov    %dx,%cx
movswl %cx,%esi
call   1030 <printf@plt>
mov    -0x2b(%rbp),%al
movb   $0x81,-0x21(%rbp)
movsbl -0x21(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2b(%rbp),%al
movb   $0xff,-0x21(%rbp)
movsbl -0x21(%rbp),%esi
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2b(%rbp),%al
movl   $0xffffcfcc,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0xf,%edx
test   %ecx,%ecx
cmovs  %edx,%ecx
shr    $0x4,%ecx
movswl %cx,%esi
lea    0xdc3(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd93(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
lea    0xdc6(%rip),%rdi
movswl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0xfcfc,-0x2a(%rbp)
lea    0xd87(%rip),%rdi
movswl -0x2a(%rbp),%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xef1(%rip),%rdi
movsd  0xed9(%rip),%xmm0
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
movsd  0xec1(%rip),%xmm0
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%ebx
movswl %bx,%ebp
lea    0xed1(%rip),%r14
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xebb(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cvttss2si 0xc(%rsp),%edx
movswl %dx,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0xffffff81,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4c(%rip),%rbx
mov    %rbx,%rdi
mov    $0xfffffcfd,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    $0xfffffcfd,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xfffffcfc,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"a: %f, b: %lf, c: %d\0A\00"
@.str.1 = [22 x i8] c"d: %f, b: %lf, c: %d\0A\00"
@INT_MAX = global i32 0
@.str.2 = [12 x i8] c"x %d(0x%x)\0A\00"
@.str.3 = [6 x i8] c"y %f\0A\00"
@.str.4 = [16 x i8] c"10000001b = %d\0A\00"
@.str.5 = [10 x i8] c"0xff= %d\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca double
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca i8
%9 = alloca i32
%10 = alloca i16
store i32 0, i32* %1
store float 0x3FFFFBE760000000, float* %2
%11 = load float, float* %2
%12 = fpext float %11 to double
store double %12, double* %3
%13 = load double, double* %3
%14 = fptosi double %13 to i32
store i32 %14, i32* %4
%15 = load float, float* %2
%16 = fptosi float %15 to i16
%17 = load double, double* %3
%18 = load i32, i32* %4
%19 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i16 signext %16, double %17, i32 %18)
store float 0xBFFFFBE760000000, float* %5
%20 = load float, float* %5
%21 = fpext float %20 to double
store double %21, double* %3
%22 = load double, double* %3
%23 = fptosi double %22 to i32
store i32 %23, i32* %4
%24 = load float, float* %5
%25 = fptosi float %24 to i16
%26 = load double, double* %3
%27 = load i32, i32* %4
%28 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i16 signext %25, double %26, i32 %27)
%29 = load i32, i32* @INT_MAX
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = trunc i32 %30 to i16
%32 = load i32, i32* %6
%33 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i16 signext %31, i32 %32)
%34 = load i32, i32* %6
%35 = sitofp i32 %34 to float
store float %35, float* %7
%36 = load float, float* %7
%37 = fptosi float %36 to i16
%38 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i16 signext %37)
%39 = load i32, i32* %6
%40 = sitofp i32 %39 to float
%41 = fptosi float %40 to i32
store i32 %41, i32* %6
%42 = load i32, i32* %6
%43 = trunc i32 %42 to i16
%44 = load i32, i32* %6
%45 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i16 signext %43, i32 %44)
store i8 -127, i8* %8
%46 = load i8, i8* %8
%47 = sext i8 %46 to i16
%48 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i16 signext %47)
store i8 -1, i8* %8
%49 = load i8, i8* %8
%50 = sext i8 %49 to i16
%51 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i16 signext %50)
store i32 -12340, i32* %9
%52 = load i32, i32* %9
%53 = sdiv i32 %52, 16
%54 = trunc i32 %53 to i16
%55 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i16 signext %54)
%56 = load i32, i32* %9
%57 = sitofp i32 %56 to float
%58 = fpext float %57 to double
%59 = fdiv double %58, 1.600000e+01
%60 = fptosi double %59 to i16
%61 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i16 signext %60)
store i16 -772, i16* %10
%62 = load i16, i16* %10
%63 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i16 signext %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"a: %f, b: %lf, c: %d\0A\00"
@.str.1 = [22 x i8] c"d: %f, b: %lf, c: %d\0A\00"
@INT_MAX = global i32 0
@.str.2 = [12 x i8] c"x %d(0x%x)\0A\00"
@.str.3 = [6 x i8] c"y %f\0A\00"
@.str.4 = [16 x i8] c"10000001b = %d\0A\00"
@.str.5 = [10 x i8] c"0xff= %d\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i16 signext 1, double 0x3FFFFBE760000000, i32 1)
%2 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i16 signext -1, double 0xBFFFFBE760000000, i32 -1)
%3 = load i32, i32* @INT_MAX
%4 = trunc i32 %3 to i16
%5 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i16 signext %4, i32 %3)
%6 = sitofp i32 %3 to float
%7 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i16 signext %4)
%8 = fptosi float %6 to i32
%9 = trunc i32 %8 to i16
%10 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i16 signext %9, i32 %8)
%11 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i16 signext -127)
%12 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i16 signext -1)
%13 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i16 signext -771)
%14 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i16 signext -771)
%15 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i16 signext -772)
ret i32 0
}