#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 *, long);
int main(void) {
  int a;
  long b;
  a = 100000;
  b = a * a;
  printf("Resut without Casting:%ld\n", b);
  a = 100000;
  b = (long)(a * a);
  printf("Resut with impropper Casting:%ld\n", b);
  a = 100000;
  b = (long)a * a;
  printf("Resut with propper Casting:%ld\n", b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x186a0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x186a0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x186a0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb4(%rip),%rdi
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    $0x540be400,%esi
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x540be400,%esi
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
movabs $0x2540be400,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Resut without Casting:%ld\0A\00"
@.str.1 = [34 x i8] c"Resut with impropper Casting:%ld\0A\00"
@.str.2 = [32 x i8] c"Resut with propper Casting:%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
store i32 100000, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* %2
%6 = mul nsw i32 %4, %5
%7 = sext i32 %6 to i64
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %8)
store i32 100000, i32* %2
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = mul nsw i32 %10, %11
%13 = sext i32 %12 to i64
store i64 %13, i64* %3
%14 = load i64, i64* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %14)
store i32 100000, i32* %2
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = mul nsw i64 %17, %19
store i64 %20, i64* %3
%21 = load i64, i64* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Resut without Casting:%ld\0A\00"
@.str.1 = [34 x i8] c"Resut with impropper Casting:%ld\0A\00"
@.str.2 = [32 x i8] c"Resut with propper Casting:%ld\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 1410065408)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 1410065408)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 10000000000)
ret i32 0
}