#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 */
void fill(char *arr, size_t length, char c) {
  for (size_t i = 0; i < length; ++i) {
    arr[i] = c;
    if (i % 100 == 0) {
      arr[i] = '\n';
    }
  }
  arr[length - 1] = 0;
}


x86 assembly (clang, -O0):
<fill>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    116f <fill+0x6f>
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    1159 <fill+0x59>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
jmp    115e <fill+0x5e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1119 <fill+0x19>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill>:
test   %rsi,%rsi
je     119c <fill+0x9c>
movzbl %dl,%r8d
cmp    $0x1,%rsi
jne    1117 <fill+0x17>
xor    %ecx,%ecx
jmp    116a <fill+0x6a>
mov    %rsi,%r9
and    $0xfffffffffffffffe,%r9
xor    %ecx,%ecx
movabs $0x28f5c28f5c28f5c3,%r10
c2 f5 28
mov    $0xa,%r11d
mov    %rcx,%rax
shr    $0x2,%rax
mul    %r10
shr    $0x2,%rdx
imul   $0x64,%rdx,%rax
cmp    %rcx,%rax
mov    %r8d,%edx
cmove  %r11d,%edx
add    $0xffffffffffffffff,%rax
cmp    %rcx,%rax
mov    %r8d,%eax
cmove  %r11d,%eax
mov    %dl,(%rdi,%rcx,1)
mov    %al,0x1(%rdi,%rcx,1)
add    $0x2,%rcx
cmp    %rcx,%r9
jne    1130 <fill+0x30>
test   $0x1,%sil
je     119c <fill+0x9c>
movabs $0x8f5c28f5c28f5c29,%rax
28 5c 8f
imul   %rcx,%rax
ror    $0x2,%rax
movabs $0x28f5c28f5c28f5d,%rdx
5c 8f 02
cmp    %rdx,%rax
mov    $0xa,%eax
cmovb  %eax,%r8d
mov    %r8b,(%rdi,%rcx,1)
movb   $0x0,-0x1(%rsi,%rdi,1)
ret

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

LLVM IR (-O2):
define void @fill(i8* nocapture writeonly %0, i64 %1, i8 signext %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = and i64 %1, 1
%7 = icmp eq i64 %1, 1
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = and i64 %1, -2
br label %21
10: ; preds = %21, %5
%11 = phi i64 [ 0, %5 ], [ %33, %21 ]
%12 = icmp eq i64 %6, 0
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %0, i64 %11
%15 = urem i64 %11, 100
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8 10, i8 %2
store i8 %17, i8* %14
br label %18
18: ; preds = %13, %10, %3
%19 = add i64 %1, -1
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
ret void
21: ; preds = %21, %8
%22 = phi i64 [ 0, %8 ], [ %33, %21 ]
%23 = phi i64 [ 0, %8 ], [ %34, %21 ]
%24 = getelementptr inbounds i8, i8* %0, i64 %22
%25 = urem i64 %22, 100
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8 10, i8 %2
store i8 %27, i8* %24
%28 = or i64 %22, 1
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = urem i64 %28, 100
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i8 10, i8 %2
store i8 %32, i8* %29
%33 = add nuw i64 %22, 2
%34 = add i64 %23, 2
%35 = icmp eq i64 %34, %9
br i1 %35, label %10, label %21
}