#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*/ go_to_xy(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse(int);
int /*<<< orphan*/ spacer(int, int);
int util_strlen(char *);
void gfx_window(int x1, int y1, int x2, int y2, char *title, int draw) {
  int w = x2 - x1;
  int h = y2 - y1;
  int padding = w - util_strlen(title) - 8;
  int i;
  if (draw) {
    if (padding < 0) {
      title[util_strlen(title) + padding] = '\0';
    }
    reverse(0);
    go_to_xy(x1, y1);
    printf("%c", 201);
    spacer(padding / 2, 205);
    printf("%c", 185);
    reverse(1);
    printf("  %s  ", title);
    reverse(0);
    printf("%c", 204);
    spacer((padding + 1) / 2, 205);
    printf("%c", 187);
    for (i = 1; i < h - 1; i++) {
      go_to_xy(x1, y1 + i);
      printf("%c", 186);
      go_to_xy(x2 - 1, y1 + i);
      printf("%c", 186);
    }
    go_to_xy(x1, y2 - 1);
    printf("%c", 200);
    spacer(w - 2, 205);
    printf("%c", 188);
  } else {
    for (i = 0; i < h; ++i) {
      go_to_xy(x1, y1 + i);
      spacer(w, 32);
    }
  }
}


x86 assembly (clang, -O0):
<gfx_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <util_strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
sub    $0x8,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1335 <gfx_window+0x1e5>
cmpl   $0x0,-0x28(%rbp)
jge    11cf <gfx_window+0x7f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <util_strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %edi,%edi
call   1030 <reverse@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <go_to_xy@plt>
lea    0xe18(%rip),%rdi
mov    $0xc9,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0xcd,%esi
call   1070 <spacer@plt>
lea    0xdee(%rip),%rdi
mov    $0xb9,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1030 <reverse@plt>
mov    -0x18(%rbp),%rsi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <reverse@plt>
lea    0xdb8(%rip),%rdi
mov    $0xcc,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0xcd,%esi
call   1070 <spacer@plt>
lea    0xd8b(%rip),%rdi
mov    $0xbb,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12ec <gfx_window+0x19c>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x2c(%rbp),%esi
call   1060 <go_to_xy@plt>
lea    0xd52(%rip),%rdi
mov    $0xba,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
add    -0x2c(%rbp),%esi
call   1060 <go_to_xy@plt>
lea    0xd2e(%rip),%rdi
mov    $0xba,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1288 <gfx_window+0x138>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
call   1060 <go_to_xy@plt>
lea    0xcff(%rip),%rdi
mov    $0xc8,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%edi
sub    $0x2,%edi
mov    $0xcd,%esi
call   1070 <spacer@plt>
lea    0xcdc(%rip),%rdi
mov    $0xbc,%esi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1376 <gfx_window+0x226>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1371 <gfx_window+0x221>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x2c(%rbp),%esi
call   1060 <go_to_xy@plt>
mov    -0x20(%rbp),%edi
mov    $0x20,%esi
call   1070 <spacer@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    133c <gfx_window+0x1ec>
jmp    1376 <gfx_window+0x226>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfx_window>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%ebx
mov    %edi,%r13d
mov    %edx,%r15d
sub    %edi,%r15d
mov    %ecx,0x8(%rsp)
sub    %esi,%r14d
mov    %r8,0x10(%rsp)
mov    %r8,%rdi
call   1050 <util_strlen@plt>
test   %ebp,%ebp
je     12fc <gfx_window+0x19c>
mov    %r14d,0xc(%rsp)
mov    %r15d,%r14d
sub    %eax,%r14d
lea    -0x8(%r14),%ebp
cmp    $0x7,%r14d
jg     11d3 <gfx_window+0x73>
mov    %ebp,0x4(%rsp)
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <util_strlen@plt>
add    0x4(%rsp),%eax
cltq
movb   $0x0,0x0(%rbp,%rax,1)
mov    0x4(%rsp),%ebp
xor    %edi,%edi
call   1030 <reverse@plt>
mov    %r13d,%edi
mov    %ebx,%esi
call   1070 <go_to_xy@plt>
mov    $0xc9,%edi
call   1040 <putchar@plt>
mov    %ebp,%edi
shr    $0x1f,%edi
add    %ebp,%edi
sar    %edi
mov    $0xcd,%esi
call   1080 <spacer@plt>
mov    $0xb9,%edi
call   1040 <putchar@plt>
mov    $0x1,%edi
call   1030 <reverse@plt>
lea    0xde4(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1030 <reverse@plt>
mov    $0xcc,%edi
call   1040 <putchar@plt>
mov    %r14d,%eax
add    $0xfffffff9,%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%edi
add    $0xfffffff9,%edi
sar    %edi
mov    $0xcd,%esi
call   1080 <spacer@plt>
mov    $0xbb,%edi
call   1040 <putchar@plt>
cmpl   $0x3,0xc(%rsp)
mov    0x8(%rsp),%r14d
jl     12ba <gfx_window+0x15a>
add    $0xffffffff,%r12d
mov    $0x2,%ebp
sub    %r14d,%ebp
add    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %ebx,%esi
call   1070 <go_to_xy@plt>
mov    $0xba,%edi
call   1040 <putchar@plt>
mov    %r12d,%edi
mov    %ebx,%esi
call   1070 <go_to_xy@plt>
mov    $0xba,%edi
call   1040 <putchar@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1280 <gfx_window+0x120>
add    $0xffffffff,%r14d
mov    %r13d,%edi
mov    %r14d,%esi
call   1070 <go_to_xy@plt>
mov    $0xc8,%edi
call   1040 <putchar@plt>
add    $0xfffffffe,%r15d
mov    %r15d,%edi
mov    $0xcd,%esi
call   1080 <spacer@plt>
mov    $0xbc,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <putchar@plt>
test   %r14d,%r14d
mov    0x8(%rsp),%ebp
jle    132e <gfx_window+0x1ce>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13d,%edi
mov    %ebx,%esi
call   1070 <go_to_xy@plt>
mov    %r15d,%edi
mov    $0x20,%esi
call   1080 <spacer@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1310 <gfx_window+0x1b0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [7 x i8] c" %s \00"
define void @gfx_window(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
store i32 %19, i32* %13
%20 = load i32, i32* %10
%21 = load i32, i32* %8
%22 = sub nsw i32 %20, %21
store i32 %22, i32* %14
%23 = load i32, i32* %13
%24 = load i8*, i8** %11
%25 = call i32 @util_strlen(i8* %24)
%26 = sub nsw i32 %23, %25
%27 = sub nsw i32 %26, 8
store i32 %27, i32* %15
%28 = load i32, i32* %12
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %93
30: ; preds = %6
%31 = load i32, i32* %15
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i8*, i8** %11
%35 = load i8*, i8** %11
%36 = call i32 @util_strlen(i8* %35)
%37 = load i32, i32* %15
%38 = add nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %34, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %33, %30
%42 = call i32 @reverse(i32 0)
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = call i32 @go_to_xy(i32 %43, i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 201)
%47 = load i32, i32* %15
%48 = sdiv i32 %47, 2
%49 = call i32 @spacer(i32 %48, i32 205)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 185)
%51 = call i32 @reverse(i32 1)
%52 = load i8*, i8** %11
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = call i32 @reverse(i32 0)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 204)
%56 = load i32, i32* %15
%57 = add nsw i32 %56, 1
%58 = sdiv i32 %57, 2
%59 = call i32 @spacer(i32 %58, i32 205)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 187)
store i32 1, i32* %16
br label %61
61: ; preds = %80, %41
%62 = load i32, i32* %16
%63 = load i32, i32* %14
%64 = sub nsw i32 %63, 1
%65 = icmp slt i32 %62, %64
br i1 %65, label %66, label %83
66: ; preds = %61
%67 = load i32, i32* %7
%68 = load i32, i32* %8
%69 = load i32, i32* %16
%70 = add nsw i32 %68, %69
%71 = call i32 @go_to_xy(i32 %67, i32 %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 186)
%73 = load i32, i32* %9
%74 = sub nsw i32 %73, 1
%75 = load i32, i32* %8
%76 = load i32, i32* %16
%77 = add nsw i32 %75, %76
%78 = call i32 @go_to_xy(i32 %74, i32 %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 186)
br label %80
80: ; preds = %66
%81 = load i32, i32* %16
%82 = add nsw i32 %81, 1
store i32 %82, i32* %16
br label %61
83: ; preds = %61
%84 = load i32, i32* %7
%85 = load i32, i32* %10
%86 = sub nsw i32 %85, 1
%87 = call i32 @go_to_xy(i32 %84, i32 %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 200)
%89 = load i32, i32* %13
%90 = sub nsw i32 %89, 2
%91 = call i32 @spacer(i32 %90, i32 205)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 188)
br label %110
93: ; preds = %6
store i32 0, i32* %16
br label %94
94: ; preds = %106, %93
%95 = load i32, i32* %16
%96 = load i32, i32* %14
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %109
98: ; preds = %94
%99 = load i32, i32* %7
%100 = load i32, i32* %8
%101 = load i32, i32* %16
%102 = add nsw i32 %100, %101
%103 = call i32 @go_to_xy(i32 %99, i32 %102)
%104 = load i32, i32* %13
%105 = call i32 @spacer(i32 %104, i32 32)
br label %106
106: ; preds = %98
%107 = load i32, i32* %16
%108 = add nsw i32 %107, 1
store i32 %108, i32* %16
br label %94
109: ; preds = %94
br label %110
110: ; preds = %109, %83
ret void
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c" %s \00"
define void @gfx_window(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = sub nsw i32 %2, %0
%8 = sub i32 %3, %1
%9 = tail call i32 @util_strlen(i8* %4)
%10 = sub nsw i32 %7, %9
%11 = add nsw i32 %10, -8
%12 = icmp eq i32 %5, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = icmp sgt i32 %8, 0
br i1 %14, label %57, label %64
15: ; preds = %6
%16 = icmp slt i32 %10, 8
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = tail call i32 @util_strlen(i8* %4)
%19 = add nsw i32 %18, %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %4, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %17, %15
%23 = tail call i32 @reverse(i32 0)
%24 = tail call i32 @go_to_xy(i32 %0, i32 %1)
%25 = tail call i32 @putchar(i32 201)
%26 = sdiv i32 %11, 2
%27 = tail call i32 @spacer(i32 %26, i32 205)
%28 = tail call i32 @putchar(i32 185)
%29 = tail call i32 @reverse(i32 1)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%31 = tail call i32 @reverse(i32 0)
%32 = tail call i32 @putchar(i32 204)
%33 = add nsw i32 %10, -7
%34 = sdiv i32 %33, 2
%35 = tail call i32 @spacer(i32 %34, i32 205)
%36 = tail call i32 @putchar(i32 187)
%37 = icmp sgt i32 %8, 2
br i1 %37, label %38, label %50
38: ; preds = %22
%39 = add nsw i32 %8, -1
%40 = add nsw i32 %2, -1
br label %41
41: ; preds = %38, %41
%42 = phi i32 [ 1, %38 ], [ %48, %41 ]
%43 = add nsw i32 %42, %1
%44 = tail call i32 @go_to_xy(i32 %0, i32 %43)
%45 = tail call i32 @putchar(i32 186)
%46 = tail call i32 @go_to_xy(i32 %40, i32 %43)
%47 = tail call i32 @putchar(i32 186)
%48 = add nuw nsw i32 %42, 1
%49 = icmp eq i32 %48, %39
br i1 %49, label %50, label %41
50: ; preds = %41, %22
%51 = add nsw i32 %3, -1
%52 = tail call i32 @go_to_xy(i32 %0, i32 %51)
%53 = tail call i32 @putchar(i32 200)
%54 = add nsw i32 %7, -2
%55 = tail call i32 @spacer(i32 %54, i32 205)
%56 = tail call i32 @putchar(i32 188)
br label %64
57: ; preds = %13, %57
%58 = phi i32 [ %62, %57 ], [ 0, %13 ]
%59 = add nsw i32 %58, %1
%60 = tail call i32 @go_to_xy(i32 %0, i32 %59)
%61 = tail call i32 @spacer(i32 %7, i32 32)
%62 = add nuw nsw i32 %58, 1
%63 = icmp eq i32 %62, %8
br i1 %63, label %64, label %57
64: ; preds = %57, %13, %50
ret void
}