#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 */
struct winsize {
  int ws_col;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
void display_sub_title(struct winsize *ws, char *title) {
  int x;
  int i;
  for (i = 0; i < ws->ws_col; i++) {
    printf("=");
  }
  printf("\n");
  x = (ws->ws_col - strlen(title)) / 2;
  for (i = 0; i < x; i++) {
    printf(" ");
  }
  printf("%s", title);
  for (i = x + strlen(title); i < ws->ws_col; i++) {
    printf(" ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<display_sub_title>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1162 <display_sub_title+0x42>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <display_sub_title+0x17>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c3 <display_sub_title+0xa3>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119b <display_sub_title+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1219 <display_sub_title+0xf9>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ee <display_sub_title+0xce>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_sub_title>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmpl   $0x0,(%rdi)
jle    1161 <display_sub_title+0x31>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    (%rbx),%ebp
jl     1150 <display_sub_title+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rbx),%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
mov    %ebp,%r15d
shr    $0x1f,%r15d
add    %ebp,%r15d
sar    %r15d
cmp    $0x2,%ebp
jl     119f <display_sub_title+0x6f>
mov    %r15d,%ebp
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1190 <display_sub_title+0x60>
lea    0xe5a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
add    %r15d,%ebp
cmp    (%rbx),%ebp
jge    11e1 <display_sub_title+0xb1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    (%rbx),%ebp
jl     11d0 <display_sub_title+0xa0>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
%struct.winsize = type { i32 }
@.str.3 = [3 x i8] c"%s\00"
define void @display_sub_title(%struct.winsize* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %2, %6
%7 = phi i32 [ %9, %6 ], [ 0, %2 ]
%8 = tail call i32 @putchar(i32 61)
%9 = add nuw nsw i32 %7, 1
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %6, label %12
12: ; preds = %6, %2
%13 = tail call i32 @putchar(i32 10)
%14 = load i32, i32* %3
%15 = tail call i32 @strlen(i8* %1)
%16 = sub nsw i32 %14, %15
%17 = sdiv i32 %16, 2
%18 = icmp sgt i32 %16, 1
br i1 %18, label %19, label %24
19: ; preds = %12, %19
%20 = phi i32 [ %22, %19 ], [ 0, %12 ]
%21 = tail call i32 @putchar(i32 32)
%22 = add nuw nsw i32 %20, 1
%23 = icmp eq i32 %22, %17
br i1 %23, label %24, label %19
24: ; preds = %19, %12
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%26 = tail call i32 @strlen(i8* %1)
%27 = add nsw i32 %26, %17
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %24, %30
%31 = phi i32 [ %33, %30 ], [ %27, %24 ]
%32 = tail call i32 @putchar(i32 32)
%33 = add nsw i32 %31, 1
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %30, label %36
36: ; preds = %30, %24
%37 = tail call i32 @putchar(i32 10)
ret void
}