#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  struct jb {
    char actor[25];
    struct jb *next;
  };
  char *bonds[6] = {"Sean Connery", "David Niven",     "George Lazenby",
                    "Roger Moore",  " Timothy Dalton", "Pierce Brosnan"};
  struct jb *first_item;
  struct jb *current_item;
  struct jb *new_item;
  int index = 0;
  first_item = (struct jb *)malloc(sizeof(struct jb));
  current_item = first_item;
  while (1) {
    strcpy(current_item->actor, bonds[index]);
    index++;
    if (index < 6) {
      new_item = (struct jb *)malloc(sizeof(struct jb));
      current_item->next = new_item;
      current_item = new_item;
    } else {
      current_item = NULL;
      break;
    }
  }
  current_item = first_item;
  index = 1;
  while (current_item) {
    printf("Structure %d: ", index++);
    printf("%s\n", current_item->actor);
    current_item = current_item->next;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
lea    0xe9a(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
movslq -0x5c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1030 <strcpy@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x6,-0x5c(%rbp)
jge    120a <main+0xca>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rcx
mov    -0x50(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x58(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1217 <main+0xd7>
movq   $0x0,-0x50(%rbp)
jmp    121c <main+0xdc>
jmp    11be <main+0x7e>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x1,-0x5c(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1271 <main+0x131>
mov    -0x5c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x5c(%rbp)
movslq %eax,%rsi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    122b <main+0xeb>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeb4(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x20(%rbx)
lea    0xea1(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x20(%r14)
lea    0xe8d(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x20(%r15)
lea    0xe7c(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x20(%r14)
lea    0xe68(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%r15)
lea    0xe5b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
test   %rbx,%rbx
je     1233 <main+0x103>
mov    $0x1,%esi
lea    0xe51(%rip),%r14
lea    0xe59(%rip),%r15
nopl   0x0(%rax)
lea    0x1(%rsi),%r12
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x20(%rbx),%rbx
mov    %r12,%rsi
test   %rbx,%rbx
jne    1210 <main+0xe0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 = [15 x i8] c"George Lazenby\00"
@.str.3 = [12 x i8] c"Roger Moore\00"
@.str.4 = [16 x i8] c" Timothy Dalton\00"
@.str.5 = [15 x i8] c"Pierce Brosnan\00"
@.str.6 = [15 x i8] c"Structure %d: \00"
@.str.7 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8*]
%3 = alloca %struct.jb*
%4 = alloca %struct.jb*
%5 = alloca %struct.jb*
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [6 x i8*]* %2 to i8*
%8 = bitcast i8* %7 to [6 x i8*]*
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 3
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 5
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i32 0, i32 0), i8** %14
store i32 0, i32* %6
%15 = call i64 @malloc(i32 40)
%16 = inttoptr i64 %15 to %struct.jb*
store %struct.jb* %16, %struct.jb** %3
%17 = load %struct.jb*, %struct.jb** %3
store %struct.jb* %17, %struct.jb** %4
br label %18
18: ; preds = %0, %39
%19 = load %struct.jb*, %struct.jb** %4
%20 = getelementptr inbounds %struct.jb, %struct.jb* %19, i32 0, i32 0
%21 = getelementptr inbounds [25 x i8], [25 x i8]* %20, i64 0, i64 0
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %21, i8* %25)
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 6
br i1 %30, label %31, label %38
31: ; preds = %18
%32 = call i64 @malloc(i32 40)
%33 = inttoptr i64 %32 to %struct.jb*
store %struct.jb* %33, %struct.jb** %5
%34 = load %struct.jb*, %struct.jb** %5
%35 = load %struct.jb*, %struct.jb** %4
%36 = getelementptr inbounds %struct.jb, %struct.jb* %35, i32 0, i32 1
store %struct.jb* %34, %struct.jb** %36
%37 = load %struct.jb*, %struct.jb** %5
store %struct.jb* %37, %struct.jb** %4
br label %39
38: ; preds = %18
store %struct.jb* null, %struct.jb** %4
br label %40
39: ; preds = %31
br label %18
40: ; preds = %38
%41 = load %struct.jb*, %struct.jb** %3
store %struct.jb* %41, %struct.jb** %4
store i32 1, i32* %6
br label %42
42: ; preds = %45, %40
%43 = load %struct.jb*, %struct.jb** %4
%44 = icmp ne %struct.jb* %43, null
br i1 %44, label %45, label %58
45: ; preds = %42
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
%48 = sext i32 %46 to i64
%49 = inttoptr i64 %48 to i8*
%50 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %49)
%51 = load %struct.jb*, %struct.jb** %4
%52 = getelementptr inbounds %struct.jb, %struct.jb* %51, i32 0, i32 0
%53 = getelementptr inbounds [25 x i8], [25 x i8]* %52, i64 0, i64 0
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %53)
%55 = load %struct.jb*, %struct.jb** %4
%56 = getelementptr inbounds %struct.jb, %struct.jb* %55, i32 0, i32 1
%57 = load %struct.jb*, %struct.jb** %56
store %struct.jb* %57, %struct.jb** %4
br label %42
58: ; preds = %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 = [15 x i8] c"George Lazenby\00"
@.str.3 = [12 x i8] c"Roger Moore\00"
@.str.4 = [16 x i8] c" Timothy Dalton\00"
@.str.5 = [15 x i8] c"Pierce Brosnan\00"
@.str.6 = [15 x i8] c"Structure %d: \00"
@.str.7 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 40)
%2 = inttoptr i64 %1 to %struct.jb*
%3 = getelementptr inbounds %struct.jb, %struct.jb* %2, i64 0, i32 0, i64 0
%4 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to %struct.jb*
%7 = getelementptr inbounds %struct.jb, %struct.jb* %2, i64 0, i32 1
store %struct.jb* %6, %struct.jb** %7
%8 = getelementptr inbounds %struct.jb, %struct.jb* %6, i64 0, i32 0, i64 0
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i64 @malloc(i32 40)
%11 = inttoptr i64 %10 to %struct.jb*
%12 = getelementptr inbounds %struct.jb, %struct.jb* %6, i64 0, i32 1
store %struct.jb* %11, %struct.jb** %12
%13 = getelementptr inbounds %struct.jb, %struct.jb* %11, i64 0, i32 0, i64 0
%14 = tail call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i64 @malloc(i32 40)
%16 = inttoptr i64 %15 to %struct.jb*
%17 = getelementptr inbounds %struct.jb, %struct.jb* %11, i64 0, i32 1
store %struct.jb* %16, %struct.jb** %17
%18 = getelementptr inbounds %struct.jb, %struct.jb* %16, i64 0, i32 0, i64 0
%19 = tail call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i64 @malloc(i32 40)
%21 = inttoptr i64 %20 to %struct.jb*
%22 = getelementptr inbounds %struct.jb, %struct.jb* %16, i64 0, i32 1
store %struct.jb* %21, %struct.jb** %22
%23 = getelementptr inbounds %struct.jb, %struct.jb* %21, i64 0, i32 0, i64 0
%24 = tail call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%25 = tail call i64 @malloc(i32 40)
%26 = inttoptr i64 %25 to %struct.jb*
%27 = getelementptr inbounds %struct.jb, %struct.jb* %21, i64 0, i32 1
store %struct.jb* %26, %struct.jb** %27
%28 = getelementptr inbounds %struct.jb, %struct.jb* %26, i64 0, i32 0, i64 0
%29 = tail call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %1, 0
br i1 %30, label %42, label %31
31: ; preds = %0, %31
%32 = phi i64 [ %34, %31 ], [ 1, %0 ]
%33 = phi %struct.jb* [ %40, %31 ], [ %2, %0 ]
%34 = add nuw i64 %32, 1
%35 = inttoptr i64 %32 to i8*
%36 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds %struct.jb, %struct.jb* %33, i64 0, i32 0, i64 0
%38 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds %struct.jb, %struct.jb* %33, i64 0, i32 1
%40 = load %struct.jb*, %struct.jb** %39
%41 = icmp eq %struct.jb* %40, null
br i1 %41, label %42, label %31
42: ; preds = %31, %0
ret i32 0
}