#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 LONG_MAX;
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("Check the size of type\n");
  printf("short: %lu int: %lu long: %lu\n", sizeof(short), sizeof(int),
         sizeof(long));
  short vivian = -20;
  unsigned int claire = 20;
  if (vivian < claire) {
    printf("value unchanged\n");
  } else {
    printf("value changed\n");
  }
  printf("%d\n", vivian);
  long elsa = LONG_MAX - 10;
  int anna = elsa;
  printf("elsa: %li, anna: %i\n", elsa, anna);
  long mario = LONG_MAX;
  float luigi = mario;
  double toad = mario;
  printf("\nmario: %li\nluigi: %f\n toad: %lf\n\n", mario, luigi, toad);
  float pi = 3.14159;
  float e = 2.718;
  int c_pi = pi;
  int c_e = e;
  printf("pi convert to int is: %i, e convert to int is: %i\n", c_pi, c_e);
  int explicit = -20;
  unsigned short value_loss = (unsigned short)explicit;

  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x2,%esi
mov    $0x4,%edx
mov    $0x8,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0xffec,-0x6(%rbp)
movl   $0x14,-0xc(%rbp)
movswl -0x6(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1177 <main+0x67>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <main+0x75>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
sub    $0xa,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e14(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x28(%rbp)
cvtsi2ssq -0x28(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rsi
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe76(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  0xdf3(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xde2(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
cvttss2si -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
cvttss2si -0x40(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffec,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %ax,-0x4e(%rbp)
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf66(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
mov    $0x2,%esi
mov    $0x4,%edx
mov    $0x8,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf54(%rip),%rdi
call   1030 <puts@plt>
lea    0xec2(%rip),%rdi
mov    $0xffffffec,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e70(%rip),%rbx
movslq (%rbx),%rdx
add    $0xfffffffffffffff6,%rdx
lea    0xea5(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq (%rbx),%rsi
cvtsi2ss %esi,%xmm0
cvtsi2sd %esi,%xmm1
cvtss2sd %xmm0,%xmm0
lea    0xe9a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x3,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Check the size of type\0A\00"
@.str.1 = [31 x i8] c"short: %lu int: %lu long: %lu\0A\00"
@.str.2 = [17 x i8] c"value unchanged\0A\00"
@.str.3 = [15 x i8] c"value changed\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@LONG_MAX = global i32 0
@.str.5 = [21 x i8] c"elsa: %li, anna: %i\0A\00"
@.str.6 = [35 x i8] c"\0Amario: %li\0Aluigi: %f\0A toad: %lf\0A\0A\00"
@.str.7 = [51 x i8] c"pi convert to int is: %i, e convert to int is: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca float
%8 = alloca double
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i16
store i32 0, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 4, i64 8)
store i16 -20, i16* %2
store i32 20, i32* %3
%17 = load i16, i16* %2
%18 = sext i16 %17 to i32
%19 = load i32, i32* %3
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
%26 = load i16, i16* %2
%27 = sext i16 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @LONG_MAX
%30 = sub nsw i32 %29, 10
%31 = sext i32 %30 to i64
store i64 %31, i64* %4
%32 = load i64, i64* %4
%33 = trunc i64 %32 to i32
store i32 %33, i32* %5
%34 = load i64, i64* %4
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i64 %34, i32 %35)
%37 = load i32, i32* @LONG_MAX
%38 = sext i32 %37 to i64
store i64 %38, i64* %6
%39 = load i64, i64* %6
%40 = sitofp i64 %39 to float
store float %40, float* %7
%41 = load i64, i64* %6
%42 = sitofp i64 %41 to double
store double %42, double* %8
%43 = load i64, i64* %6
%44 = load float, float* %7
%45 = fpext float %44 to double
%46 = load double, double* %8
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i64 %43, double %45, double %46)
store float 0x400921FA00000000, float* %9
store float 0x4005BE76C0000000, float* %10
%48 = load float, float* %9
%49 = fptosi float %48 to i32
store i32 %49, i32* %11
%50 = load float, float* %10
%51 = fptosi float %50 to i32
store i32 %51, i32* %12
%52 = load i32, i32* %11
%53 = load i32, i32* %12
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %52, i32 %53)
store i32 -20, i32* %13
%55 = load i32, i32* %13
%56 = trunc i32 %55 to i16
store i16 %56, i16* %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"short: %lu int: %lu long: %lu\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@LONG_MAX = global i32 0
@.str.5 = [21 x i8] c"elsa: %li, anna: %i\0A\00"
@.str.6 = [35 x i8] c"\0Amario: %li\0Aluigi: %f\0A toad: %lf\0A\0A\00"
@.str.7 = [51 x i8] c"pi convert to int is: %i, e convert to int is: %i\0A\00"
@str = [23 x i8] c"Check the size of type\00"
@str.8 = [14 x i8] c"value changed\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 4, i64 8)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 -20)
%5 = load i32, i32* @LONG_MAX
%6 = add nsw i32 %5, -10
%7 = sext i32 %6 to i64
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i64 %7, i32 %6)
%9 = load i32, i32* @LONG_MAX
%10 = sext i32 %9 to i64
%11 = sitofp i32 %9 to float
%12 = sitofp i32 %9 to double
%13 = fpext float %11 to double
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i64 %10, double %13, double %12)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 3, i32 2)
ret i32 0
}