#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 */
int atoi(char *);
int /*<<< orphan*/ print_int_array(int *, int);
void fillArray(int argc, char *argv[], int a[], int num_elements) {
  int i;
  for (i = 0; i < num_elements; i++)
    a[i] = atoi(argv[i + 1]);
  print_int_array(a, num_elements);
}


x86 assembly (clang, -O0):
<fillArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117a <fillArray+0x5a>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <fillArray+0x1d>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <print_int_array@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r12
test   %ecx,%ecx
jle    115a <fillArray+0x3a>
mov    %rsi,%r15
mov    %r14d,%r13d
xor    %ebx,%ebx
nopl   (%rax)
lea    0x1(%rbx),%rbp
mov    0x8(%r15,%rbx,8),%rdi
call   1030 <atoi@plt>
mov    %eax,(%r12,%rbx,4)
mov    %rbp,%rbx
cmp    %rbp,%r13
jne    1140 <fillArray+0x20>
mov    %r12,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <print_int_array@plt>

LLVM IR (-O0):
define void @fillArray(i32 %0, i8** %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %26, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i8**, i8*** %6
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
%22 = load i32*, i32** %7
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 %21, i32* %25
br label %26
26: ; preds = %14
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %10
29: ; preds = %10
%30 = load i32*, i32** %7
%31 = load i32, i32* %8
%32 = call i32 @print_int_array(i32* %30, i32 %31)
ret void
}

LLVM IR (-O2):
define void @fillArray(i32 %0, i8** nocapture %1, i32* %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %16
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %10, %8 ]
%10 = add nuw nsw i64 %9, 1
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i32, i32* %2, i64 %9
store i32 %13, i32* %14
%15 = icmp eq i64 %10, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %4
%17 = tail call i32 @print_int_array(i32* %2, i32 %3)
ret void
}