#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*/ repeat_char(char, int);
void center_char(char c, int width, int repeatings) {
  int spaces_left, spaces_right;
  if (repeatings < 1) {
    repeatings = 1;
  }
  if (width < repeatings) {
    width = 1;
  }
  spaces_left = (width - repeatings) / 2;
  repeat_char(' ', spaces_left);
  repeat_char(c, repeatings);
  spaces_right = width - repeatings - spaces_left;
  repeat_char(' ', spaces_right);
}


x86 assembly (clang, -O0):
<center_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1135 <center_char+0x25>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1148 <center_char+0x38>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    $0x20,%edi
call   1030 <repeat_char@plt>
mov    -0x1(%rbp),%al
mov    -0xc(%rbp),%esi
movsbl %al,%edi
call   1030 <repeat_char@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x20,%edi
call   1030 <repeat_char@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<center_char>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
test   %edx,%edx
mov    $0x1,%eax
cmovle %eax,%r15d
mov    %esi,%ebp
mov    %edi,%r14d
cmp    %esi,%r15d
cmovg  %eax,%ebp
sub    %r15d,%ebp
mov    %ebp,%ebx
shr    $0x1f,%ebx
add    %ebp,%ebx
sar    %ebx
mov    $0x20,%edi
mov    %ebx,%esi
call   1030 <repeat_char@plt>
mov    %r14d,%edi
mov    %r15d,%esi
call   1030 <repeat_char@plt>
sub    %ebx,%ebp
mov    $0x20,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <repeat_char@plt>

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

LLVM IR (-O2):
define void @center_char(i8 signext %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 1
%5 = select i1 %4, i32 %2, i32 1
%6 = icmp sgt i32 %5, %1
%7 = select i1 %6, i32 1, i32 %1
%8 = sub nsw i32 %7, %5
%9 = sdiv i32 %8, 2
%10 = tail call i32 @repeat_char(i8 signext 32, i32 %9)
%11 = tail call i32 @repeat_char(i8 signext %0, i32 %5)
%12 = sub nsw i32 %8, %9
%13 = tail call i32 @repeat_char(i8 signext 32, i32 %12)
ret void
}