#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 MAX(int, int);
scalar_t__ ceil(int);
double cos(double);
int fabs(double);
double sin(double);
void rotozoomSurfaceSizeTrig(int width, int height, double angle, double zoom,
                             int *dstwidth, int *dstheight, double *canglezoom,
                             double *sanglezoom) {
  double x, y, cx, cy, sx, sy;
  double radangle;
  int dstwidthhalf, dstheighthalf;
  radangle = angle * (3.141592654 / 180.0);
  *sanglezoom = sin(radangle);
  *canglezoom = cos(radangle);
  *sanglezoom *= zoom;
  *canglezoom *= zoom;
  x = width / 2;
  y = height / 2;
  cx = *canglezoom * x;
  cy = *canglezoom * y;
  sx = *sanglezoom * x;
  sy = *sanglezoom * y;
  dstwidthhalf =
      MAX((int)ceil(MAX(MAX(MAX(fabs(cx + sy), fabs(cx - sy)), fabs(-cx + sy)),
                        fabs(-cx - sy))),
          1);
  dstheighthalf =
      MAX((int)ceil(MAX(MAX(MAX(fabs(sx + cy), fabs(sx - cy)), fabs(-sx + cy)),
                        fabs(-sx - cy))),
          1);
  *dstwidth = 2 * dstwidthhalf;
  *dstheight = 2 * dstheighthalf;
}


x86 assembly (clang, -O0):
<rotozoomSurfaceSizeTrig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  0xe7d(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1060 <sin@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm0
call   1070 <cos@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
call   1050 <fabs@plt>
mov    %eax,-0x90(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x90(%rbp),%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,-0x8c(%rbp)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x68(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x8c(%rbp),%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,-0x88(%rbp)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  -0x68(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x88(%rbp),%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%edi
call   1040 <ceil@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <MAX@plt>
mov    %eax,-0x74(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
call   1050 <fabs@plt>
mov    %eax,-0x84(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x84(%rbp),%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x58(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x80(%rbp),%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,-0x7c(%rbp)
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  -0x58(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x7c(%rbp),%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%edi
call   1040 <ceil@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <MAX@plt>
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x78(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotozoomSurfaceSizeTrig>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%rbp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
movsd  %xmm1,(%rsp)
mov    %esi,%r12d
mov    %edi,%r13d
mulsd  0xe83(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1060 <sin@plt>
movsd  %xmm0,0x0(%rbp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,(%rbx)
movsd  0x0(%rbp),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp)
mulsd  (%rbx),%xmm1
mov    %r13d,%eax
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
cvtsi2sd %eax,%xmm2
movsd  %xmm1,(%rbx)
mov    %r12d,%eax
shr    $0x1f,%eax
add    %r12d,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm1,%xmm3
mulsd  %xmm2,%xmm3
movapd %xmm3,0x10(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x0(%rbp),%xmm1
mulsd  %xmm1,%xmm2
movapd %xmm2,0x30(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm3,%xmm0
addsd  %xmm1,%xmm0
call   1050 <fabs@plt>
mov    %eax,%ebx
movapd 0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
call   1050 <fabs@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%ebx
movapd 0xdd5(%rip),%xmm1
movapd %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movapd 0x10(%rsp),%xmm2
subsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
call   1050 <fabs@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%ebx
movapd 0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
call   1050 <fabs@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%edi
call   1040 <ceil@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <MAX@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
call   1050 <fabs@plt>
mov    %eax,%ebx
movapd 0x30(%rsp),%xmm0
subsd  (%rsp),%xmm0
call   1050 <fabs@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%ebx
movapd 0x30(%rsp),%xmm1
movapd 0x20(%rsp),%xmm0
xorpd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
call   1050 <fabs@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%ebx
movapd 0x20(%rsp),%xmm0
subsd  (%rsp),%xmm0
call   1050 <fabs@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <MAX@plt>
mov    %eax,%edi
call   1040 <ceil@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <MAX@plt>
add    %ebp,%ebp
mov    %ebp,(%r15)
add    %eax,%eax
mov    %eax,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rotozoomSurfaceSizeTrig(i32 %0, i32 %1, double %2, double %3, i32* %4, i32* %5, double* %6, double* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %9
store i32 %1, i32* %10
store double %2, double* %11
store double %3, double* %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store double* %6, double** %15
store double* %7, double** %16
%26 = load double, double* %11
%27 = fmul double %26, 0x3F91DF46A25CA311
store double %27, double* %23
%28 = load double, double* %23
%29 = call double @sin(double %28)
%30 = load double*, double** %16
store double %29, double* %30
%31 = load double, double* %23
%32 = call double @cos(double %31)
%33 = load double*, double** %15
store double %32, double* %33
%34 = load double, double* %12
%35 = load double*, double** %16
%36 = load double, double* %35
%37 = fmul double %36, %34
store double %37, double* %35
%38 = load double, double* %12
%39 = load double*, double** %15
%40 = load double, double* %39
%41 = fmul double %40, %38
store double %41, double* %39
%42 = load i32, i32* %9
%43 = sdiv i32 %42, 2
%44 = sitofp i32 %43 to double
store double %44, double* %17
%45 = load i32, i32* %10
%46 = sdiv i32 %45, 2
%47 = sitofp i32 %46 to double
store double %47, double* %18
%48 = load double*, double** %15
%49 = load double, double* %48
%50 = load double, double* %17
%51 = fmul double %49, %50
store double %51, double* %19
%52 = load double*, double** %15
%53 = load double, double* %52
%54 = load double, double* %18
%55 = fmul double %53, %54
store double %55, double* %20
%56 = load double*, double** %16
%57 = load double, double* %56
%58 = load double, double* %17
%59 = fmul double %57, %58
store double %59, double* %21
%60 = load double*, double** %16
%61 = load double, double* %60
%62 = load double, double* %18
%63 = fmul double %61, %62
store double %63, double* %22
%64 = load double, double* %19
%65 = load double, double* %22
%66 = fadd double %64, %65
%67 = call i32 @fabs(double %66)
%68 = load double, double* %19
%69 = load double, double* %22
%70 = fsub double %68, %69
%71 = call i32 @fabs(double %70)
%72 = call i32 @MAX(i32 %67, i32 %71)
%73 = load double, double* %19
%74 = fneg double %73
%75 = load double, double* %22
%76 = fadd double %74, %75
%77 = call i32 @fabs(double %76)
%78 = call i32 @MAX(i32 %72, i32 %77)
%79 = load double, double* %19
%80 = fneg double %79
%81 = load double, double* %22
%82 = fsub double %80, %81
%83 = call i32 @fabs(double %82)
%84 = call i32 @MAX(i32 %78, i32 %83)
%85 = call i64 @ceil(i32 %84)
%86 = trunc i64 %85 to i32
%87 = call i32 @MAX(i32 %86, i32 1)
store i32 %87, i32* %24
%88 = load double, double* %21
%89 = load double, double* %20
%90 = fadd double %88, %89
%91 = call i32 @fabs(double %90)
%92 = load double, double* %21
%93 = load double, double* %20
%94 = fsub double %92, %93
%95 = call i32 @fabs(double %94)
%96 = call i32 @MAX(i32 %91, i32 %95)
%97 = load double, double* %21
%98 = fneg double %97
%99 = load double, double* %20
%100 = fadd double %98, %99
%101 = call i32 @fabs(double %100)
%102 = call i32 @MAX(i32 %96, i32 %101)
%103 = load double, double* %21
%104 = fneg double %103
%105 = load double, double* %20
%106 = fsub double %104, %105
%107 = call i32 @fabs(double %106)
%108 = call i32 @MAX(i32 %102, i32 %107)
%109 = call i64 @ceil(i32 %108)
%110 = trunc i64 %109 to i32
%111 = call i32 @MAX(i32 %110, i32 1)
store i32 %111, i32* %25
%112 = load i32, i32* %24
%113 = mul nsw i32 2, %112
%114 = load i32*, i32** %13
store i32 %113, i32* %114
%115 = load i32, i32* %25
%116 = mul nsw i32 2, %115
%117 = load i32*, i32** %14
store i32 %116, i32* %117
ret void
}

LLVM IR (-O2):
define void @rotozoomSurfaceSizeTrig(i32 %0, i32 %1, double %2, double %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, double* nocapture %6, double* nocapture %7) {
%9 = fmul double %2, 0x3F91DF46A25CA311
%10 = tail call double @sin(double %9)
store double %10, double* %7
%11 = tail call double @cos(double %9)
store double %11, double* %6
%12 = load double, double* %7
%13 = fmul double %12, %3
store double %13, double* %7
%14 = load double, double* %6
%15 = fmul double %14, %3
store double %15, double* %6
%16 = sdiv i32 %0, 2
%17 = sitofp i32 %16 to double
%18 = sdiv i32 %1, 2
%19 = sitofp i32 %18 to double
%20 = fmul double %15, %17
%21 = fmul double %15, %19
%22 = load double, double* %7
%23 = fmul double %22, %17
%24 = fmul double %22, %19
%25 = fadd double %20, %24
%26 = tail call i32 @fabs(double %25)
%27 = fsub double %20, %24
%28 = tail call i32 @fabs(double %27)
%29 = tail call i32 @MAX(i32 %26, i32 %28)
%30 = fneg double %20
%31 = fsub double %24, %20
%32 = tail call i32 @fabs(double %31)
%33 = tail call i32 @MAX(i32 %29, i32 %32)
%34 = fsub double %30, %24
%35 = tail call i32 @fabs(double %34)
%36 = tail call i32 @MAX(i32 %33, i32 %35)
%37 = tail call i64 @ceil(i32 %36)
%38 = trunc i64 %37 to i32
%39 = tail call i32 @MAX(i32 %38, i32 1)
%40 = fadd double %21, %23
%41 = tail call i32 @fabs(double %40)
%42 = fsub double %23, %21
%43 = tail call i32 @fabs(double %42)
%44 = tail call i32 @MAX(i32 %41, i32 %43)
%45 = fneg double %23
%46 = fsub double %21, %23
%47 = tail call i32 @fabs(double %46)
%48 = tail call i32 @MAX(i32 %44, i32 %47)
%49 = fsub double %45, %21
%50 = tail call i32 @fabs(double %49)
%51 = tail call i32 @MAX(i32 %48, i32 %50)
%52 = tail call i64 @ceil(i32 %51)
%53 = trunc i64 %52 to i32
%54 = tail call i32 @MAX(i32 %53, i32 1)
%55 = shl nsw i32 %39, 1
store i32 %55, i32* %4
%56 = shl nsw i32 %54, 1
store i32 %56, i32* %5
ret void
}