#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void CenterText(char text[], int width) {
  char tmp[256] = "";
  int i;
  if (strlen(text) <= width) {
    for (i = 0; i < (width - strlen(text)) / 2; i++)
      strcat(tmp, " ");
    strcat(tmp, text);
    strcpy(text, tmp);
  }
}


x86 assembly (clang, -O0):
<CenterText>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0xc(%rbp),%eax
jg     1208 <CenterText+0xc8>
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x11c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x11c(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x118(%rbp),%eax
cmp    %ecx,%eax
jge    11e8 <CenterText+0xa8>
lea    -0x110(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1181 <CenterText+0x41>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CenterText>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %esi,%r12d
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
call   1040 <strlen@plt>
cmp    %r12d,%eax
jg     1221 <CenterText+0xf1>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12d,%ecx
sub    %eax,%ecx
cmp    $0x2,%ecx
jl     1208 <CenterText+0xd8>
xor    %ebp,%ebp
lea    0xe2c(%rip),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12d,%ecx
sub    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
cmp    %eax,%ebp
jl     11e0 <CenterText+0xb0>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @CenterText(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = bitcast [256 x i8]* %5 to i8*
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = load i32, i32* %4
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %34
12: ; preds = %2
store i32 0, i32* %6
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %15, %17
%19 = sdiv i32 %18, 2
%20 = icmp slt i32 %14, %19
br i1 %20, label %21, label %27
21: ; preds = %13
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %13
27: ; preds = %13
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%29 = load i8*, i8** %3
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = load i8*, i8** %3
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%33 = call i32 @strcpy(i8* %31, i8* %32)
br label %34
34: ; preds = %27, %2
ret void
}

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