void main() {
  struct student {
    char *name;
    int score;
  } stu, *pstu, *pstu1;
  stu.score = 99;
  printf("%d\n", stu.score);
  pstu = (struct student *)malloc(sizeof(struct student));
  pstu->score = 99;
  printf("%d\n", pstu->score);
  free(pstu);
  pstu1 = (struct student *)malloc(sizeof(struct student *));
  pstu1->score = 99;
  printf("%d\n", pstu1->score);
  free(pstu1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x63,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x63,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x63,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x63,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.student = type { i8*, i32 }
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca %struct.student
%2 = alloca %struct.student*
%3 = alloca %struct.student*
%4 = getelementptr inbounds %struct.student, %struct.student* %1, i32 0, i32 1
store i32 99, i32* %4
%5 = getelementptr inbounds %struct.student, %struct.student* %1, i32 0, i32 1
%6 = load i32, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i8* @malloc(i64 16)
%9 = bitcast i8* %8 to %struct.student*
store %struct.student* %9, %struct.student** %2
%10 = load %struct.student*, %struct.student** %2
%11 = getelementptr inbounds %struct.student, %struct.student* %10, i32 0, i32 1
store i32 99, i32* %11
%12 = load %struct.student*, %struct.student** %2
%13 = getelementptr inbounds %struct.student, %struct.student* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load %struct.student*, %struct.student** %2
%17 = bitcast %struct.student* %16 to i8*
%18 = call i8* @malloc(i64 8)
%19 = bitcast i8* %18 to %struct.student*
store %struct.student* %19, %struct.student** %3
%20 = load %struct.student*, %struct.student** %3
%21 = getelementptr inbounds %struct.student, %struct.student* %20, i32 0, i32 1
store i32 99, i32* %21
%22 = load %struct.student*, %struct.student** %3
%23 = getelementptr inbounds %struct.student, %struct.student* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load %struct.student*, %struct.student** %3
%27 = bitcast %struct.student* %26 to i8*
ret void
}

LLVM IR (-O2):
%struct.student = type { i8*, i32 }
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 99)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 99)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 99)
ret void
}