#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 /*<<< orphan*/ assert(int);
void init_array(int *arr, int val) {
  for (int i = 0; i < 20; i++) {
    arr[i] = val;
  }
  arr[0] = val;
  assert(arr[2] == val);
  assert(arr[10] == val);
}


x86 assembly (clang, -O0):
<init_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    114c <init_array+0x3c>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <init_array+0x16>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
cmp    -0xc(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%eax
cmp    -0xc(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_array>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movd   %esi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqu %xmm0,0x10(%rdi)
movdqu %xmm0,0x20(%rdi)
movdqu %xmm0,0x30(%rdi)
movdqu %xmm0,0x40(%rdi)
movdqu %xmm0,(%rdi)
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
cmp    %ebp,0x28(%rbx)
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @init_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
br label %6
6: ; preds = %15, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %4
%11 = load i32*, i32** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32 %10, i32* %14
br label %15
15: ; preds = %9
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %6
18: ; preds = %6
%19 = load i32, i32* %4
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 0
store i32 %19, i32* %21
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = load i32, i32* %23
%25 = load i32, i32* %4
%26 = icmp eq i32 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32*, i32** %3
%30 = getelementptr inbounds i32, i32* %29, i64 10
%31 = load i32, i32* %30
%32 = load i32, i32* %4
%33 = icmp eq i32 %31, %32
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
ret void
}

LLVM IR (-O2):
define void @init_array(i32* nocapture %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 4
%4 = insertelement <4 x i32> poison, i32 %1, i64 0
%5 = shufflevector <4 x i32> %4, <4 x i32> poison, <4 x i32> zeroinitializer
%6 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %0, i64 8
%8 = getelementptr inbounds i32, i32* %0, i64 10
%9 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %0, i64 12
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %11
%12 = getelementptr inbounds i32, i32* %0, i64 16
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %13
%14 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %14
%15 = tail call i32 @assert(i32 1)
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, %1
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
ret void
}