#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 */
typedef int /*<<< orphan*/ WINDOW;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int A_BOLD;
int COLOR_PAIR(int);
scalar_t__ EOF;
int /*<<< orphan*/ clear();
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getch();
int getmaxx(int /*<<< orphan*/ *);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *, ...);
int /*<<< orphan*/ refresh();
int strlen(char *);
int /*<<< orphan*/ wattrset(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void rprint_credits(WINDOW *win) {
  FILE *fr;
  if ((fr = fopen("credits.txt", "r")) == NULL) {
    mvwprintw(win, 3, 3, "error : cannot open file %s", "credits.txt");
    mvwprintw(win, 4, 3,
              "this file should be in directory with this executable");
    refresh();
    getch();
  } else {
    clear();
    int row_count = 1;
    int buff_size = 100;
    int win_len = getmaxx(win);
    int len;
    int col_offset;
    char buff[buff_size];
    wattrset(win, COLOR_PAIR(3) | A_BOLD);
    while (fgets(buff, buff_size, fr) != NULL) {
      len = strlen(buff);
      col_offset = (win_len - len) / 2;
      if (len > win_len) {
        mvwprintw(win, row_count, col_offset, "long line ...");
      } else {
        mvwprintw(win, row_count, col_offset, buff);
      }
      row_count++;
    }
    wrefresh(win);
    if (fclose(fr) == EOF) {
      mvwprintw(win, 3, 3, "error : cannot close file %s", "credits.txt");
      wrefresh(win);
    }
  }
}


x86 assembly (clang, -O0):
<rprint_credits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe2d(%rip),%rdi
lea    0xe32(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    123c <rprint_credits+0x7c>
mov    -0x8(%rbp),%rdi
mov    $0x3,%edx
lea    0xe11(%rip),%rcx
lea    0xdfc(%rip),%r8
mov    %edx,%esi
mov    $0x0,%al
call   10c0 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
mov    $0x3,%edx
lea    0xe08(%rip),%rcx
mov    $0x0,%al
call   10c0 <mvwprintw@plt>
mov    $0x0,%al
call   1090 <refresh@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
jmp    137e <rprint_credits+0x1be>
xor    %eax,%eax
call   10e0 <clear@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <getmaxx@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x3,%edi
call   1080 <COLOR_PAIR@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
mov    0x2d36(%rip),%rax
or     (%rax),%esi
call   1030 <wattrset@plt>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     132c <rprint_credits+0x16c>
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1309 <rprint_credits+0x149>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xd63(%rip),%rcx
mov    $0x0,%al
call   10c0 <mvwprintw@plt>
jmp    131e <rprint_credits+0x15e>
mov    -0x48(%rbp),%rcx
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   10c0 <mvwprintw@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a9 <rprint_credits+0xe9>
mov    -0x8(%rbp),%rdi
call   1060 <wrefresh@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2ca3(%rip),%rcx
cmp    (%rcx),%rax
jne    1377 <rprint_credits+0x1b7>
mov    -0x8(%rbp),%rdi
mov    $0x3,%edx
lea    0xd10(%rip),%rcx
lea    0xc9b(%rip),%r8
mov    %edx,%esi
mov    $0x0,%al
call   10c0 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
call   1060 <wrefresh@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rprint_credits>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe28(%rip),%rdi
lea    0xe2d(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12f4 <rprint_credits+0x134>
mov    %rax,%r15
xor    %eax,%eax
call   10e0 <clear@plt>
mov    %r14,%rdi
call   10a0 <getmaxx@plt>
mov    %eax,%r12d
mov    %rsp,-0x30(%rbp)
mov    %rsp,%r13
add    $0xffffffffffffff90,%r13
mov    %r13,%rsp
mov    $0x3,%edi
call   1080 <COLOR_PAIR@plt>
mov    0x2db7(%rip),%rcx
or     (%rcx),%eax
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <wattrset@plt>
mov    %r13,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     129b <rprint_credits+0xdb>
mov    $0x1,%ebx
jmp    1272 <rprint_credits+0xb2>
nopl   0x0(%rax)
mov    %r13,%rcx
xor    %eax,%eax
call   10c0 <mvwprintw@plt>
add    $0x1,%ebx
mov    %r13,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     129b <rprint_credits+0xdb>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %r12d,%ecx
sub    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
mov    %r14,%rdi
mov    %ebx,%esi
cmp    %eax,%r12d
jge    1250 <rprint_credits+0x90>
lea    0xdc7(%rip),%rcx
jmp    1253 <rprint_credits+0x93>
mov    %r14,%rdi
call   1060 <wrefresh@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x2d36(%rip),%rcx
cmp    (%rcx),%rax
jne    12e1 <rprint_credits+0x121>
lea    0xdb0(%rip),%rcx
lea    0xd3b(%rip),%r8
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   10c0 <mvwprintw@plt>
mov    %r14,%rdi
call   1060 <wrefresh@plt>
mov    -0x30(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd13(%rip),%rcx
lea    0xcfe(%rip),%r8
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   10c0 <mvwprintw@plt>
lea    0xd0d(%rip),%rcx
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   10c0 <mvwprintw@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <getch@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"credits.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"error : cannot open file %s\00"
@.str.3 = [54 x i8] c"this file should be in directory with this executable\00"
@A_BOLD = global i32 0
@.str.4 = [14 x i8] c"long line ...\00"
@EOF = global i64 0
@.str.5 = [29 x i8] c"error : cannot close file %s\00"
define void @rprint_credits(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
store i32* %0, i32** %2
%11 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %20
13: ; preds = %1
%14 = load i32*, i32** %2
%15 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %14, i32 3, i32 3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%16 = load i32*, i32** %2
%17 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %16, i32 4, i32 3, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (...) @refresh()
%19 = call i32 (...) @getch()
br label %74
20: ; preds = %1
%21 = call i32 (...) @clear()
store i32 1, i32* %4
store i32 100, i32* %5
%22 = load i32*, i32** %2
%23 = call i32 @getmaxx(i32* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %5
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %9
%27 = alloca i8, i64 %25
store i64 %25, i64* %10
%28 = load i32*, i32** %2
%29 = call i32 @COLOR_PAIR(i32 3)
%30 = load i32, i32* @A_BOLD
%31 = or i32 %29, %30
%32 = call i32 @wattrset(i32* %28, i32 %31)
br label %33
33: ; preds = %57, %20
%34 = load i32, i32* %5
%35 = load i32*, i32** %3
%36 = call i32* @fgets(i8* %27, i32 %34, i32* %35)
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %60
38: ; preds = %33
%39 = call i32 @strlen(i8* %27)
store i32 %39, i32* %7
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = sub nsw i32 %40, %41
%43 = sdiv i32 %42, 2
store i32 %43, i32* %8
%44 = load i32, i32* %7
%45 = load i32, i32* %6
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %52
47: ; preds = %38
%48 = load i32*, i32** %2
%49 = load i32, i32* %4
%50 = load i32, i32* %8
%51 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %48, i32 %49, i32 %50, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %57
52: ; preds = %38
%53 = load i32*, i32** %2
%54 = load i32, i32* %4
%55 = load i32, i32* %8
%56 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %53, i32 %54, i32 %55, i8* %27)
br label %57
57: ; preds = %52, %47
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %33
60: ; preds = %33
%61 = load i32*, i32** %2
%62 = call i32 @wrefresh(i32* %61)
%63 = load i32*, i32** %3
%64 = call i64 @fclose(i32* %63)
%65 = load i64, i64* @EOF
%66 = icmp eq i64 %64, %65
br i1 %66, label %67, label %72
67: ; preds = %60
%68 = load i32*, i32** %2
%69 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %68, i32 3, i32 3, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%70 = load i32*, i32** %2
%71 = call i32 @wrefresh(i32* %70)
br label %72
72: ; preds = %67, %60
%73 = load i8*, i8** %9
br label %74
74: ; preds = %72, %13
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"credits.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"error : cannot open file %s\00"
@.str.3 = [54 x i8] c"this file should be in directory with this executable\00"
@A_BOLD = global i32 0
@.str.4 = [14 x i8] c"long line ...\00"
@EOF = global i64 0
@.str.5 = [29 x i8] c"error : cannot close file %s\00"
define void @rprint_credits(i32* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %0, i32 3, i32 3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %0, i32 4, i32 3, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 (...) @refresh()
%8 = tail call i32 (...) @getch()
br label %44
9: ; preds = %1
%10 = tail call i32 (...) @clear()
%11 = tail call i32 @getmaxx(i32* %0)
%12 = tail call i8* @llvm.stacksave()
%13 = alloca [100 x i8]
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%15 = tail call i32 @COLOR_PAIR(i32 3)
%16 = load i32, i32* @A_BOLD
%17 = or i32 %16, %15
%18 = tail call i32 @wattrset(i32* %0, i32 %17)
%19 = call i32* @fgets(i8* %14, i32 100, i32* %2)
%20 = icmp eq i32* %19, null
br i1 %20, label %35, label %21
21: ; preds = %9, %31
%22 = phi i32 [ %32, %31 ], [ 1, %9 ]
%23 = call i32 @strlen(i8* %14)
%24 = sub nsw i32 %11, %23
%25 = sdiv i32 %24, 2
%26 = icmp slt i32 %11, %23
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %0, i32 %22, i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %31
29: ; preds = %21
%30 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %0, i32 %22, i32 %25, i8* %14)
br label %31
31: ; preds = %29, %27
%32 = add nuw nsw i32 %22, 1
%33 = call i32* @fgets(i8* %14, i32 100, i32* %2)
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %21
35: ; preds = %31, %9
%36 = call i32 @wrefresh(i32* %0)
%37 = call i64 @fclose(i32* %2)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = call i32 (i32*, i32, i32, i8*, ...) @mvwprintw(i32* %0, i32 3, i32 3, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @wrefresh(i32* %0)
br label %43
43: ; preds = %40, %35
br label %44
44: ; preds = %43, %4
ret void
}