#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 */
double atan(int);
double cos(double);
scalar_t__ fabs(double);
double sin(double);
int tan(double);
void encloseellipse(double a, double b, double theta_rad, size_t *x_w,
                    size_t *y_w) {
  double t_x, t_y, max_x, max_y;
  t_x = atan(b / a * tan(theta_rad));
  t_y = atan(-1 * b / a / tan(theta_rad));
  max_x = a * cos(t_x) * cos(theta_rad) + b * sin(t_x) * sin(theta_rad);
  max_y = -1 * a * cos(t_y) * sin(theta_rad) + b * sin(t_y) * cos(theta_rad);
  *x_w = 2 * ((size_t)fabs(max_x) + 1) - 1;
  *y_w = 2 * ((size_t)fabs(max_y) + 1) - 1;
}


x86 assembly (clang, -O0):
<encloseellipse>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1060 <tan@plt>
movsd  -0xa8(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <atan@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe4c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1060 <tan@plt>
movsd  -0xa0(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <atan@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd72(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
add    $0x1,%rcx
shl    $0x1,%rcx
sub    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movsd  -0x48(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
add    $0x1,%rcx
shl    $0x1,%rcx
sub    $0x1,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encloseellipse>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm2,(%rsp)
movapd %xmm1,0x30(%rsp)
movsd  %xmm0,0x10(%rsp)
divsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movaps %xmm2,%xmm0
call   1060 <tan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <atan@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0xe5c(%rip),%xmm0
xorpd  0x30(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1060 <tan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1050 <atan@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x30(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
add    %rax,%rax
add    $0x1,%rax
mov    %rax,(%rbx)
movsd  (%rsp),%xmm0
call   1030 <fabs@plt>
add    %rax,%rax
add    $0x1,%rax
mov    %rax,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @encloseellipse(double %0, double %1, double %2, i64* %3, i64* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store i64* %3, i64** %9
store i64* %4, i64** %10
%15 = load double, double* %7
%16 = load double, double* %6
%17 = fdiv double %15, %16
%18 = load double, double* %8
%19 = call i32 @tan(double %18)
%20 = sitofp i32 %19 to double
%21 = fmul double %17, %20
%22 = fptosi double %21 to i32
%23 = call double @atan(i32 %22)
store double %23, double* %11
%24 = load double, double* %7
%25 = fmul double -1.000000e+00, %24
%26 = load double, double* %6
%27 = fdiv double %25, %26
%28 = load double, double* %8
%29 = call i32 @tan(double %28)
%30 = sitofp i32 %29 to double
%31 = fdiv double %27, %30
%32 = fptosi double %31 to i32
%33 = call double @atan(i32 %32)
store double %33, double* %12
%34 = load double, double* %6
%35 = load double, double* %11
%36 = call double @cos(double %35)
%37 = fmul double %34, %36
%38 = load double, double* %8
%39 = call double @cos(double %38)
%40 = load double, double* %7
%41 = load double, double* %11
%42 = call double @sin(double %41)
%43 = fmul double %40, %42
%44 = load double, double* %8
%45 = call double @sin(double %44)
%46 = fmul double %43, %45
%47 = call double @llvm.fmuladd.f64(double %37, double %39, double %46)
store double %47, double* %13
%48 = load double, double* %6
%49 = fmul double -1.000000e+00, %48
%50 = load double, double* %12
%51 = call double @cos(double %50)
%52 = fmul double %49, %51
%53 = load double, double* %8
%54 = call double @sin(double %53)
%55 = load double, double* %7
%56 = load double, double* %12
%57 = call double @sin(double %56)
%58 = fmul double %55, %57
%59 = load double, double* %8
%60 = call double @cos(double %59)
%61 = fmul double %58, %60
%62 = call double @llvm.fmuladd.f64(double %52, double %54, double %61)
store double %62, double* %14
%63 = load double, double* %13
%64 = call i64 @fabs(double %63)
%65 = add i64 %64, 1
%66 = mul i64 2, %65
%67 = sub i64 %66, 1
%68 = load i64*, i64** %9
store i64 %67, i64* %68
%69 = load double, double* %14
%70 = call i64 @fabs(double %69)
%71 = add i64 %70, 1
%72 = mul i64 2, %71
%73 = sub i64 %72, 1
%74 = load i64*, i64** %10
store i64 %73, i64* %74
ret void
}

LLVM IR (-O2):
define void @encloseellipse(double %0, double %1, double %2, i64* nocapture writeonly %3, i64* nocapture writeonly %4) {
%6 = fdiv double %1, %0
%7 = tail call i32 @tan(double %2)
%8 = sitofp i32 %7 to double
%9 = fmul double %6, %8
%10 = fptosi double %9 to i32
%11 = tail call double @atan(i32 %10)
%12 = fneg double %1
%13 = fdiv double %12, %0
%14 = tail call i32 @tan(double %2)
%15 = sitofp i32 %14 to double
%16 = fdiv double %13, %15
%17 = fptosi double %16 to i32
%18 = tail call double @atan(i32 %17)
%19 = tail call double @cos(double %11)
%20 = fmul double %19, %0
%21 = tail call double @cos(double %2)
%22 = tail call double @sin(double %11)
%23 = fmul double %22, %1
%24 = tail call double @sin(double %2)
%25 = fmul double %23, %24
%26 = tail call double @llvm.fmuladd.f64(double %20, double %21, double %25)
%27 = fneg double %0
%28 = tail call double @cos(double %18)
%29 = fmul double %28, %27
%30 = tail call double @sin(double %2)
%31 = tail call double @sin(double %18)
%32 = fmul double %31, %1
%33 = tail call double @cos(double %2)
%34 = fmul double %32, %33
%35 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %34)
%36 = tail call i64 @fabs(double %26)
%37 = shl i64 %36, 1
%38 = or i64 %37, 1
store i64 %38, i64* %3
%39 = tail call i64 @fabs(double %35)
%40 = shl i64 %39, 1
%41 = or i64 %40, 1
store i64 %41, i64* %4
ret void
}