#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*/ strcpy(char *, char *);
int main(void) {
  typedef struct JB {
    char actor[25];
    struct JB *next;
  } jb;
  char *bonds[6] = {"Sean Connery", "David Niven",    "George Lazenby",
                    "Roger Moore",  "Timothy Dalton", "Pierce Brosnan"};
  jb *current_item;
  jb *first_item;
  jb *new_item;
  int index = 0;
  first_item = (jb *)malloc(sizeof(jb));
  current_item = first_item;
  while (index < 6) {
    strcpy(current_item->actor, bonds[index]);
    new_item = (jb *)malloc(sizeof(jb));
    current_item->next = new_item;
    current_item = new_item;
    index++;
  }
  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   1040 <memset@plt>
lea    0xeaa(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeb2(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x6,-0x5c(%rbp)
jge    11fa <main+0xca>
mov    -0x48(%rbp),%rdi
movslq -0x5c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x58(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ae <main+0x7e>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
lea    0xec8(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x20(%r14)
lea    0xeb5(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x20(%rbx)
lea    0xea1(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x20(%r14)
lea    0xe90(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x20(%rbx)
lea    0xe7c(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x20(%r14)
lea    0xe6b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x20(%rbx)
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 = [15 x i8] c"George Lazenby\00"
@.str.3 = [12 x i8] c"Roger Moore\00"
@.str.4 = [15 x i8] c"Timothy Dalton\00"
@.str.5 = [15 x i8] c"Pierce Brosnan\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 ([15 x i8], [15 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** %4
%17 = load %struct.JB*, %struct.JB** %4
store %struct.JB* %17, %struct.JB** %3
br label %18
18: ; preds = %21, %0
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 6
br i1 %20, label %21, label %38
21: ; preds = %18
%22 = load %struct.JB*, %struct.JB** %3
%23 = getelementptr inbounds %struct.JB, %struct.JB* %22, i32 0, i32 0
%24 = getelementptr inbounds [25 x i8], [25 x i8]* %23, i64 0, i64 0
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @strcpy(i8* %24, i8* %28)
%30 = call i64 @malloc(i32 40)
%31 = inttoptr i64 %30 to %struct.JB*
store %struct.JB* %31, %struct.JB** %5
%32 = load %struct.JB*, %struct.JB** %5
%33 = load %struct.JB*, %struct.JB** %3
%34 = getelementptr inbounds %struct.JB, %struct.JB* %33, i32 0, i32 1
store %struct.JB* %32, %struct.JB** %34
%35 = load %struct.JB*, %struct.JB** %5
store %struct.JB* %35, %struct.JB** %3
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %18
38: ; preds = %18
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 = [15 x i8] c"Timothy Dalton\00"
@.str.5 = [15 x i8] c"Pierce Brosnan\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 ([15 x i8], [15 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 = tail call i64 @malloc(i32 40)
%31 = inttoptr i64 %30 to %struct.JB*
%32 = getelementptr inbounds %struct.JB, %struct.JB* %26, i64 0, i32 1
store %struct.JB* %31, %struct.JB** %32
ret i32 0
}