#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 */
char *int_to_string(int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ readStr();
int str_to_int(int /*<<< orphan*/);
void fill_array(int arr[], int n) {
  int i = 0;
  for (i = 0; i < n; i++) {
    print("ARR[");
    print(int_to_string(i));
    print("]: ");
    arr[i] = str_to_int(readStr());
    print("\n");
  }
}


x86 assembly (clang, -O0):
<fill_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c6 <fill_array+0x86>
lea    0xe90(%rip),%rdi
call   1040 <print@plt>
mov    -0x10(%rbp),%edi
call   1060 <int_to_string@plt>
mov    %rax,%rdi
call   1040 <print@plt>
lea    0xe79(%rip),%rdi
call   1040 <print@plt>
mov    $0x0,%al
call   1050 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    0xe56(%rip),%rdi
call   1040 <print@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <fill_array+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11b3 <fill_array+0x73>
mov    %rdi,%r13
mov    %esi,%ebp
lea    0xea5(%rip),%r14
lea    0xea3(%rip),%r15
lea    0xea0(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <print@plt>
mov    %ebx,%edi
call   1060 <int_to_string@plt>
mov    %rax,%rdi
call   1040 <print@plt>
mov    %r15,%rdi
call   1040 <print@plt>
xor    %eax,%eax
call   1050 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,0x0(%r13,%rbx,4)
mov    %r12,%rdi
call   1040 <print@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <fill_array+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"ARR[\00"
@.str.1 = [4 x i8] c"]: \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @fill_array(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %6
6: ; preds = %23, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = call i32 @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %5
%13 = call i8* @int_to_string(i32 %12)
%14 = call i32 @print(i8* %13)
%15 = call i32 @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (...) @readStr()
%17 = call i32 @str_to_int(i32 %16)
%18 = load i32*, i32** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
%22 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %10
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %6
26: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"ARR[\00"
@.str.1 = [4 x i8] c"]: \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @fill_array(i32* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %17, %6 ]
%8 = tail call i32 @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = trunc i64 %7 to i32
%10 = tail call i8* @int_to_string(i32 %9)
%11 = tail call i32 @print(i8* %10)
%12 = tail call i32 @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 (...) @readStr()
%14 = tail call i32 @str_to_int(i32 %13)
%15 = getelementptr inbounds i32, i32* %0, i64 %7
store i32 %14, i32* %15
%16 = tail call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = add nuw nsw i64 %7, 1
%18 = icmp eq i64 %17, %5
br i1 %18, label %19, label %6
19: ; preds = %6, %2
ret void
}