#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 node {
  int dummy;
};

/* Variables and functions */
struct node *InsertInFront(struct node *, int);
struct node *CreateList(int values[], int len) {
  if (len == 0)
    return NULL;
  struct node *head = NULL;
  int i;
  for (i = len; i > 0; i--) {
    head = InsertInFront(head, values[i - 1]);
  }
  return head;
}


x86 assembly (clang, -O0):
<CreateList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1136 <CreateList+0x26>
movq   $0x0,-0x8(%rbp)
jmp    1181 <CreateList+0x71>
movq   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1179 <CreateList+0x69>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <InsertInFront@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <CreateList+0x34>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateList>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    114b <CreateList+0x3b>
mov    %rdi,%r14
mov    %esi,%ebx
add    $0x1,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x2(%rbx),%ecx
mov    (%r14,%rcx,4),%esi
mov    %rax,%rdi
call   1030 <InsertInFront@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1130 <CreateList+0x20>
jmp    114d <CreateList+0x3d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.node = type { i32 }
define %struct.node* @CreateList(i32* %0, i32 %1) {
%3 = alloca %struct.node*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.node*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store %struct.node* null, %struct.node** %3
br label %30
11: ; preds = %2
store %struct.node* null, %struct.node** %6
%12 = load i32, i32* %5
store i32 %12, i32* %7
br label %13
13: ; preds = %25, %11
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load %struct.node*, %struct.node** %6
%18 = load i32*, i32** %4
%19 = load i32, i32* %7
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %18, i64 %21
%23 = load i32, i32* %22
%24 = call %struct.node* @InsertInFront(%struct.node* %17, i32 %23)
store %struct.node* %24, %struct.node** %6
br label %25
25: ; preds = %16
%26 = load i32, i32* %7
%27 = add nsw i32 %26, -1
store i32 %27, i32* %7
br label %13
28: ; preds = %13
%29 = load %struct.node*, %struct.node** %6
store %struct.node* %29, %struct.node** %3
br label %30
30: ; preds = %28, %10
%31 = load %struct.node*, %struct.node** %3
ret %struct.node* %31
}

LLVM IR (-O2):
%struct.node = type { i32 }
define %struct.node* @CreateList(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %5, %4 ], [ %9, %6 ]
%8 = phi %struct.node* [ null, %4 ], [ %13, %6 ]
%9 = add nsw i64 %7, -1
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = tail call %struct.node* @InsertInFront(%struct.node* %8, i32 %12)
%14 = icmp ugt i64 %7, 1
br i1 %14, label %6, label %15
15: ; preds = %6, %2
%16 = phi %struct.node* [ null, %2 ], [ %13, %6 ]
ret %struct.node* %16
}