int main() {
  char *p = (char *)malloc(3);
  *p = 'a';
  *(p + 1) = 'b';
  *(p + 2) = 'c';
  free(p);
  *p = 'a';
  *(p + 1) = 'd';
  char *str1 = "Dines";
  char *str2 = (char *)malloc(6 * sizeof(char));
  strcpy(str2, str1);
  printf("%s\n", str2);
  char *mem = (char *)malloc(6 * sizeof(char));
  long int i = 0;
  for (i = 0; i < 1000000000; i++) {
    mem[i] = 'p';
  }
  for (i = 0; i < 1000000000; i++) {
    printf("%c ", mem[i]);
  }
  char *point = (char *)0100;
  *point = 'e';
  printf("%c\n", point);
  int num;
  printf("Num value %u\n ", &num);
  printf("Enter a number ");
  scanf("%d", num);
  int var = 10;
  int *pointer;
  pointer = &var;
  printf("Address : %u\n value : %d\n", pointer, *pointer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x61,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x62,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x63,0x2(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movb   $0x61,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x64,0x1(%rax)
lea    0xe5d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x3b9aca00,-0x30(%rbp)
3b
jge    121d <main+0xcd>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x70,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11f2 <main+0xa2>
movq   $0x0,-0x30(%rbp)
cmpq   $0x3b9aca00,-0x30(%rbp)
3b
jge    125e <main+0x10e>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1225 <main+0xd5>
mov    $0x40,%eax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x65,(%rax)
mov    -0x38(%rbp),%rsi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd8b(%rip),%rdi
lea    -0x3c(%rbp),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0xa,-0x40(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
mov    -0x48(%rbp),%rax
mov    (%rax),%edx
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x6,%edi
call   1060 <malloc@plt>
movl   $0x656e6944,(%rax)
movw   $0x73,0x4(%rax)
mov    %rax,%rdi
call   1030 <puts@plt>
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x3b9aca00,%edx
mov    %rax,%rdi
mov    $0x70,%esi
call   1050 <memset@plt>
lea    0xe69(%rip),%r14
mov    %r14,%rdi
mov    $0x70,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x3b9aca00,%rbx
jne    11c0 <main+0x70>
movb   $0x65,0x40
65
lea    0xe1f(%rip),%rdi
mov    $0x40,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe10(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe0a(%rip),%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
movl   $0xa,0x8(%rsp)
lea    0xdf7(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Dines\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [4 x i8] c"%c\0A\00"
@.str.4 = [15 x i8] c"Num value %u\0A \00"
@.str.5 = [16 x i8] c"Enter a number \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [26 x i8] c"Address : %u\0A value : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %1
%11 = call i8* @malloc(i64 3)
store i8* %11, i8** %2
%12 = load i8*, i8** %2
store i8 97, i8* %12
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8 98, i8* %14
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 2
store i8 99, i8* %16
%17 = load i8*, i8** %2
%18 = load i8*, i8** %2
store i8 97, i8* %18
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 100, i8* %20
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
%21 = call i8* @malloc(i64 6)
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = load i8*, i8** %3
%24 = call i8* @strcpy(i8* %22, i8* %23)
%25 = load i8*, i8** %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = call i8* @malloc(i64 6)
store i8* %27, i8** %5
store i64 0, i64* %6
store i64 0, i64* %6
br label %28
28: ; preds = %35, %0
%29 = load i64, i64* %6
%30 = icmp slt i64 %29, 1000000000
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i8*, i8** %5
%33 = load i64, i64* %6
%34 = getelementptr inbounds i8, i8* %32, i64 %33
store i8 112, i8* %34
br label %35
35: ; preds = %31
%36 = load i64, i64* %6
%37 = add nsw i64 %36, 1
store i64 %37, i64* %6
br label %28
38: ; preds = %28
store i64 0, i64* %6
br label %39
39: ; preds = %49, %38
%40 = load i64, i64* %6
%41 = icmp slt i64 %40, 1000000000
br i1 %41, label %42, label %52
42: ; preds = %39
%43 = load i8*, i8** %5
%44 = load i64, i64* %6
%45 = getelementptr inbounds i8, i8* %43, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %42
%50 = load i64, i64* %6
%51 = add nsw i64 %50, 1
store i64 %51, i64* %6
br label %39
52: ; preds = %39
store i8* inttoptr (i64 64 to i8*), i8** %7
%53 = load i8*, i8** %7
store i8 101, i8* %53
%54 = load i8*, i8** %7
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%58 = load i32, i32* %8
%59 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %58)
store i32 10, i32* %9
store i32* %9, i32** %10
%60 = load i32*, i32** %10
%61 = load i32*, i32** %10
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32* %60, i32 %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"Dines\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [4 x i8] c"%c\0A\00"
@.str.4 = [15 x i8] c"Num value %u\0A \00"
@.str.5 = [16 x i8] c"Enter a number \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [26 x i8] c"Address : %u\0A value : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call dereferenceable_or_null(6) i8* @malloc(i64 6)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(6) %3, i8* align 1 dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 6, i1 false)
%4 = tail call i32 @puts(i8* dereferenceable(1) %3)
%5 = tail call dereferenceable_or_null(6) i8* @malloc(i64 6)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 112)
br label %7
7: ; preds = %0, %7
%8 = phi i64 [ 1, %0 ], [ %13, %7 ]
%9 = getelementptr inbounds i8, i8* %5, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, 1000000000
br i1 %14, label %15, label %7
15: ; preds = %7
store i8 101, i8* inttoptr (i64 64 to i8*)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* inttoptr (i64 64 to i8*))
%17 = bitcast i32* %1 to i8*
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%20 = load i32, i32* %1
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%22 = bitcast i32* %2 to i8*
store i32 10, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32* %2, i32 10)
ret i32 0
}