void doarc(x, y, xoff, yoff, cosine, sine, nsegs) float x, y, xoff, yoff,
    cosine, sine;
int nsegs;
{
  float cx, cy, dx, dy;
  int i;
  cx = x + xoff;
  cy = y + yoff;
  move2(cx, cy);
  for (i = 0; i < nsegs; i++) {
    dx = cx - x;
    dy = cy - y;
    cx = x + dx * cosine - dy * sine;
    cy = y + dx * sine + dy * cosine;
    draw2(cx, cy);
  }
}


x86 assembly (clang, -O0):
<doarc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm4,-0x40(%rbp)
movsd  %xmm3,-0x48(%rbp)
movaps %xmm2,%xmm3
movsd  -0x48(%rbp),%xmm2
movaps %xmm1,%xmm4
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm5
movsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm5,%xmm5
cvtsd2ss %xmm4,%xmm4
cvtsd2ss %xmm3,%xmm3
cvtsd2ss %xmm2,%xmm2
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm5,-0x4(%rbp)
movss  %xmm4,-0x8(%rbp)
movss  %xmm3,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm1,-0x14(%rbp)
movss  %xmm0,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    $0x2,%al
call   1040 <move2@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1280 <doarc+0x160>
movss  -0x20(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    $0x2,%al
call   1030 <draw2@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c6 <doarc+0xa6>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doarc>:
push   %rbx
sub    $0x40,%rsp
unpcklpd %xmm1,%xmm0
cvtpd2ps %xmm0,%xmm6
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
xorps  %xmm2,%xmm2
cvtsd2ss %xmm3,%xmm2
mov    %edi,%ebx
movaps %xmm5,0x10(%rsp)
movaps %xmm4,(%rsp)
movapd %xmm6,%xmm1
movss  %xmm0,%xmm1
movlhps %xmm6,%xmm2
movaps %xmm6,0x30(%rsp)
shufps $0xe2,%xmm6,%xmm2
addps  %xmm1,%xmm2
movaps %xmm2,%xmm1
shufps $0x55,%xmm2,%xmm1
movaps %xmm2,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
cvtss2sd %xmm1,%xmm1
mov    $0x2,%al
call   1040 <move2@plt>
test   %ebx,%ebx
jle    11f8 <doarc+0xd8>
movapd 0x10(%rsp),%xmm0
unpcklpd (%rsp),%xmm0
cvtpd2ps %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
shufps $0xe1,%xmm0,%xmm0
movaps %xmm0,(%rsp)
nopl   0x0(%rax)
movaps 0x30(%rsp),%xmm2
movaps 0x20(%rsp),%xmm3
subps  %xmm2,%xmm3
movaps %xmm3,%xmm0
shufps $0x55,%xmm3,%xmm0
xorps  0xe45(%rip),%xmm0
movaps %xmm3,%xmm1
shufps $0x0,%xmm3,%xmm1
mulps  (%rsp),%xmm1
addps  %xmm2,%xmm1
movss  %xmm0,%xmm3
mulps  0x10(%rsp),%xmm3
addps  %xmm1,%xmm3
movaps %xmm3,%xmm1
shufps $0x55,%xmm3,%xmm1
movaps %xmm3,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
cvtss2sd %xmm1,%xmm1
mov    $0x2,%al
call   1030 <draw2@plt>
add    $0xffffffff,%ebx
jne    11a0 <doarc+0x80>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @doarc(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6) {
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i32
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca i32
%20 = fptrunc double %0 to float
%21 = fptrunc double %1 to float
%22 = fptrunc double %2 to float
%23 = fptrunc double %3 to float
%24 = fptrunc double %4 to float
%25 = fptrunc double %5 to float
store float %20, float* %8
store float %21, float* %9
store float %22, float* %10
store float %23, float* %11
store float %24, float* %12
store float %25, float* %13
store i32 %6, i32* %14
%26 = load float, float* %8
%27 = load float, float* %10
%28 = fadd float %26, %27
store float %28, float* %15
%29 = load float, float* %9
%30 = load float, float* %11
%31 = fadd float %29, %30
store float %31, float* %16
%32 = load float, float* %15
%33 = fpext float %32 to double
%34 = load float, float* %16
%35 = fpext float %34 to double
%36 = call i32 (double, double, ...) bitcast (i32 (...)* @move2 to i32 (double, double, ...)*)(double %33, double %35)
store i32 0, i32* %19
br label %37
37: ; preds = %68, %7
%38 = load i32, i32* %19
%39 = load i32, i32* %14
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %71
41: ; preds = %37
%42 = load float, float* %15
%43 = load float, float* %8
%44 = fsub float %42, %43
store float %44, float* %17
%45 = load float, float* %16
%46 = load float, float* %9
%47 = fsub float %45, %46
store float %47, float* %18
%48 = load float, float* %8
%49 = load float, float* %17
%50 = load float, float* %12
%51 = call float @llvm.fmuladd.f32(float %49, float %50, float %48)
%52 = load float, float* %18
%53 = load float, float* %13
%54 = fneg float %52
%55 = call float @llvm.fmuladd.f32(float %54, float %53, float %51)
store float %55, float* %15
%56 = load float, float* %9
%57 = load float, float* %17
%58 = load float, float* %13
%59 = call float @llvm.fmuladd.f32(float %57, float %58, float %56)
%60 = load float, float* %18
%61 = load float, float* %12
%62 = call float @llvm.fmuladd.f32(float %60, float %61, float %59)
store float %62, float* %16
%63 = load float, float* %15
%64 = fpext float %63 to double
%65 = load float, float* %16
%66 = fpext float %65 to double
%67 = call i32 (double, double, ...) bitcast (i32 (...)* @draw2 to i32 (double, double, ...)*)(double %64, double %66)
br label %68
68: ; preds = %41
%69 = load i32, i32* %19
%70 = add nsw i32 %69, 1
store i32 %70, i32* %19
br label %37
71: ; preds = %37
ret void
}

LLVM IR (-O2):
define void @doarc(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6) {
%8 = insertelement <2 x double> poison, double %0, i64 0
%9 = insertelement <2 x double> %8, double %1, i64 1
%10 = fptrunc <2 x double> %9 to <2 x float>
%11 = fptrunc double %2 to float
%12 = fptrunc double %3 to float
%13 = insertelement <2 x double> poison, double %5, i64 0
%14 = insertelement <2 x double> %13, double %4, i64 1
%15 = fptrunc <2 x double> %14 to <2 x float>
%16 = insertelement <2 x float> %10, float %11, i64 0
%17 = insertelement <2 x float> %10, float %12, i64 1
%18 = fadd <2 x float> %16, %17
%19 = extractelement <2 x float> %18, i64 0
%20 = fpext float %19 to double
%21 = extractelement <2 x float> %18, i64 1
%22 = fpext float %21 to double
%23 = tail call i32 (double, double, ...) bitcast (i32 (...)* @move2 to i32 (double, double, ...)*)(double %20, double %22)
%24 = icmp sgt i32 %6, 0
br i1 %24, label %25, label %45
25: ; preds = %7
%26 = shufflevector <2 x float> %15, <2 x float> undef, <2 x i32> <i32 1, i32 0>
br label %27
27: ; preds = %25, %27
%28 = phi i32 [ %43, %27 ], [ 0, %25 ]
%29 = phi <2 x float> [ %37, %27 ], [ %18, %25 ]
%30 = fsub <2 x float> %29, %10
%31 = fsub <2 x float> %29, %10
%32 = extractelement <2 x float> %31, i64 1
%33 = fneg float %32
%34 = shufflevector <2 x float> %30, <2 x float> undef, <2 x i32> zeroinitializer
%35 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %34, <2 x float> %26, <2 x float> %10)
%36 = insertelement <2 x float> %31, float %33, i64 0
%37 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %36, <2 x float> %15, <2 x float> %35)
%38 = extractelement <2 x float> %37, i64 0
%39 = fpext float %38 to double
%40 = extractelement <2 x float> %37, i64 1
%41 = fpext float %40 to double
%42 = tail call i32 (double, double, ...) bitcast (i32 (...)* @draw2 to i32 (double, double, ...)*)(double %39, double %41)
%43 = add nuw nsw i32 %28, 1
%44 = icmp eq i32 %43, %6
br i1 %44, label %45, label %27
45: ; preds = %27, %7
ret void
}