int main() {
  struct jb {
    char actor[25];
    struct jb *next;
  };
  struct jb *first_item;
  struct jb *current_item;
  struct jb *new_item;
  first_item = (struct jb *)malloc(sizeof(struct jb));
  strcpy(first_item->actor, "Sean Connery");
  new_item = (struct jb *)malloc(sizeof(struct jb));
  first_item->next = new_item;
  current_item = new_item;
  strcpy(current_item->actor, "David Niven");
  new_item = (struct jb *)malloc(sizeof(struct jb));
  current_item->next = new_item;
  puts("The first structure:");
  printf("\tfirst_item->actor = %s\n", first_item->actor);
  printf("\tnext structure adress = %p\n", first_item->next);
  puts("\nThe second structure:");
  printf("\tcurrent_item->actor = %s\n", current_item->actor);
  printf("\tnext structure adress = %p\n", current_item->next);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x20(%rax)
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
mov    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
mov    -0x18(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movabs $0x6e6f43206e616553,%rax
43 6f 6e
mov    %rax,(%rbx)
movabs $0x7972656e6e6f43,%rax
mov    %rax,0x5(%rbx)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x20(%rbx)
movabs $0x694e206469766144,%rax
20 4e 69
mov    %rax,(%r14)
movl   $0x6e6576,0x8(%r14)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%r14)
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%rsi
lea    0xe8d(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%r14),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.jb = type { [25 x i8], %struct.jb* }
@.str = [13 x i8] c"Sean Connery\00"
@.str.1 = [12 x i8] c"David Niven\00"
@.str.2 = [21 x i8] c"The first structure:\00"
@.str.3 = [25 x i8] c"\09first_item->actor = %s\0A\00"
@.str.4 = [29 x i8] c"\09next structure adress = %p\0A\00"
@.str.5 = [23 x i8] c"\0AThe second structure:\00"
@.str.6 = [27 x i8] c"\09current_item->actor = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.jb*
%3 = alloca %struct.jb*
%4 = alloca %struct.jb*
store i32 0, i32* %1
%5 = call i8* @malloc(i64 40)
%6 = bitcast i8* %5 to %struct.jb*
store %struct.jb* %6, %struct.jb** %2
%7 = load %struct.jb*, %struct.jb** %2
%8 = getelementptr inbounds %struct.jb, %struct.jb* %7, i32 0, i32 0
%9 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 0
%10 = call i8* @strcpy(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = call i8* @malloc(i64 40)
%12 = bitcast i8* %11 to %struct.jb*
store %struct.jb* %12, %struct.jb** %4
%13 = load %struct.jb*, %struct.jb** %4
%14 = load %struct.jb*, %struct.jb** %2
%15 = getelementptr inbounds %struct.jb, %struct.jb* %14, i32 0, i32 1
store %struct.jb* %13, %struct.jb** %15
%16 = load %struct.jb*, %struct.jb** %4
store %struct.jb* %16, %struct.jb** %3
%17 = load %struct.jb*, %struct.jb** %3
%18 = getelementptr inbounds %struct.jb, %struct.jb* %17, i32 0, i32 0
%19 = getelementptr inbounds [25 x i8], [25 x i8]* %18, i64 0, i64 0
%20 = call i8* @strcpy(i8* %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%21 = call i8* @malloc(i64 40)
%22 = bitcast i8* %21 to %struct.jb*
store %struct.jb* %22, %struct.jb** %4
%23 = load %struct.jb*, %struct.jb** %4
%24 = load %struct.jb*, %struct.jb** %3
%25 = getelementptr inbounds %struct.jb, %struct.jb* %24, i32 0, i32 1
store %struct.jb* %23, %struct.jb** %25
%26 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%27 = load %struct.jb*, %struct.jb** %2
%28 = getelementptr inbounds %struct.jb, %struct.jb* %27, i32 0, i32 0
%29 = getelementptr inbounds [25 x i8], [25 x i8]* %28, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load %struct.jb*, %struct.jb** %2
%32 = getelementptr inbounds %struct.jb, %struct.jb* %31, i32 0, i32 1
%33 = load %struct.jb*, %struct.jb** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), %struct.jb* %33)
%35 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%36 = load %struct.jb*, %struct.jb** %3
%37 = getelementptr inbounds %struct.jb, %struct.jb* %36, i32 0, i32 0
%38 = getelementptr inbounds [25 x i8], [25 x i8]* %37, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %38)
%40 = load %struct.jb*, %struct.jb** %3
%41 = getelementptr inbounds %struct.jb, %struct.jb* %40, i32 0, i32 1
%42 = load %struct.jb*, %struct.jb** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), %struct.jb* %42)
ret i32 0
}

LLVM IR (-O2):
%struct.jb = type { [25 x i8], %struct.jb* }
@.str = [13 x i8] c"Sean Connery\00"
@.str.1 = [12 x i8] c"David Niven\00"
@.str.2 = [21 x i8] c"The first structure:\00"
@.str.3 = [25 x i8] c"\09first_item->actor = %s\0A\00"
@.str.4 = [29 x i8] c"\09next structure adress = %p\0A\00"
@.str.5 = [23 x i8] c"\0AThe second structure:\00"
@.str.6 = [27 x i8] c"\09current_item->actor = %s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(40) i8* @malloc(i64 40)
%2 = bitcast i8* %1 to %struct.jb*
%3 = getelementptr inbounds %struct.jb, %struct.jb* %2, i64 0, i32 0, i64 0
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(13) %3, i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13, i1 false)
%4 = tail call dereferenceable_or_null(40) i8* @malloc(i64 40)
%5 = bitcast i8* %4 to %struct.jb*
%6 = getelementptr inbounds %struct.jb, %struct.jb* %2, i64 0, i32 1
%7 = bitcast %struct.jb** %6 to i8**
store i8* %4, i8** %7
%8 = getelementptr inbounds %struct.jb, %struct.jb* %5, i64 0, i32 0, i64 0
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %8, i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 12, i1 false)
%9 = tail call dereferenceable_or_null(40) i8* @malloc(i64 40)
%10 = getelementptr inbounds %struct.jb, %struct.jb* %5, i64 0, i32 1
%11 = bitcast %struct.jb** %10 to i8**
store i8* %9, i8** %11
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%14 = load %struct.jb*, %struct.jb** %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), %struct.jb* %14)
%16 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%18 = load %struct.jb*, %struct.jb** %10
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), %struct.jb* %18)
ret i32 0
}