#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 strlen(char *);
char *center(char *string, int screen_len) {
  static char line[512];
  int x;
  int str_len_div_two = strlen(string) / 2;
  int scr_len_div_two = screen_len / 2;
  for (x = 0; x < scr_len_div_two - str_len_div_two; x++)
    line[x] = ' ';
  line[x] = '\0';
  strcat(line, string);
  return line;
}


x86 assembly (clang, -O0):
<center>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    1186 <center+0x66>
movslq -0x10(%rbp),%rcx
lea    0x2ecc(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <center+0x38>
movslq -0x10(%rbp),%rcx
lea    0x2eaf(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rsi
lea    0x2ea0(%rip),%rdi
call   1040 <strcat@plt>
lea    0x2e94(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<center>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ebp,%ebx
shr    $0x1f,%ebx
add    %ebp,%ebx
sar    %ebx
sub    %ecx,%ebx
test   %ebx,%ebx
jle    1173 <center+0x43>
add    $0xffffffff,%ebx
add    $0x1,%rbx
lea    0x2eec(%rip),%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1040 <memset@plt>
jmp    1175 <center+0x45>
xor    %ebx,%ebx
lea    0x2ed4(%rip),%rbp
movb   $0x0,(%rbx,%rbp,1)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@center.line = internal global [512 x i8] zeroinitializer
define i8* @center(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = sdiv i32 %9, 2
store i32 %10, i32* %6
%11 = load i32, i32* %4
%12 = sdiv i32 %11, 2
store i32 %12, i32* %7
store i32 0, i32* %5
br label %13
13: ; preds = %23, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = sub nsw i32 %15, %16
%18 = icmp slt i32 %14, %17
br i1 %18, label %19, label %26
19: ; preds = %13
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [512 x i8], [512 x i8]* @center.line, i64 0, i64 %21
store i8 32, i8* %22
br label %23
23: ; preds = %19
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %13
26: ; preds = %13
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [512 x i8], [512 x i8]* @center.line, i64 0, i64 %28
store i8 0, i8* %29
%30 = load i8*, i8** %3
%31 = call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @center.line, i64 0, i64 0), i8* %30)
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @center.line, i64 0, i64 0)
}

LLVM IR (-O2):
@center.line = internal global [512 x i8] zeroinitializer
define i8* @center(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = sdiv i32 %3, -2
%5 = sdiv i32 %1, 2
%6 = add nsw i32 %4, %5
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = add nsw i32 %6, -1
%10 = zext i32 %9 to i64
%11 = add nuw nsw i64 %10, 1
br label %12
12: ; preds = %8, %2
%13 = phi i64 [ 0, %2 ], [ %11, %8 ]
%14 = getelementptr inbounds [512 x i8], [512 x i8]* @center.line, i64 0, i64 %13
store i8 0, i8* %14
%15 = tail call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @center.line, i64 0, i64 0), i8* %0)
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @center.line, i64 0, i64 0)
}