#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*/ printf(char *, char);
void printpaddedline(char *ch, int totallength, int noofchars,
                     char *paddedchar) {
  int i = 1;
  int j = 1;
  int prefuntilindex = totallength / 2 - (noofchars - 1);
  int sufafterindex = totallength / 2 + noofchars + 1;
  for (j = 1; j <= totallength; j++) {
    if ((j <= prefuntilindex) || (j >= sufafterindex))
      printf("%c", *paddedchar);
    else
      printf("%c", *ch);
  }
}


x86 assembly (clang, -O0):
<printpaddedline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11c7 <printpaddedline+0xb7>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    1189 <printpaddedline+0x79>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     11a1 <printpaddedline+0x91>
mov    -0x18(%rbp),%rax
lea    0xe6c(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
jmp    11b4 <printpaddedline+0xa4>
mov    -0x8(%rbp),%rax
lea    0xe54(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
jmp    11b9 <printpaddedline+0xa9>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1165 <printpaddedline+0x55>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printpaddedline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1185 <printpaddedline+0x75>
mov    %rcx,%rbx
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%ebp
shr    $0x1f,%ebp
add    %esi,%ebp
sar    %ebp
mov    %ebp,%r13d
sub    %edx,%r13d
add    $0x1,%r13d
add    %edx,%ebp
neg    %r14d
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
cmp    %ebp,%r12d
mov    %r15,%rax
cmovg  %rbx,%rax
cmp    %r13d,%r12d
cmovle %rbx,%rax
movsbl (%rax),%esi
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
lea    (%r14,%r12,1),%eax
add    $0x1,%eax
mov    %r12d,%ecx
add    $0x1,%ecx
mov    %ecx,%r12d
cmp    $0x1,%eax
jne    1150 <printpaddedline+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @printpaddedline(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 1, i32* %9
store i32 1, i32* %10
%13 = load i32, i32* %6
%14 = sdiv i32 %13, 2
%15 = load i32, i32* %7
%16 = sub nsw i32 %15, 1
%17 = sub nsw i32 %14, %16
store i32 %17, i32* %11
%18 = load i32, i32* %6
%19 = sdiv i32 %18, 2
%20 = load i32, i32* %7
%21 = add nsw i32 %19, %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %12
store i32 1, i32* %10
br label %23
23: ; preds = %44, %4
%24 = load i32, i32* %10
%25 = load i32, i32* %6
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %47
27: ; preds = %23
%28 = load i32, i32* %10
%29 = load i32, i32* %11
%30 = icmp sle i32 %28, %29
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i32, i32* %10
%33 = load i32, i32* %12
%34 = icmp sge i32 %32, %33
br i1 %34, label %35, label %39
35: ; preds = %31, %27
%36 = load i8*, i8** %8
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %37)
br label %43
39: ; preds = %31
%40 = load i8*, i8** %5
%41 = load i8, i8* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %41)
br label %43
43: ; preds = %39, %35
br label %44
44: ; preds = %43
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
store i32 %46, i32* %10
br label %23
47: ; preds = %23
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @printpaddedline(i8* nocapture %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = sdiv i32 %1, 2
%6 = sub i32 1, %2
%7 = add i32 %6, %5
%8 = add nsw i32 %5, %2
%9 = icmp slt i32 %1, 1
br i1 %9, label %20, label %10
10: ; preds = %4, %10
%11 = phi i32 [ %18, %10 ], [ 1, %4 ]
%12 = icmp sle i32 %11, %7
%13 = icmp sgt i32 %11, %8
%14 = select i1 %12, i1 true, i1 %13
%15 = select i1 %14, i8* %3, i8* %0
%16 = load i8, i8* %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %16)
%18 = add nuw i32 %11, 1
%19 = icmp eq i32 %11, %1
br i1 %19, label %20, label %10
20: ; preds = %10, %4
ret void
}