#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, char);
void example3() {
  char c = 'A';
  int *ptr;
  int j;
  printf("Size of pointer %ld \n", sizeof(*ptr));
  ptr = malloc(1000 * sizeof(int));
  printf("Size after allocating memory: %ld \n", sizeof(*ptr));
  *ptr = 100;
  printf("Now ptr value has changed: %d \n", *ptr);
  printf("c value is %d \n", c);
  free(ptr);
}


x86 assembly (clang, -O0):
<example3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movb   $0x41,-0x1(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
mov    $0xfa0,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x64,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
lea    0xeb7(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example3>:
push   %rbx
lea    0xec8(%rip),%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
mov    $0xfa0,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xec0(%rip),%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
movl   $0x64,(%rbx)
lea    0xecd(%rip),%rdi
mov    $0x64,%esi
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x41,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Size of pointer %ld \0A\00"
@.str.1 = [36 x i8] c"Size after allocating memory: %ld \0A\00"
@.str.2 = [32 x i8] c"Now ptr value has changed: %d \0A\00"
@.str.3 = [16 x i8] c"c value is %d \0A\00"
define void @example3() {
%1 = alloca i8
%2 = alloca i32*
%3 = alloca i32
store i8 65, i8* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 4)
%5 = call i32* @malloc(i32 4000)
store i32* %5, i32** %2
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8 signext 4)
%7 = load i32*, i32** %2
store i32 100, i32* %7
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = trunc i32 %9 to i8
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8 signext %10)
%12 = load i8, i8* %1
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8 signext %12)
%14 = load i32*, i32** %2
%15 = call i32 @free(i32* %14)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Size of pointer %ld \0A\00"
@.str.1 = [36 x i8] c"Size after allocating memory: %ld \0A\00"
@.str.2 = [32 x i8] c"Now ptr value has changed: %d \0A\00"
@.str.3 = [16 x i8] c"c value is %d \0A\00"
define void @example3() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 4)
%2 = tail call i32* @malloc(i32 4000)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8 signext 4)
store i32 100, i32* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8 signext 100)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8 signext 65)
%6 = tail call i32 @free(i32* %2)
ret void
}