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

/* Variables and functions */
int /*<<< orphan*/ display_def_fonts(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ display_header(int /*<<< orphan*/ *, double, double, double,
                                  double);
int /*<<< orphan*/ display_pscommands(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                      double, double, double, double, double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
int display_postscript(Widget w, char *fname, double width_in_inches,
                       double height_in_inches, int landscape) {
  FILE *fp;
  double width_in_pts;
  double height_in_pts;
  double x_translation;
  double y_translation;
  double rotation;
  if (landscape == 0) {
    rotation = 0.0;
    height_in_pts = width_in_inches * 72;
    width_in_pts = height_in_inches * 72;
    x_translation = (603 - width_in_pts) / 2;
    y_translation = (783 - height_in_pts);
  } else {
    rotation = 90.0;
    width_in_pts = width_in_inches * 72;
    height_in_pts = height_in_inches * 72;
    x_translation = (603 + height_in_pts) / 2;
    y_translation = (783 - width_in_pts) / 2;
  }
  if ((fp = fopen(fname, "w")) == NULL) {
    fprintf(stderr, "DisplayWidget: couldn't open %s\n", fname);
    return -1;
  }
  display_header(fp, x_translation, y_translation, width_in_pts, height_in_pts);
  display_def_fonts(w, fp);
  display_pscommands(w, fp, x_translation, y_translation, width_in_pts,
                     height_in_pts, rotation);
  fprintf(fp, "showpage\n");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<display_postscript>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11e7 <display_postscript+0x87>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe82(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe70(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe56(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  0xe39(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe30(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1254 <display_postscript+0xf4>
movsd  0xe31(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe1c(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe0a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdf0(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  0xdd3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdca(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  0xdb5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    129a <display_postscript+0x13a>
mov    0x2d67(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rdx
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    130a <display_postscript+0x1aa>
mov    -0x30(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
call   1030 <display_header@plt>
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <display_def_fonts@plt>
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%rsi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm4
call   1060 <display_pscommands@plt>
mov    -0x30(%rbp),%rdi
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_postscript>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
movsd  0xe7a(%rip),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm1
movsd  0xe72(%rip),%xmm2
test   %edx,%edx
je     11da <display_postscript+0x6a>
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xe64(%rip),%xmm2
subsd  %xmm0,%xmm2
mulsd  0xe60(%rip),%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  0xe5a(%rip),%xmm2
movsd  %xmm2,0x28(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x20(%rsp)
jmp    120c <display_postscript+0x9c>
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xe24(%rip),%xmm2
movsd  %xmm0,0x20(%rsp)
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  %xmm1,0x10(%rsp)
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ae <display_postscript+0x13e>
mov    %rax,%rbp
movsd  0x8(%rsp),%xmm0
mulsd  0xde3(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rax,%rdi
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1030 <display_header@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <display_def_fonts@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
call   1060 <display_pscommands@plt>
lea    0xdbb(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1090 <fwrite@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12ce <display_postscript+0x15e>
mov    0x2d2b(%rip),%rax
movslq (%rax),%rdi
lea    0xd6b(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"DisplayWidget: couldn't open %s\0A\00"
@.str.2 = [10 x i8] c"showpage\0A\00"
define i32 @display_postscript(i32 %0, i8* %1, double %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 %0, i32* %7
store i8* %1, i8** %8
store double %2, double* %9
store double %3, double* %10
store i32 %4, i32* %11
%18 = load i32, i32* %11
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %5
store double 0.000000e+00, double* %17
%21 = load double, double* %9
%22 = fmul double %21, 7.200000e+01
store double %22, double* %14
%23 = load double, double* %10
%24 = fmul double %23, 7.200000e+01
store double %24, double* %13
%25 = load double, double* %13
%26 = fsub double 6.030000e+02, %25
%27 = fdiv double %26, 2.000000e+00
store double %27, double* %15
%28 = load double, double* %14
%29 = fsub double 7.830000e+02, %28
store double %29, double* %16
br label %41
30: ; preds = %5
store double 9.000000e+01, double* %17
%31 = load double, double* %9
%32 = fmul double %31, 7.200000e+01
store double %32, double* %13
%33 = load double, double* %10
%34 = fmul double %33, 7.200000e+01
store double %34, double* %14
%35 = load double, double* %14
%36 = fadd double 6.030000e+02, %35
%37 = fdiv double %36, 2.000000e+00
store double %37, double* %15
%38 = load double, double* %13
%39 = fsub double 7.830000e+02, %38
%40 = fdiv double %39, 2.000000e+00
store double %40, double* %16
br label %41
41: ; preds = %30, %20
%42 = load i8*, i8** %8
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %43, i32** %12
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = sext i32 %46 to i64
%48 = inttoptr i64 %47 to i32*
%49 = load i8*, i8** %8
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %49)
store i32 -1, i32* %6
br label %73
51: ; preds = %41
%52 = load i32*, i32** %12
%53 = load double, double* %15
%54 = load double, double* %16
%55 = load double, double* %13
%56 = load double, double* %14
%57 = call i32 @display_header(i32* %52, double %53, double %54, double %55, double %56)
%58 = load i32, i32* %7
%59 = load i32*, i32** %12
%60 = call i32 @display_def_fonts(i32 %58, i32* %59)
%61 = load i32, i32* %7
%62 = load i32*, i32** %12
%63 = load double, double* %15
%64 = load double, double* %16
%65 = load double, double* %13
%66 = load double, double* %14
%67 = load double, double* %17
%68 = call i32 @display_pscommands(i32 %61, i32* %62, double %63, double %64, double %65, double %66, double %67)
%69 = load i32*, i32** %12
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%71 = load i32*, i32** %12
%72 = call i32 @fclose(i32* %71)
store i32 0, i32* %6
br label %73
73: ; preds = %51, %45
%74 = load i32, i32* %6
ret i32 %74
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"DisplayWidget: couldn't open %s\0A\00"
@.str.2 = [10 x i8] c"showpage\0A\00"
define i32 @display_postscript(i32 %0, i8* %1, double %2, double %3, i32 %4) {
%6 = icmp eq i32 %4, 0
%7 = fmul double %2, 7.200000e+01
%8 = fmul double %3, 7.200000e+01
br i1 %6, label %9, label %12
9: ; preds = %5
%10 = fsub double 6.030000e+02, %8
%11 = fsub double 7.830000e+02, %7
br label %16
12: ; preds = %5
%13 = fadd double %8, 6.030000e+02
%14 = fsub double 7.830000e+02, %7
%15 = fmul double %14, 5.000000e-01
br label %16
16: ; preds = %12, %9
%17 = phi double [ %8, %9 ], [ %7, %12 ]
%18 = phi double [ %7, %9 ], [ %8, %12 ]
%19 = phi double [ %10, %9 ], [ %13, %12 ]
%20 = phi double [ %11, %9 ], [ %15, %12 ]
%21 = phi double [ 0.000000e+00, %9 ], [ 9.000000e+01, %12 ]
%22 = fmul double %19, 5.000000e-01
%23 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i32*
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %36
30: ; preds = %16
%31 = tail call i32 @display_header(i32* %23, double %22, double %20, double %17, double %18)
%32 = tail call i32 @display_def_fonts(i32 %0, i32* %23)
%33 = tail call i32 @display_pscommands(i32 %0, i32* %23, double %22, double %20, double %17, double %18, double %21)
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 9, i64 1, i32* %23)
%35 = tail call i32 @fclose(i32* %23)
br label %36
36: ; preds = %30, %25
%37 = phi i32 [ -1, %25 ], [ 0, %30 ]
ret i32 %37
}