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

/* Variables and functions */
int /*<<< orphan*/ int_list_add(struct _int_list *, int);
struct _int_list *int_list_initial();
struct _int_list *int_list_initial_by_array(int _array[], int _size) {
  struct _int_list *s = int_list_initial();
  int i;
  for (i = 0; i < _size; i++)
    int_list_add(s, _array[i]);
  return s;
}


x86 assembly (clang, -O0):
<int_list_initial_by_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1030 <int_list_initial@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116f <int_list_initial_by_array+0x4f>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <int_list_add@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <int_list_initial_by_array+0x21>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_list_initial_by_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <int_list_initial@plt>
mov    %rax,%r15
test   %ebp,%ebp
jle    1155 <int_list_initial_by_array+0x35>
mov    %ebp,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
call   1040 <int_list_add@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <int_list_initial_by_array+0x20>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct._int_list = type { i32 }
define %struct._int_list* @int_list_initial_by_array(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct._int_list*
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = call %struct._int_list* (...) @int_list_initial()
store %struct._int_list* %7, %struct._int_list** %5
store i32 0, i32* %6
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load %struct._int_list*, %struct._int_list** %5
%14 = load i32*, i32** %3
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @int_list_add(%struct._int_list* %13, i32 %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %8
23: ; preds = %8
%24 = load %struct._int_list*, %struct._int_list** %5
ret %struct._int_list* %24
}

LLVM IR (-O2):
%struct._int_list = type { i32 }
define %struct._int_list* @int_list_initial_by_array(i32* nocapture %0, i32 %1) {
%3 = tail call %struct._int_list* (...) @int_list_initial()
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %14
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %12, %7 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = tail call i32 @int_list_add(%struct._int_list* %3, i32 %10)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %7
14: ; preds = %7, %2
ret %struct._int_list* %3
}