#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*/ putchar(char);
int strlen(char *);
void prt_fill(char *str, char fillchar, int fieldlen) {
  int i = 0, slen;
  char *pc;
  pc = str;
  slen = strlen(str);
  while (i < fieldlen) {
    (i - slen) < 0 ? putchar(*pc) : putchar(fillchar);
    i++;
    pc++;
  }
}


x86 assembly (clang, -O0):
<prt_fill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119f <prt_fill+0x7f>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
cmp    $0x0,%eax
jge    117c <prt_fill+0x5c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    1185 <prt_fill+0x65>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1150 <prt_fill+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prt_fill>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %r15d,%r15d
jle    116f <prt_fill+0x4f>
mov    %eax,%r13d
mov    %r15d,%ebx
xor    %ebp,%ebp
jmp    1160 <prt_fill+0x40>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %ebp,%ebx
je     116f <prt_fill+0x4f>
mov    %r12d,%eax
cmp    %r13d,%ebp
jge    1150 <prt_fill+0x30>
movzbl (%r14,%rbp,1),%eax
jmp    1150 <prt_fill+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @prt_fill(i8* %0, i8 signext %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
store i8* %10, i8** %9
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %8
br label %13
13: ; preds = %29, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = sub nsw i32 %18, %19
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i8*, i8** %9
%24 = load i8, i8* %23
%25 = call i32 @putchar(i8 signext %24)
br label %29
26: ; preds = %17
%27 = load i8, i8* %5
%28 = call i32 @putchar(i8 signext %27)
br label %29
29: ; preds = %26, %22
%30 = phi i32 [ %25, %22 ], [ %28, %26 ]
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %9
br label %13
35: ; preds = %13
ret void
}

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