#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/ *);
void print_week_header(FILE *f) {
  const char *week_header =
      "/TM 560 def     % top margin\n"
      "/BM  30 def     % bottom margin\n"
      "/LM  30 def     % left margin\n"
      "/RM 810 def     % right margin\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "\n"
      "/itemfont       /Helvetica-ISOLatin1    def\n"
      "/datefont       /Helvetica-Bold         def\n"
      "/FirstHour       9 def  % Default beginning and end of the plan\n"
      "/LastHour       22 def\n"
      "\n"
      "/usefont {findfont fontsize scalefont setfont} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Rotate page round so it is printed A4 landscape\n"
      "\n"
      "/A4landscape {\n"
      "        initgraphics\n"
      "        A4Y ScaleY mul 0 translate\n"
      "        90 rotate\n"
      "        ScaleX ScaleY Min dup scale\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "%       'concat' - routine to concatenate two strings from the\n"
      "%        stack, leaving result on the stack. Does it by stack\n"
      "%       manipulation, without needing to 'def' anything...\n"
      "\n"
      "/concat {\n"
      "        2 copy\n"
      "        length exch length add string dup dup\n"
      "        0 5 index putinterval\n"
      "        3 index length 3 index putinterval\n"
      "        exch pop exch pop\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% This does all the initial set up for a planner sheet, setting up\n"
      "% page, printing the times down left hand edge of sheet, printing\n"
      "% date and time of printing at the top, etc.\n"
      "\n"
      "/startprinting {\n"
      "        dup LastHour  gt { /LastHour  edef } { pop } ifelse\n"
      "        dup FirstHour lt { /FirstHour edef } { pop } ifelse\n"
      "        /Year edef\n"
      "        /Month edef\n"
      "        /Day edef\n"
      "        A4landscape\n"
      "        gsave\n"
      "        /Helvetica-Oblique findfont 8 scalefont setfont\n"
      "        LM TM 5 add m (Printed on: ) show\n"
      "          Day nstr cvs show (/) show\n"
      "        Month nstr cvs show (/) show\n"
      "         Year nstr cvs show\n"
      "        gsave\n"
      "        %----------------------------------------------------------\n"
      "        % Put the times, in 24 hour format, down the left hand edge\n"
      "        % of the page...\n"
      "        datefont usefont\n"
      "        /HourHeight TopOfDay BotOfDay sub LastHour FirstHour sub\n"
      "                    div def\n"
      "        FirstHour 1 LastHour {\n"
      "                dup dup 0 TimeToY fontsize 0.7 mul sub LM exch m\n"
      "                10 lt { (0) show } if\n"
      "                nstr cvs show (00) show\n"
      "        } for\n"
      "        grestore\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Brief counterpart to startprinting: just showpages and restores\n"
      "% the graphics state...\n"
      "\n"
      "/finishprinting {\n"
      "        showpage\n"
      "        grestore\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Give TimeToY a 24 hour clock time (hours, minutes) and it'll work\n"
      "% out a Y offset...\n"
      "\n"
      "/TimeColWidth 40 def\n"
      "/DayWidth RM LM sub TimeColWidth sub 7 div def\n"
      "/TopOfDay TM linespacing 2 mul sub def\n"
      "/BotOfDay BM linespacing 8 mul add def\n"
      "\n"
      "/TimeToY {\n"
      "        60 div exch FirstHour sub add HourHeight mul TopOfDay esub\n"
      "} def\n"
      "\n"
      "/TimeToY2 {\n"
      "        FirstHour sub HourHeight mul TopOfDay esub\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Some constants for the the 'StringToTime' routine below\n"
      "\n"
      "/PM     (p) 0 get def\n"
      "/AM     (a) 0 get def\n"
      "/Colon  (:) 0 get def\n"
      "/Zero   (0) 0 get def\n"
      "/Nine   (9) 0 get def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Give this a string containing a from/to time pair, like:\n"
      "%       (6:30pm to 7:30pm)\n"
      "% it will leave the two times, in 24-hour format, with the minutes\n"
      "% as a decimal fraction of the hour, on the stack.\n"
      "\n"
      "/StringToTimes {\n"
      "        /String edef\n"
      "\n"
      "        %----------------------------------------------------------\n"
      "        % This stuff extracts the from time from the start of the\n"
      "        % string.\n"
      "\n"
      "        String 1 get Colon eq { /Len1 1 def }{ /Len1 2 def } ifelse\n"
      "        /Hour1  String 0 Len1 getinterval cvi def\n"
      "        /Min1   String Len1 1 add 2 getinterval cvi def\n"
      "        Hour1 12 eq { /Hour1 0 def } if\n"
      "        String Len1 3 add get PM eq { /Hour1 Hour1 12 add def } if\n"
      "\n"
      "        Hour1 Min1 60 div add\n"
      "\n"
      "        %----------------------------------------------------------\n"
      "        /Len3 9 Len1 add def\n"
      "        String Len3 1 add get Colon eq { /Len2 1 def }\n"
      "                                       { /Len2 2 def } ifelse\n"
      "        /Hour2  String Len3 Len2 getinterval cvi def\n"
      "        /Min2   String Len3 Len2 1 add add 2 getinterval cvi def\n"
      "        Hour2 12 eq { /Hour2 0 def } if\n"
      "        String Len3 Len2 3 add add get PM eq\n"
      "            { /Hour2 Hour2 12 add def } if\n"
      "\n"
      "        Hour2 Min2 60 div add\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "\n"
      "/startday {\n"
      "        /Today edef\n"
      "        /TodayLM DayWidth Today mul TimeColWidth add LM add def\n"
      "        grestore gsave\n"
      "        gsave newpath\n"
      "        TodayLM TM m TodayLM DayWidth add TM l\n"
      "        TodayLM DayWidth add BM l TodayLM BM l\n"
      "        closepath 0 slw 0 setgray stroke\n"
      "        TodayLM TopOfDay 3 add m DayWidth 0 rlineto stroke\n"
      "        2 slw\n"
      "        TodayLM BotOfDay m DayWidth 0 rlineto stroke\n"
      "        Dashes {\n"
      "            0 slw [ 1 5 ] 1 setdash\n"
      "            FirstHour 1 add 1 LastHour 1 sub {\n"
      "                TodayLM exch 0 TimeToY m DayWidth 0 rlineto stroke\n"
      "            } for\n"
      "        } if\n"
      "        grestore\n"
      "        newpath\n"
      "        TodayLM TM m TodayLM DayWidth add TM l\n"
      "        TodayLM DayWidth add BM l TodayLM BM l\n"
      "        closepath clip\n"
      "        /BotItemY BotOfDay 3 sub def\n"
      "} def\n"
      "\n"
      "/dateline {\n"
      "        datefont usefont\n"
      "        TodayLM 5 add TM linespacing sub m show\n"
      "        TodayLM 5 add TM 100 sub m\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% 'spacify' routine to replace line-feeds with spaces in strings\n"
      "%  passed in - places string back on stack where it came from.\n"
      "\n"
      "/spacify {\n"
      "        /LF 10 def\n"
      "        /SP 32 def\n"
      "\n"
      "        /String edef\n"
      "\n"
      "        0 1 String length 1 sub {\n"
      "                /I edef\n"
      "                String I get LF eq {\n"
      "                        String I SP put\n"
      "                } if\n"
      "        } for\n"
      "        String\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Move onto the next line\n"
      "\n"
      "/incY { /X LMpara def /Y Y linespacing sub def } def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% This routine will do automatic line-breaking of the item text, so\n"
      "% that as much of it as possible is visible.\n"
      "%\n"
      "% Arguments are: 'Paragraph Y para'\n"
      "\n"
      "/para {\n"
      "    /RMpara TodayLM DayWidth add def\n"
      "    /LMpara TodayLM 3 add def\n"
      "    /Y edef\n"
      "    spacify\n"
      "    /Paragraph edef\n"
      "    /SpaceW ( ) stringwidth pop def\n"
      "    RMpara LMpara sub Paragraph stringwidth pop gt\n"
      "    {\n"
      "        %----------------------------------------------\n"
      "        % The whole paragraph fits on one line - so\n"
      "        % just print it!\n"
      "        %----------------------------------------------\n"
      "        LMpara Y m Paragraph show\n"
      "    } {\n"
      "        %----------------------------------------------\n"
      "        % Have to do our clever formatting\n"
      "        %----------------------------------------------\n"
      "        /X LMpara def\n"
      "        {\n"
      "            Paragraph ( ) search\n"
      "            {\n"
      "                %--------------------------------------------\n"
      "                % Found a space - so check where to print it.\n"
      "                %--------------------------------------------\n"
      "                dup\n"
      "                stringwidth pop /SW edef\n"
      "                SW RMpara X sub gt { incY } if\n"
      "                X Y m show\n"
      "                pop\n"
      "                /X X SW SpaceW add add def\n"
      "                /Paragraph edef\n"
      "            } {\n"
      "                %----------------------------------------\n"
      "                % No space. Print rest of string and exit\n"
      "                %----------------------------------------\n"
      "                RMpara X sub Paragraph stringwidth pop lt\n"
      "                { incY } if\n"
      "                X Y m Paragraph show\n"
      "                pop\n"
      "                exit\n"
      "            } ifelse\n"
      "        } loop\n"
      "    } ifelse\n"
      "} def\n"
      "\n"
      "%------------------------------------------------------------------\n"
      "% Takes either one or two arguments - one if no time component, two\n"
      "% if there is also a time for the appointment. Prints time in left\n"
      "% margin, and actual item text offset by 65 point. Long lines can\n"
      "% generate extra strings, which should print on a new line, but at\n"
      "% the moment, on basis that space is critical and in Filofax I am\n"
      "% likely to get the gist - I can always check the details at home!\n"
      "\n"
      "/itemline {\n"
      "    itemfont usefont\n"
      "    count 0 ne {\n"
      "        count 1 eq {\n"
      "            /BotItemY BotItemY linespacing sub def\n"
      "            TodayLM 3 add BotItemY m show\n"
      "        } {\n"
      "            { count 3 gt { concat } { exit } ifelse } loop\n"
      "            /Details        edef\n"
      "            /HourTo         edef\n"
      "            /HourFrom       edef\n"
      "            %----------------------------------------\n"
      "            % Having got the times extracted, draw the\n"
      "            % shaded box round the blocked out time,\n"
      "            % and set this box to be a clipping path...\n"
      "            gsave\n"
      "            newpath\n"
      "            TodayLM                 HourFrom TimeToY2 m\n"
      "            TodayLM DayWidth add    HourFrom TimeToY2 l\n"
      "            TodayLM DayWidth add    HourTo   TimeToY2 l\n"
      "            TodayLM                 HourTo   TimeToY2 l\n"
      "            closepath gsave 0.9 setgray fill\n"
      "            grestore gsave 0 setgray stroke\n"
      "            grestore clip\n"
      "\n"
      "            %----------------------------------------\n"
      "            % Now fill in the text of the details\n"
      "            Details HourFrom TimeToY2 linespacing sub para\n"
      "            grestore\n"
      "        } ifelse\n"
      "    } if\n"
      "} def\n"
      "\n"
      "%-------------------------------------------------------------\n\n\n";
  fputs(week_header, f);
}


x86 assembly (clang, -O0):
<print_week_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_week_header>:
mov    %rdi,%rcx
lea    0xee6(%rip),%rdi
mov    $0x2505,%esi
mov    $0x1,%edx
jmp    1030 <fwrite@plt>

LLVM IR (-O0):
@.str = [9478 x i8] c"/TM 560 def % top margin\0A/BM 30 def % bottom margin\0A/LM 30 def % left margin\0A/RM 810 def % right margin\0A\0A%------------------------------------------------------------------\0A\0A/itemfont /Helvetica-ISOLatin1 def\0A/datefont /Helvetica-Bold def\0A/FirstHour 9 def % Default beginning and end of the plan\0A/LastHour 22 def\0A\0A/usefont {findfont fontsize scalefont setfont} def\0A\0A%------------------------------------------------------------------\0A% Rotate page round so it is printed A4 landscape\0A\0A/A4landscape {\0A initgraphics\0A A4Y ScaleY mul 0 translate\0A 90 rotate\0A ScaleX ScaleY Min dup scale\0A} def\0A\0A%------------------------------------------------------------------\0A% 'concat' - routine to concatenate two strings from the\0A% stack, leaving result on the stack. Does it by stack\0A% manipulation, without needing to 'def' anything...\0A\0A/concat {\0A 2 copy\0A length exch length add string dup dup\0A 0 5 index putinterval\0A 3 index length 3 index putinterval\0A exch pop exch pop\0A} def\0A\0A%------------------------------------------------------------------\0A% This does all the initial set up for a planner sheet, setting up\0A% page, printing the times down left hand edge of sheet, printing\0A% date and time of printing at the top, etc.\0A\0A/startprinting {\0A dup LastHour gt { /LastHour edef } { pop } ifelse\0A dup FirstHour lt { /FirstHour edef } { pop } ifelse\0A /Year edef\0A /Month edef\0A /Day edef\0A A4landscape\0A gsave\0A /Helvetica-Oblique findfont 8 scalefont setfont\0A LM TM 5 add m (Printed on: ) show\0A Day nstr cvs show (/) show\0A Month nstr cvs show (/) show\0A Year nstr cvs show\0A gsave\0A %----------------------------------------------------------\0A % Put the times, in 24 hour format, down the left hand edge\0A % of the page...\0A datefont usefont\0A /HourHeight TopOfDay BotOfDay sub LastHour FirstHour sub\0A div def\0A FirstHour 1 LastHour {\0A dup dup 0 TimeToY fontsize 0.7 mul sub LM exch m\0A 10 lt { (0) show } if\0A nstr cvs show (00) show\0A } for\0A grestore\0A} def\0A\0A%------------------------------------------------------------------\0A% Brief counterpart to startprinting: just showpages and restores\0A% the graphics state...\0A\0A/finishprinting {\0A showpage\0A grestore\0A} def\0A\0A%------------------------------------------------------------------\0A% Give TimeToY a 24 hour clock time (hours, minutes) and it'll work\0A% out a Y offset...\0A\0A/TimeColWidth 40 def\0A/DayWidth RM LM sub TimeColWidth sub 7 div def\0A/TopOfDay TM linespacing 2 mul sub def\0A/BotOfDay BM linespacing 8 mul add def\0A\0A/TimeToY {\0A 60 div exch FirstHour sub add HourHeight mul TopOfDay esub\0A} def\0A\0A/TimeToY2 {\0A FirstHour sub HourHeight mul TopOfDay esub\0A} def\0A\0A%------------------------------------------------------------------\0A% Some constants for the the 'StringToTime' routine below\0A\0A/PM (p) 0 get def\0A/AM (a) 0 get def\0A/Colon (:) 0 get def\0A/Zero (0) 0 get def\0A/Nine (9) 0 get def\0A\0A%------------------------------------------------------------------\0A% Give this a string containing a from/to time pair, like:\0A% (6:30pm to 7:30pm)\0A% it will leave the two times, in 24-hour format, with the minutes\0A% as a decimal fraction of the hour, on the stack.\0A\0A/StringToTimes {\0A /String edef\0A\0A %----------------------------------------------------------\0A % This stuff extracts the from time from the start of the\0A % string.\0A\0A String 1 get Colon eq { /Len1 1 def }{ /Len1 2 def } ifelse\0A /Hour1 String 0 Len1 getinterval cvi def\0A /Min1 String Len1 1 add 2 getinterval cvi def\0A Hour1 12 eq { /Hour1 0 def } if\0A String Len1 3 add get PM eq { /Hour1 Hour1 12 add def } if\0A\0A Hour1 Min1 60 div add\0A\0A %----------------------------------------------------------\0A /Len3 9 Len1 add def\0A String Len3 1 add get Colon eq { /Len2 1 def }\0A { /Len2 2 def } ifelse\0A /Hour2 String Len3 Len2 getinterval cvi def\0A /Min2 String Len3 Len2 1 add add 2 getinterval cvi def\0A Hour2 12 eq { /Hour2 0 def } if\0A String Len3 Len2 3 add add get PM eq\0A { /Hour2 Hour2 12 add def } if\0A\0A Hour2 Min2 60 div add\0A} def\0A\0A%------------------------------------------------------------------\0A\0A/startday {\0A /Today edef\0A /TodayLM DayWidth Today mul TimeColWidth add LM add def\0A grestore gsave\0A gsave newpath\0A TodayLM TM m TodayLM DayWidth add TM l\0A TodayLM DayWidth add BM l TodayLM BM l\0A closepath 0 slw 0 setgray stroke\0A TodayLM TopOfDay 3 add m DayWidth 0 rlineto stroke\0A 2 slw\0A TodayLM BotOfDay m DayWidth 0 rlineto stroke\0A Dashes {\0A 0 slw [ 1 5 ] 1 setdash\0A FirstHour 1 add 1 LastHour 1 sub {\0A TodayLM exch 0 TimeToY m DayWidth 0 rlineto stroke\0A } for\0A } if\0A grestore\0A newpath\0A TodayLM TM m TodayLM DayWidth add TM l\0A TodayLM DayWidth add BM l TodayLM BM l\0A closepath clip\0A /BotItemY BotOfDay 3 sub def\0A} def\0A\0A/dateline {\0A datefont usefont\0A TodayLM 5 add TM linespacing sub m show\0A TodayLM 5 add TM 100 sub m\0A} def\0A\0A%------------------------------------------------------------------\0A% 'spacify' routine to replace line-feeds with spaces in strings\0A% passed in - places string back on stack where it came from.\0A\0A/spacify {\0A /LF 10 def\0A /SP 32 def\0A\0A /String edef\0A\0A 0 1 String length 1 sub {\0A /I edef\0A String I get LF eq {\0A String I SP put\0A } if\0A } for\0A String\0A} def\0A\0A%------------------------------------------------------------------\0A% Move onto the next line\0A\0A/incY { /X LMpara def /Y Y linespacing sub def } def\0A\0A%------------------------------------------------------------------\0A% This routine will do automatic line-breaking of the item text, so\0A% that as much of it as possible is visible.\0A%\0A% Arguments are: 'Paragraph Y para'\0A\0A/para {\0A /RMpara TodayLM DayWidth add def\0A /LMpara TodayLM 3 add def\0A /Y edef\0A spacify\0A /Paragraph edef\0A /SpaceW ( ) stringwidth pop def\0A RMpara LMpara sub Paragraph stringwidth pop gt\0A {\0A %----------------------------------------------\0A % The whole paragraph fits on one line - so\0A % just print it!\0A %----------------------------------------------\0A LMpara Y m Paragraph show\0A } {\0A %----------------------------------------------\0A % Have to do our clever formatting\0A %----------------------------------------------\0A /X LMpara def\0A {\0A Paragraph ( ) search\0A {\0A %--------------------------------------------\0A % Found a space - so check where to print it.\0A %--------------------------------------------\0A dup\0A stringwidth pop /SW edef\0A SW RMpara X sub gt { incY } if\0A X Y m show\0A pop\0A /X X SW SpaceW add add def\0A /Paragraph edef\0A } {\0A %----------------------------------------\0A % No space. Print rest of string and exit\0A %----------------------------------------\0A RMpara X sub Paragraph stringwidth pop lt\0A { incY } if\0A X Y m Paragraph show\0A pop\0A exit\0A } ifelse\0A } loop\0A } ifelse\0A} def\0A\0A%------------------------------------------------------------------\0A% Takes either one or two arguments - one if no time component, two\0A% if there is also a time for the appointment. Prints time in left\0A% margin, and actual item text offset by 65 point. Long lines can\0A% generate extra strings, which should print on a new line, but at\0A% the moment, on basis that space is critical and in Filofax I am\0A% likely to get the gist - I can always check the details at home!\0A\0A/itemline {\0A itemfont usefont\0A count 0 ne {\0A count 1 eq {\0A /BotItemY BotItemY linespacing sub def\0A TodayLM 3 add BotItemY m show\0A } {\0A { count 3 gt { concat } { exit } ifelse } loop\0A /Details edef\0A /HourTo edef\0A /HourFrom edef\0A %----------------------------------------\0A % Having got the times extracted, draw the\0A % shaded box round the blocked out time,\0A % and set this box to be a clipping path...\0A gsave\0A newpath\0A TodayLM HourFrom TimeToY2 m\0A TodayLM DayWidth add HourFrom TimeToY2 l\0A TodayLM DayWidth add HourTo TimeToY2 l\0A TodayLM HourTo TimeToY2 l\0A closepath gsave 0.9 setgray fill\0A grestore gsave 0 setgray stroke\0A grestore clip\0A\0A %----------------------------------------\0A % Now fill in the text of the details\0A Details HourFrom TimeToY2 linespacing sub para\0A grestore\0A } ifelse\0A } if\0A} def\0A\0A%-------------------------------------------------------------\0A\0A\0A\00"
define void @print_week_header(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i32* %0, i32** %2
store i8* getelementptr inbounds ([9478 x i8], [9478 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %3
%5 = load i32*, i32** %2
%6 = call i32 @fputs(i8* %4, i32* %5)
ret void
}

LLVM IR (-O2):
@.str = [9478 x i8] c"/TM 560 def % top margin\0A/BM 30 def % bottom margin\0A/LM 30 def % left margin\0A/RM 810 def % right margin\0A\0A%------------------------------------------------------------------\0A\0A/itemfont /Helvetica-ISOLatin1 def\0A/datefont /Helvetica-Bold def\0A/FirstHour 9 def % Default beginning and end of the plan\0A/LastHour 22 def\0A\0A/usefont {findfont fontsize scalefont setfont} def\0A\0A%------------------------------------------------------------------\0A% Rotate page round so it is printed A4 landscape\0A\0A/A4landscape {\0A initgraphics\0A A4Y ScaleY mul 0 translate\0A 90 rotate\0A ScaleX ScaleY Min dup scale\0A} def\0A\0A%------------------------------------------------------------------\0A% 'concat' - routine to concatenate two strings from the\0A% stack, leaving result on the stack. Does it by stack\0A% manipulation, without needing to 'def' anything...\0A\0A/concat {\0A 2 copy\0A length exch length add string dup dup\0A 0 5 index putinterval\0A 3 index length 3 index putinterval\0A exch pop exch pop\0A} def\0A\0A%------------------------------------------------------------------\0A% This does all the initial set up for a planner sheet, setting up\0A% page, printing the times down left hand edge of sheet, printing\0A% date and time of printing at the top, etc.\0A\0A/startprinting {\0A dup LastHour gt { /LastHour edef } { pop } ifelse\0A dup FirstHour lt { /FirstHour edef } { pop } ifelse\0A /Year edef\0A /Month edef\0A /Day edef\0A A4landscape\0A gsave\0A /Helvetica-Oblique findfont 8 scalefont setfont\0A LM TM 5 add m (Printed on: ) show\0A Day nstr cvs show (/) show\0A Month nstr cvs show (/) show\0A Year nstr cvs show\0A gsave\0A %----------------------------------------------------------\0A % Put the times, in 24 hour format, down the left hand edge\0A % of the page...\0A datefont usefont\0A /HourHeight TopOfDay BotOfDay sub LastHour FirstHour sub\0A div def\0A FirstHour 1 LastHour {\0A dup dup 0 TimeToY fontsize 0.7 mul sub LM exch m\0A 10 lt { (0) show } if\0A nstr cvs show (00) show\0A } for\0A grestore\0A} def\0A\0A%------------------------------------------------------------------\0A% Brief counterpart to startprinting: just showpages and restores\0A% the graphics state...\0A\0A/finishprinting {\0A showpage\0A grestore\0A} def\0A\0A%------------------------------------------------------------------\0A% Give TimeToY a 24 hour clock time (hours, minutes) and it'll work\0A% out a Y offset...\0A\0A/TimeColWidth 40 def\0A/DayWidth RM LM sub TimeColWidth sub 7 div def\0A/TopOfDay TM linespacing 2 mul sub def\0A/BotOfDay BM linespacing 8 mul add def\0A\0A/TimeToY {\0A 60 div exch FirstHour sub add HourHeight mul TopOfDay esub\0A} def\0A\0A/TimeToY2 {\0A FirstHour sub HourHeight mul TopOfDay esub\0A} def\0A\0A%------------------------------------------------------------------\0A% Some constants for the the 'StringToTime' routine below\0A\0A/PM (p) 0 get def\0A/AM (a) 0 get def\0A/Colon (:) 0 get def\0A/Zero (0) 0 get def\0A/Nine (9) 0 get def\0A\0A%------------------------------------------------------------------\0A% Give this a string containing a from/to time pair, like:\0A% (6:30pm to 7:30pm)\0A% it will leave the two times, in 24-hour format, with the minutes\0A% as a decimal fraction of the hour, on the stack.\0A\0A/StringToTimes {\0A /String edef\0A\0A %----------------------------------------------------------\0A % This stuff extracts the from time from the start of the\0A % string.\0A\0A String 1 get Colon eq { /Len1 1 def }{ /Len1 2 def } ifelse\0A /Hour1 String 0 Len1 getinterval cvi def\0A /Min1 String Len1 1 add 2 getinterval cvi def\0A Hour1 12 eq { /Hour1 0 def } if\0A String Len1 3 add get PM eq { /Hour1 Hour1 12 add def } if\0A\0A Hour1 Min1 60 div add\0A\0A %----------------------------------------------------------\0A /Len3 9 Len1 add def\0A String Len3 1 add get Colon eq { /Len2 1 def }\0A { /Len2 2 def } ifelse\0A /Hour2 String Len3 Len2 getinterval cvi def\0A /Min2 String Len3 Len2 1 add add 2 getinterval cvi def\0A Hour2 12 eq { /Hour2 0 def } if\0A String Len3 Len2 3 add add get PM eq\0A { /Hour2 Hour2 12 add def } if\0A\0A Hour2 Min2 60 div add\0A} def\0A\0A%------------------------------------------------------------------\0A\0A/startday {\0A /Today edef\0A /TodayLM DayWidth Today mul TimeColWidth add LM add def\0A grestore gsave\0A gsave newpath\0A TodayLM TM m TodayLM DayWidth add TM l\0A TodayLM DayWidth add BM l TodayLM BM l\0A closepath 0 slw 0 setgray stroke\0A TodayLM TopOfDay 3 add m DayWidth 0 rlineto stroke\0A 2 slw\0A TodayLM BotOfDay m DayWidth 0 rlineto stroke\0A Dashes {\0A 0 slw [ 1 5 ] 1 setdash\0A FirstHour 1 add 1 LastHour 1 sub {\0A TodayLM exch 0 TimeToY m DayWidth 0 rlineto stroke\0A } for\0A } if\0A grestore\0A newpath\0A TodayLM TM m TodayLM DayWidth add TM l\0A TodayLM DayWidth add BM l TodayLM BM l\0A closepath clip\0A /BotItemY BotOfDay 3 sub def\0A} def\0A\0A/dateline {\0A datefont usefont\0A TodayLM 5 add TM linespacing sub m show\0A TodayLM 5 add TM 100 sub m\0A} def\0A\0A%------------------------------------------------------------------\0A% 'spacify' routine to replace line-feeds with spaces in strings\0A% passed in - places string back on stack where it came from.\0A\0A/spacify {\0A /LF 10 def\0A /SP 32 def\0A\0A /String edef\0A\0A 0 1 String length 1 sub {\0A /I edef\0A String I get LF eq {\0A String I SP put\0A } if\0A } for\0A String\0A} def\0A\0A%------------------------------------------------------------------\0A% Move onto the next line\0A\0A/incY { /X LMpara def /Y Y linespacing sub def } def\0A\0A%------------------------------------------------------------------\0A% This routine will do automatic line-breaking of the item text, so\0A% that as much of it as possible is visible.\0A%\0A% Arguments are: 'Paragraph Y para'\0A\0A/para {\0A /RMpara TodayLM DayWidth add def\0A /LMpara TodayLM 3 add def\0A /Y edef\0A spacify\0A /Paragraph edef\0A /SpaceW ( ) stringwidth pop def\0A RMpara LMpara sub Paragraph stringwidth pop gt\0A {\0A %----------------------------------------------\0A % The whole paragraph fits on one line - so\0A % just print it!\0A %----------------------------------------------\0A LMpara Y m Paragraph show\0A } {\0A %----------------------------------------------\0A % Have to do our clever formatting\0A %----------------------------------------------\0A /X LMpara def\0A {\0A Paragraph ( ) search\0A {\0A %--------------------------------------------\0A % Found a space - so check where to print it.\0A %--------------------------------------------\0A dup\0A stringwidth pop /SW edef\0A SW RMpara X sub gt { incY } if\0A X Y m show\0A pop\0A /X X SW SpaceW add add def\0A /Paragraph edef\0A } {\0A %----------------------------------------\0A % No space. Print rest of string and exit\0A %----------------------------------------\0A RMpara X sub Paragraph stringwidth pop lt\0A { incY } if\0A X Y m Paragraph show\0A pop\0A exit\0A } ifelse\0A } loop\0A } ifelse\0A} def\0A\0A%------------------------------------------------------------------\0A% Takes either one or two arguments - one if no time component, two\0A% if there is also a time for the appointment. Prints time in left\0A% margin, and actual item text offset by 65 point. Long lines can\0A% generate extra strings, which should print on a new line, but at\0A% the moment, on basis that space is critical and in Filofax I am\0A% likely to get the gist - I can always check the details at home!\0A\0A/itemline {\0A itemfont usefont\0A count 0 ne {\0A count 1 eq {\0A /BotItemY BotItemY linespacing sub def\0A TodayLM 3 add BotItemY m show\0A } {\0A { count 3 gt { concat } { exit } ifelse } loop\0A /Details edef\0A /HourTo edef\0A /HourFrom edef\0A %----------------------------------------\0A % Having got the times extracted, draw the\0A % shaded box round the blocked out time,\0A % and set this box to be a clipping path...\0A gsave\0A newpath\0A TodayLM HourFrom TimeToY2 m\0A TodayLM DayWidth add HourFrom TimeToY2 l\0A TodayLM DayWidth add HourTo TimeToY2 l\0A TodayLM HourTo TimeToY2 l\0A closepath gsave 0.9 setgray fill\0A grestore gsave 0 setgray stroke\0A grestore clip\0A\0A %----------------------------------------\0A % Now fill in the text of the details\0A Details HourFrom TimeToY2 linespacing sub para\0A grestore\0A } ifelse\0A } if\0A} def\0A\0A%-------------------------------------------------------------\0A\0A\0A\00"
define void @print_week_header(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([9478 x i8], [9478 x i8]* @.str, i64 0, i64 0), i64 9477, i64 1, i32* %0)
ret void
}