#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 */
struct rmDsummary {
  int dummy;
};
struct list {
  int dummy;
};

/* Variables and functions */
struct list *cctools_list_create(int /*<<< orphan*/);
int /*<<< orphan*/ cctools_list_first_item(struct list *);
struct rmDsummary *cctools_list_next_item(struct list *);
int /*<<< orphan*/ cctools_list_push_head(struct list *, int /*<<< orphan*/);
int /*<<< orphan*/ cluster_create(struct rmDsummary *);
struct list *create_initial_clusters(struct list *summaries) {
  struct rmDsummary *s;
  struct list *initial_clusters = cctools_list_create(0);
  cctools_list_first_item(summaries);
  while ((s = cctools_list_next_item(summaries)))
    cctools_list_push_head(initial_clusters, cluster_create(s));
  return initial_clusters;
}


x86 assembly (clang, -O0):
<create_initial_clusters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1050 <cctools_list_create@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <cctools_list_first_item@plt>
mov    -0x8(%rbp),%rdi
call   1030 <cctools_list_next_item@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a8 <create_initial_clusters+0x58>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <cluster_create@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1040 <cctools_list_push_head@plt>
jmp    1170 <create_initial_clusters+0x20>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_initial_clusters>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
call   1050 <cctools_list_create@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <cctools_list_first_item@plt>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <cctools_list_next_item@plt>
test   %rax,%rax
je     1191 <create_initial_clusters+0x41>
mov    %rax,%rdi
call   1060 <cluster_create@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <cctools_list_push_head@plt>
jmp    1170 <create_initial_clusters+0x20>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.list = type { i32 }
%struct.rmDsummary = type { i32 }
define %struct.list* @create_initial_clusters(%struct.list* %0) {
%2 = alloca %struct.list*
%3 = alloca %struct.rmDsummary*
%4 = alloca %struct.list*
store %struct.list* %0, %struct.list** %2
%5 = call %struct.list* @cctools_list_create(i32 0)
store %struct.list* %5, %struct.list** %4
%6 = load %struct.list*, %struct.list** %2
%7 = call i32 @cctools_list_first_item(%struct.list* %6)
br label %8
8: ; preds = %12, %1
%9 = load %struct.list*, %struct.list** %2
%10 = call %struct.rmDsummary* @cctools_list_next_item(%struct.list* %9)
store %struct.rmDsummary* %10, %struct.rmDsummary** %3
%11 = icmp ne %struct.rmDsummary* %10, null
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load %struct.list*, %struct.list** %4
%14 = load %struct.rmDsummary*, %struct.rmDsummary** %3
%15 = call i32 @cluster_create(%struct.rmDsummary* %14)
%16 = call i32 @cctools_list_push_head(%struct.list* %13, i32 %15)
br label %8
17: ; preds = %8
%18 = load %struct.list*, %struct.list** %4
ret %struct.list* %18
}

LLVM IR (-O2):
%struct.list = type { i32 }
%struct.rmDsummary = type { i32 }
define %struct.list* @create_initial_clusters(%struct.list* %0) {
%2 = tail call %struct.list* @cctools_list_create(i32 0)
%3 = tail call i32 @cctools_list_first_item(%struct.list* %0)
%4 = tail call %struct.rmDsummary* @cctools_list_next_item(%struct.list* %0)
%5 = icmp eq %struct.rmDsummary* %4, null
br i1 %5, label %12, label %6
6: ; preds = %1, %6
%7 = phi %struct.rmDsummary* [ %10, %6 ], [ %4, %1 ]
%8 = tail call i32 @cluster_create(%struct.rmDsummary* %7)
%9 = tail call i32 @cctools_list_push_head(%struct.list* %2, i32 %8)
%10 = tail call %struct.rmDsummary* @cctools_list_next_item(%struct.list* %0)
%11 = icmp eq %struct.rmDsummary* %10, null
br i1 %11, label %12, label %6
12: ; preds = %6, %1
ret %struct.list* %2
}