char *timlib_character_pad(char delimiter, int column_count) {
  static char buffer[1024];
  char *ptr = buffer;
  if (column_count >= 1024)
    return "";
  while (column_count--)
    *ptr++ = delimiter;
  *ptr = '\0';
  return buffer;
}


x86 assembly (clang, -O0):
<timlib_character_pad>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    %esi,-0x10(%rbp)
lea    0x2f1c(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x400,-0x10(%rbp)
jl     1135 <timlib_character_pad+0x35>
lea    0xed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1179 <timlib_character_pad+0x79>
jmp    113a <timlib_character_pad+0x3a>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     1167 <timlib_character_pad+0x67>
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    113a <timlib_character_pad+0x3a>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ebb(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<timlib_character_pad>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3ff,%esi
jle    1126 <timlib_character_pad+0x16>
lea    0xedc(%rip),%r14
jmp    1159 <timlib_character_pad+0x49>
mov    %esi,%ebx
lea    0x2f11(%rip),%r14
mov    %r14,%rax
test   %esi,%esi
je     1156 <timlib_character_pad+0x46>
mov    %ebx,%edx
movzbl %dil,%esi
lea    0x2efd(%rip),%r15
mov    %r15,%rdi
call   1030 <memset@plt>
add    $0xffffffff,%ebx
lea    (%rbx,%r15,1),%rax
add    $0x1,%rax
movb   $0x0,(%rax)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@timlib_character_pad.buffer = internal global [1024 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @timlib_character_pad(i8 signext %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8*
store i8 %0, i8* %4
store i32 %1, i32* %5
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @timlib_character_pad.buffer, i64 0, i64 0), i8** %6
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 1024
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %21
10: ; preds = %2
br label %11
11: ; preds = %15, %10
%12 = load i32, i32* %5
%13 = add nsw i32 %12, -1
store i32 %13, i32* %5
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8, i8* %4
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %6
store i8 %16, i8* %17
br label %11
19: ; preds = %11
%20 = load i8*, i8** %6
store i8 0, i8* %20
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @timlib_character_pad.buffer, i64 0, i64 0), i8** %3
br label %21
21: ; preds = %19, %9
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@timlib_character_pad.buffer = internal global [1024 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @timlib_character_pad(i8 signext %0, i32 %1) {
%3 = icmp sgt i32 %1, 1023
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 0
br i1 %5, label %12, label %6
6: ; preds = %4
%7 = zext i32 %1 to i64
%8 = add i32 %1, -1
%9 = zext i32 %8 to i64
%10 = add nuw nsw i64 %9, 1
%11 = getelementptr [1024 x i8], [1024 x i8]* @timlib_character_pad.buffer, i64 0, i64 %10
br label %12
12: ; preds = %6, %4
%13 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @timlib_character_pad.buffer, i64 0, i64 0), %4 ], [ %11, %6 ]
store i8 0, i8* %13
br label %14
14: ; preds = %2, %12
%15 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @timlib_character_pad.buffer, i64 0, i64 0), %12 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %15
}