#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 *, ...);
int strlen(char const *);
void txt_ctrd(const char *str, char endline) {
  int txt_len = strlen(str);
  int padding = (80 - txt_len) / 2;
  for (int i = padding; i > 0; --i) {
    printf(" ");
  }
  printf("%s%c", str, endline);
}


x86 assembly (clang, -O0):
<txt_ctrd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    $0x50,%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    117d <txt_ctrd+0x5d>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <txt_ctrd+0x37>
mov    -0x8(%rbp),%rsi
movsbl -0x9(%rbp),%edx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<txt_ctrd>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x4e,%eax
jg     1162 <txt_ctrd+0x32>
mov    $0x50,%ebp
sub    %eax,%ebp
shr    %ebp
add    $0x1,%ebp
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1150 <txt_ctrd+0x20>
movsbl %r14b,%edx
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"%s%c\00"
define void @txt_ctrd(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = sub nsw i32 80, %10
%12 = sdiv i32 %11, 2
store i32 %12, i32* %6
%13 = load i32, i32* %6
store i32 %13, i32* %7
br label %14
14: ; preds = %19, %2
%15 = load i32, i32* %7
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17
%20 = load i32, i32* %7
%21 = add nsw i32 %20, -1
store i32 %21, i32* %7
br label %14
22: ; preds = %14
%23 = load i8*, i8** %3
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %25)
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%s%c\00"
define void @txt_ctrd(i8* %0, i8 signext %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, 79
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = sub nsw i32 80, %3
%7 = lshr i32 %6, 1
br label %11
8: ; preds = %11, %2
%9 = sext i8 %1 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %9)
ret void
11: ; preds = %5, %11
%12 = phi i32 [ %14, %11 ], [ %7, %5 ]
%13 = tail call i32 @putchar(i32 32)
%14 = add nsw i32 %12, -1
%15 = icmp ugt i32 %12, 1
br i1 %15, label %11, label %8
}