#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 cos(float);
int sin(float);
void barb_convert(float angle, int distance, int *x, int *y) {
  if (angle > 360)
    angle -= 360;
  else if (angle < 0)
    angle += 360;
  float r_angle = angle * (3.14159265 / 180);
  *x = distance * cos(r_angle);
  *y = distance * sin(r_angle);
}


x86 assembly (clang, -O0):
<barb_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xebb(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1169 <barb_convert+0x49>
movss  -0x4(%rbp),%xmm0
movss  0xea5(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    118d <barb_convert+0x6d>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1188 <barb_convert+0x68>
movss  0xe82(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    118d <barb_convert+0x6d>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6a(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x24(%rbp),%ecx
imul   %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x20(%rbp),%ecx
imul   %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<barb_convert>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
ucomiss 0xec9(%rip),%xmm0
jbe    1143 <barb_convert+0x23>
addss  0xec3(%rip),%xmm0
jmp    1153 <barb_convert+0x33>
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    1153 <barb_convert+0x33>
addss  0xead(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xea9(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <cos@plt>
imul   %ebp,%eax
mov    %eax,(%rbx)
movss  0xc(%rsp),%xmm0
call   1030 <sin@plt>
imul   %ebp,%eax
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @barb_convert(float %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca float
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca float
store float %0, float* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load float, float* %5
%11 = fcmp ogt float %10, 3.600000e+02
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load float, float* %5
%14 = fsub float %13, 3.600000e+02
store float %14, float* %5
br label %22
15: ; preds = %4
%16 = load float, float* %5
%17 = fcmp olt float %16, 0.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load float, float* %5
%20 = fadd float %19, 3.600000e+02
store float %20, float* %5
br label %21
21: ; preds = %18, %15
br label %22
22: ; preds = %21, %12
%23 = load float, float* %5
%24 = fpext float %23 to double
%25 = fmul double %24, 0x3F91DF46A1FAE712
%26 = fptrunc double %25 to float
store float %26, float* %9
%27 = load i32, i32* %6
%28 = load float, float* %9
%29 = call i32 @cos(float %28)
%30 = mul nsw i32 %27, %29
%31 = load i32*, i32** %7
store i32 %30, i32* %31
%32 = load i32, i32* %6
%33 = load float, float* %9
%34 = call i32 @sin(float %33)
%35 = mul nsw i32 %32, %34
%36 = load i32*, i32** %8
store i32 %35, i32* %36
ret void
}

LLVM IR (-O2):
define void @barb_convert(float %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = fcmp ogt float %0, 3.600000e+02
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = fadd float %0, -3.600000e+02
br label %12
8: ; preds = %4
%9 = fcmp olt float %0, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = fadd float %0, 3.600000e+02
br label %12
12: ; preds = %8, %10, %6
%13 = phi float [ %7, %6 ], [ %11, %10 ], [ %0, %8 ]
%14 = fpext float %13 to double
%15 = fmul double %14, 0x3F91DF46A1FAE712
%16 = fptrunc double %15 to float
%17 = tail call i32 @cos(float %16)
%18 = mul nsw i32 %17, %1
store i32 %18, i32* %2
%19 = tail call i32 @sin(float %16)
%20 = mul nsw i32 %19, %1
store i32 %20, i32* %3
ret void
}