#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 /*<<< orphan*/ cart2polar(double, double, double *, double *);
int /*<<< orphan*/ polar2cart(double, double, double *, double *);
double tan(double);
void tustins2z(double res, double ims, double Ts, double *rez, double *imz) {
  double mag, ang, magd, angd;
  cart2polar(res, ims, &mag, &ang);
  double warp = mag / tan(mag * Ts / 2.0);
  cart2polar(res + warp, ims, &mag, &ang);
  cart2polar(res - warp, ims, &magd, &angd);
  polar2cart(mag / magd, ang - angd, rez, imz);
}


x86 assembly (clang, -O0):
<tustins2z>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <cart2polar@plt>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <cart2polar@plt>
movsd  -0x8(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <cart2polar@plt>
movsd  -0x30(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <polar2cart@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tustins2z>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    0x20(%rsp),%rbx
lea    0x40(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <cart2polar@plt>
movsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe7a(%rip),%xmm0
call   1040 <tan@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <cart2polar@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0x38(%rsp),%rdi
lea    0x30(%rsp),%rsi
movsd  0x18(%rsp),%xmm1
call   1050 <cart2polar@plt>
movsd  0x20(%rsp),%xmm0
divsd  0x38(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
subsd  0x30(%rsp),%xmm1
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <polar2cart@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @tustins2z(double %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%16 = load double, double* %6
%17 = load double, double* %7
%18 = call i32 @cart2polar(double %16, double %17, double* %11, double* %12)
%19 = load double, double* %11
%20 = load double, double* %11
%21 = load double, double* %8
%22 = fmul double %20, %21
%23 = fdiv double %22, 2.000000e+00
%24 = call double @tan(double %23)
%25 = fdiv double %19, %24
store double %25, double* %15
%26 = load double, double* %6
%27 = load double, double* %15
%28 = fadd double %26, %27
%29 = load double, double* %7
%30 = call i32 @cart2polar(double %28, double %29, double* %11, double* %12)
%31 = load double, double* %6
%32 = load double, double* %15
%33 = fsub double %31, %32
%34 = load double, double* %7
%35 = call i32 @cart2polar(double %33, double %34, double* %13, double* %14)
%36 = load double, double* %11
%37 = load double, double* %13
%38 = fdiv double %36, %37
%39 = load double, double* %12
%40 = load double, double* %14
%41 = fsub double %39, %40
%42 = load double*, double** %9
%43 = load double*, double** %10
%44 = call i32 @polar2cart(double %38, double %41, double* %42, double* %43)
ret void
}

LLVM IR (-O2):
define void @tustins2z(double %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = bitcast double* %6 to i8*
%11 = bitcast double* %7 to i8*
%12 = bitcast double* %8 to i8*
%13 = bitcast double* %9 to i8*
%14 = call i32 @cart2polar(double %0, double %1, double* %6, double* %7)
%15 = load double, double* %6
%16 = fmul double %15, %2
%17 = fmul double %16, 5.000000e-01
%18 = call double @tan(double %17)
%19 = fdiv double %15, %18
%20 = fadd double %19, %0
%21 = call i32 @cart2polar(double %20, double %1, double* %6, double* %7)
%22 = fsub double %0, %19
%23 = call i32 @cart2polar(double %22, double %1, double* %8, double* %9)
%24 = load double, double* %6
%25 = load double, double* %8
%26 = fdiv double %24, %25
%27 = load double, double* %7
%28 = load double, double* %9
%29 = fsub double %27, %28
%30 = call i32 @polar2cart(double %26, double %29, double* %3, double* %4)
ret void
}