#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 cos(double);
double sin(double);
int trans_(int *n, double *rlat, double *rlon, double *x, double *y,
           double *z__) {
  int i__1;
  static int i__, nn;
  static double phi, theta, cosphi;
  --z__;
  --y;
  --x;
  --rlon;
  --rlat;
  nn = *n;
  i__1 = nn;
  for (i__ = 1; i__ <= i__1; ++i__) {
    phi = rlat[i__];
    theta = rlon[i__];
    cosphi = cos(phi);
    x[i__] = cosphi * cos(theta);
    y[i__] = cosphi * sin(theta);
    z__[i__] = sin(phi);
  }
  return 0;
}


x86 assembly (clang, -O0):
<trans_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,0x2eb4(%rip)
mov    0x2eae(%rip),%eax
mov    %eax,-0x34(%rbp)
movl   $0x1,0x2e9d(%rip)
mov    0x2e97(%rip),%eax
cmp    -0x34(%rbp),%eax
jg     128c <trans_+0x16c>
mov    -0x10(%rbp),%rax
movslq 0x2e83(%rip),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0x2e7e(%rip)
mov    -0x18(%rbp),%rax
movslq 0x2e6b(%rip),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0x2e6e(%rip)
movsd  0x2e5e(%rip),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x2e61(%rip)
movsd  0x2e59(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0x2e44(%rip),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq 0x2e18(%rip),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0x2e23(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0x2e0e(%rip),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq 0x2de2(%rip),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0x2ddd(%rip),%xmm0
call   1030 <sin@plt>
mov    -0x30(%rbp),%rax
movslq 0x2dc5(%rip),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x2dba(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2db1(%rip)
jmp    119b <trans_+0x7b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trans_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%ebp
movl   $0x1,0x2f01(%rip)
test   %ebp,%ebp
jle    120a <trans_+0xea>
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cltq
movsd  -0x8(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x2ed0(%rip)
movsd  -0x8(%r13,%rax,8),%xmm1
movsd  %xmm1,0x2ec9(%rip)
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x2ebf(%rip)
movsd  0x2eaf(%rip),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movslq 0x2e8e(%rip),%rax
movsd  %xmm0,-0x8(%r12,%rax,8)
movsd  0x2e97(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x2e82(%rip),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movslq 0x2e61(%rip),%rax
movsd  %xmm0,-0x8(%r15,%rax,8)
movsd  0x2e5a(%rip),%xmm0
call   1030 <sin@plt>
movslq 0x2e46(%rip),%rcx
movsd  %xmm0,-0x8(%r14,%rcx,8)
lea    0x1(%rcx),%eax
mov    %eax,0x2e36(%rip)
cmp    %ebp,%ecx
jl     1160 <trans_+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@trans_.i__ = internal global i32 0
@trans_.nn = internal global i32 0
@trans_.phi = internal global double 0.000000e+00
@trans_.theta = internal global double 0.000000e+00
@trans_.cosphi = internal global double 0.000000e+00
define i32 @trans_(i32* %0, double* %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
store i32* %0, i32** %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%14 = load double*, double** %12
%15 = getelementptr inbounds double, double* %14, i32 -1
store double* %15, double** %12
%16 = load double*, double** %11
%17 = getelementptr inbounds double, double* %16, i32 -1
store double* %17, double** %11
%18 = load double*, double** %10
%19 = getelementptr inbounds double, double* %18, i32 -1
store double* %19, double** %10
%20 = load double*, double** %9
%21 = getelementptr inbounds double, double* %20, i32 -1
store double* %21, double** %9
%22 = load double*, double** %8
%23 = getelementptr inbounds double, double* %22, i32 -1
store double* %23, double** %8
%24 = load i32*, i32** %7
%25 = load i32, i32* %24
store i32 %25, i32* @trans_.nn
%26 = load i32, i32* @trans_.nn
store i32 %26, i32* %13
store i32 1, i32* @trans_.i__
br label %27
27: ; preds = %66, %6
%28 = load i32, i32* @trans_.i__
%29 = load i32, i32* %13
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %69
31: ; preds = %27
%32 = load double*, double** %8
%33 = load i32, i32* @trans_.i__
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
store double %36, double* @trans_.phi
%37 = load double*, double** %9
%38 = load i32, i32* @trans_.i__
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
store double %41, double* @trans_.theta
%42 = load double, double* @trans_.phi
%43 = call double @cos(double %42)
store double %43, double* @trans_.cosphi
%44 = load double, double* @trans_.cosphi
%45 = load double, double* @trans_.theta
%46 = call double @cos(double %45)
%47 = fmul double %44, %46
%48 = load double*, double** %10
%49 = load i32, i32* @trans_.i__
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
%52 = load double, double* @trans_.cosphi
%53 = load double, double* @trans_.theta
%54 = call double @sin(double %53)
%55 = fmul double %52, %54
%56 = load double*, double** %11
%57 = load i32, i32* @trans_.i__
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %55, double* %59
%60 = load double, double* @trans_.phi
%61 = call double @sin(double %60)
%62 = load double*, double** %12
%63 = load i32, i32* @trans_.i__
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
store double %61, double* %65
br label %66
66: ; preds = %31
%67 = load i32, i32* @trans_.i__
%68 = add nsw i32 %67, 1
store i32 %68, i32* @trans_.i__
br label %27
69: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@trans_.i__ = internal unnamed_addr global i32 0
@trans_.phi = internal unnamed_addr global double 0.000000e+00
@trans_.theta = internal unnamed_addr global double 0.000000e+00
@trans_.cosphi = internal unnamed_addr global double 0.000000e+00
define i32 @trans_(i32* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = getelementptr inbounds double, double* %5, i64 -1
%8 = getelementptr inbounds double, double* %4, i64 -1
%9 = getelementptr inbounds double, double* %3, i64 -1
%10 = getelementptr inbounds double, double* %2, i64 -1
%11 = getelementptr inbounds double, double* %1, i64 -1
%12 = load i32, i32* %0
store i32 1, i32* @trans_.i__
%13 = icmp slt i32 %12, 1
br i1 %13, label %42, label %14
14: ; preds = %6, %14
%15 = phi i32 [ %40, %14 ], [ 1, %6 ]
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %11, i64 %16
%18 = load double, double* %17
store double %18, double* @trans_.phi
%19 = getelementptr inbounds double, double* %10, i64 %16
%20 = load double, double* %19
store double %20, double* @trans_.theta
%21 = tail call double @cos(double %18)
store double %21, double* @trans_.cosphi
%22 = load double, double* @trans_.theta
%23 = tail call double @cos(double %22)
%24 = fmul double %21, %23
%25 = load i32, i32* @trans_.i__
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %9, i64 %26
store double %24, double* %27
%28 = load double, double* @trans_.cosphi
%29 = load double, double* @trans_.theta
%30 = tail call double @sin(double %29)
%31 = fmul double %28, %30
%32 = load i32, i32* @trans_.i__
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %8, i64 %33
store double %31, double* %34
%35 = load double, double* @trans_.phi
%36 = tail call double @sin(double %35)
%37 = load i32, i32* @trans_.i__
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %7, i64 %38
store double %36, double* %39
%40 = add nsw i32 %37, 1
store i32 %40, i32* @trans_.i__
%41 = icmp slt i32 %37, %12
br i1 %41, label %14, label %42
42: ; preds = %14, %6
ret i32 0
}