#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 *, ...);
void main() {
  int i;
  struct student {
    long num;
    char name[20];
    char sex;
    int age;
  };
  struct student stu[3] = {{10101, "Li Lin", 'M', 18},
                           {10102, "Zhang Fun", 'M', 19},
                           {10104, "Wang Min", 'F', 20}};
  struct student *p, *pm;
  printf("No.     Name                 Sex  age\n");
  for (p = stu; p < stu + 3; p++) {
    printf("%5d   %-20s %2c %4d\n", p->num, p->name, p->sex, p->age);
  }
  printf("\nAddress type change:\n");
  pm = (struct student *)stu[0].name;
  for (i = 0; i < 3; i++) {
    printf("name = %s\n", pm++);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    -0x80(%rbp),%rdi
lea    0xeca(%rip),%rsi
mov    $0x78,%edx
call   1040 <memcpy@plt>
lea    0xf31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
lea    -0x80(%rbp),%rcx
add    $0x78,%rcx
cmp    %rcx,%rax
jae    11c1 <main+0xa1>
mov    -0x88(%rbp),%rax
mov    (%rax),%rsi
mov    -0x88(%rbp),%rdx
add    $0x8,%rdx
mov    -0x88(%rbp),%rax
movsbl 0x1c(%rax),%ecx
mov    -0x88(%rbp),%rax
mov    0x20(%rax),%r8d
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%rax
add    $0x28,%rax
mov    %rax,-0x88(%rbp)
jmp    1159 <main+0x39>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    1220 <main+0x100>
mov    -0x90(%rbp),%rsi
mov    %rsi,%rax
add    $0x28,%rax
mov    %rax,-0x90(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e5 <main+0xc5>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    0xf3d(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xf21(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xf05(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
lea    0x78(%rsp),%r15
lea    0xed2(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%rsi
movsbl 0x1c(%rbx),%ecx
mov    0x20(%rbx),%r8d
lea    0x8(%rbx),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rbx
cmp    %r15,%rbx
jb     11b0 <main+0x90>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
lea    0x30(%rsp),%r14
lea    0xe9e(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x58(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.student = type { i64, [20 x i8], i8, i32 }
@__const.main.stu = [3 x %struct.student] [%struct.student { i64 10101, [20 x i8] c"Li Lin\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i8 77, i32 18 }, %struct.student { i64 10102, [20 x i8] c"Zhang Fun\00\00\00\00\00\00\00\00\00\00\00", i8 77, i32 19 }, %struct.student { i64 10104, [20 x i8] c"Wang Min\00\00\00\00\00\00\00\00\00\00\00\00", i8 70, i32 20 }]
@.str = [39 x i8] c"No. Name Sex age\0A\00"
@.str.1 = [21 x i8] c"%5d %-20s %2c %4d\0A\00"
@.str.2 = [23 x i8] c"\0AAddress type change:\0A\00"
@.str.3 = [11 x i8] c"name = %s\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [3 x %struct.student]
%3 = alloca %struct.student*
%4 = alloca %struct.student*
%5 = bitcast [3 x %struct.student]* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %2, i64 0, i64 0
store %struct.student* %7, %struct.student** %3
br label %8
8: ; preds = %28, %0
%9 = load %struct.student*, %struct.student** %3
%10 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %2, i64 0, i64 0
%11 = getelementptr inbounds %struct.student, %struct.student* %10, i64 3
%12 = icmp ult %struct.student* %9, %11
br i1 %12, label %13, label %31
13: ; preds = %8
%14 = load %struct.student*, %struct.student** %3
%15 = getelementptr inbounds %struct.student, %struct.student* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load %struct.student*, %struct.student** %3
%18 = getelementptr inbounds %struct.student, %struct.student* %17, i32 0, i32 1
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 0
%20 = load %struct.student*, %struct.student** %3
%21 = getelementptr inbounds %struct.student, %struct.student* %20, i32 0, i32 2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load %struct.student*, %struct.student** %3
%25 = getelementptr inbounds %struct.student, %struct.student* %24, i32 0, i32 3
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %16, i8* %19, i32 %23, i32 %26)
br label %28
28: ; preds = %13
%29 = load %struct.student*, %struct.student** %3
%30 = getelementptr inbounds %struct.student, %struct.student* %29, i32 1
store %struct.student* %30, %struct.student** %3
br label %8
31: ; preds = %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%33 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %2, i64 0, i64 0
%34 = getelementptr inbounds %struct.student, %struct.student* %33, i32 0, i32 1
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %34, i64 0, i64 0
%36 = bitcast i8* %35 to %struct.student*
store %struct.student* %36, %struct.student** %4
store i32 0, i32* %1
br label %37
37: ; preds = %44, %31
%38 = load i32, i32* %1
%39 = icmp slt i32 %38, 3
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load %struct.student*, %struct.student** %4
%42 = getelementptr inbounds %struct.student, %struct.student* %41, i32 1
store %struct.student* %42, %struct.student** %4
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %struct.student* %41)
br label %44
44: ; preds = %40
%45 = load i32, i32* %1
%46 = add nsw i32 %45, 1
store i32 %46, i32* %1
br label %37
47: ; preds = %37
ret void
}

LLVM IR (-O2):
%struct.student = type { i64, [20 x i8], i8, i32 }
@__const.main.stu = [3 x %struct.student] [%struct.student { i64 10101, [20 x i8] c"Li Lin\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i8 77, i32 18 }, %struct.student { i64 10102, [20 x i8] c"Zhang Fun\00\00\00\00\00\00\00\00\00\00\00", i8 77, i32 19 }, %struct.student { i64 10104, [20 x i8] c"Wang Min\00\00\00\00\00\00\00\00\00\00\00\00", i8 70, i32 20 }]
@.str.1 = [21 x i8] c"%5d %-20s %2c %4d\0A\00"
@.str.3 = [11 x i8] c"name = %s\0A\00"
@str = [38 x i8] c"No. Name Sex age\00"
@str.4 = [22 x i8] c"\0AAddress type change:\00"
define void @main() {
%1 = alloca [3 x %struct.student]
%2 = bitcast [3 x %struct.student]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %1, i64 0, i64 0
%5 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %1, i64 0, i64 3
br label %6
6: ; preds = %0, %6
%7 = phi %struct.student* [ %4, %0 ], [ %17, %6 ]
%8 = getelementptr inbounds %struct.student, %struct.student* %7, i64 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.student, %struct.student* %7, i64 0, i32 1, i64 0
%11 = getelementptr inbounds %struct.student, %struct.student* %7, i64 0, i32 2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = getelementptr inbounds %struct.student, %struct.student* %7, i64 0, i32 3
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %9, i8* %10, i32 %13, i32 %15)
%17 = getelementptr inbounds %struct.student, %struct.student* %7, i64 1
%18 = icmp ult %struct.student* %17, %5
br i1 %18, label %6, label %19
19: ; preds = %6
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%21 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %1, i64 0, i64 0, i32 1, i64 0
%22 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %1, i64 0, i64 0, i32 1, i64 40
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%24 = getelementptr inbounds [3 x %struct.student], [3 x %struct.student]* %1, i64 0, i64 0, i32 1, i64 80
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %24)
ret void
}