#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 M_PI;
int atan2(double, double);
double cos(double);
int /*<<< orphan*/ printf(char *, double, double, double, ...);
double sin(double);
void gt_r3(double ag, double rad, double rad_t, double *r3, double *ag1,
           double *ag2) {
  double a1, b1, r1;
  double a2, b2, r2;
  a1 = (sin(ag * M_PI / 180)) * rad;
  b1 = (cos(ag * M_PI / 180)) * rad;
  r1 = rad;
  *ag1 = ag;
  a2 = a1;
  b2 = rad_t - b1;
  *ag2 = atan2(a2, b2) * 180 / M_PI;
  r2 = a2 / sin(*ag2 * M_PI / 180);
  *r3 = r2;
  printf("ag=%f, rad=%f, r1=%f, a1=%f, *ag1=%f\n", ag, rad, r1, a1, *ag1);
  printf("a2=%f, b2=%f, *ag2=%f, rad_t=%f, r2=%f\n", a2, b2, *ag2, rad_t, r2);
  printf("r3=%f, ag1=%f, ag2=%f\n", *r3, *ag1, *ag2);
}


x86 assembly (clang, -O0):
<gt_r3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2e79(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2e4e(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <cos@plt>
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <atan2@plt>
imul   $0xb4,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    0x2ddf(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2dba(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xdc6(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm4
lea    0xd84(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
lea    0xd80(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm2
lea    0xd82(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gt_r3>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
movapd %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
mov    0x2e77(%rip),%rbx
movsd  (%rbx),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xe7f(%rip),%xmm0
call   1050 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0xe5c(%rip),%xmm0
call   1060 <cos@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  %xmm1,(%r12)
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <atan2@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,(%r14)
mulsd  (%rbx),%xmm0
divsd  0xe08(%rip),%xmm0
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
movsd  %xmm1,(%r15)
movsd  (%r12),%xmm4
lea    0xde5(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movaps %xmm1,%xmm2
mov    $0x5,%al
call   1040 <printf@plt>
movsd  (%r14),%xmm2
lea    0xde9(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
mov    $0x5,%al
call   1040 <printf@plt>
movsd  (%r15),%xmm0
movsd  (%r12),%xmm1
movsd  (%r14),%xmm2
lea    0xddb(%rip),%rdi
mov    $0x3,%al
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@.str = [38 x i8] c"ag=%f, rad=%f, r1=%f, a1=%f, *ag1=%f\0A\00"
@.str.1 = [40 x i8] c"a2=%f, b2=%f, *ag2=%f, rad_t=%f, r2=%f\0A\00"
@.str.2 = [23 x i8] c"r3=%f, ag1=%f, ag2=%f\0A\00"
define void @gt_r3(double %0, double %1, double %2, double* %3, double* %4, double* %5) {
%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
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %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
%19 = load double, double* %7
%20 = load double, double* @M_PI
%21 = fmul double %19, %20
%22 = fdiv double %21, 1.800000e+02
%23 = call double @sin(double %22)
%24 = load double, double* %8
%25 = fmul double %23, %24
store double %25, double* %13
%26 = load double, double* %7
%27 = load double, double* @M_PI
%28 = fmul double %26, %27
%29 = fdiv double %28, 1.800000e+02
%30 = call double @cos(double %29)
%31 = load double, double* %8
%32 = fmul double %30, %31
store double %32, double* %14
%33 = load double, double* %8
store double %33, double* %15
%34 = load double, double* %7
%35 = load double*, double** %11
store double %34, double* %35
%36 = load double, double* %13
store double %36, double* %16
%37 = load double, double* %9
%38 = load double, double* %14
%39 = fsub double %37, %38
store double %39, double* %17
%40 = load double, double* %16
%41 = load double, double* %17
%42 = call i32 @atan2(double %40, double %41)
%43 = mul nsw i32 %42, 180
%44 = sitofp i32 %43 to double
%45 = load double, double* @M_PI
%46 = fdiv double %44, %45
%47 = load double*, double** %12
store double %46, double* %47
%48 = load double, double* %16
%49 = load double*, double** %12
%50 = load double, double* %49
%51 = load double, double* @M_PI
%52 = fmul double %50, %51
%53 = fdiv double %52, 1.800000e+02
%54 = call double @sin(double %53)
%55 = fdiv double %48, %54
store double %55, double* %18
%56 = load double, double* %18
%57 = load double*, double** %10
store double %56, double* %57
%58 = load double, double* %7
%59 = load double, double* %8
%60 = load double, double* %15
%61 = load double, double* %13
%62 = load double*, double** %11
%63 = load double, double* %62
%64 = call i32 (i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %58, double %59, double %60, double %61, double %63)
%65 = load double, double* %16
%66 = load double, double* %17
%67 = load double*, double** %12
%68 = load double, double* %67
%69 = load double, double* %9
%70 = load double, double* %18
%71 = call i32 (i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), double %65, double %66, double %68, double %69, double %70)
%72 = load double*, double** %10
%73 = load double, double* %72
%74 = load double*, double** %11
%75 = load double, double* %74
%76 = load double*, double** %12
%77 = load double, double* %76
%78 = call i32 (i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %73, double %75, double %77)
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@.str = [38 x i8] c"ag=%f, rad=%f, r1=%f, a1=%f, *ag1=%f\0A\00"
@.str.1 = [40 x i8] c"a2=%f, b2=%f, *ag2=%f, rad_t=%f, r2=%f\0A\00"
@.str.2 = [23 x i8] c"r3=%f, ag1=%f, ag2=%f\0A\00"
define void @gt_r3(double %0, double %1, double %2, double* nocapture %3, double* nocapture %4, double* nocapture %5) {
%7 = load double, double* @M_PI
%8 = fmul double %7, %0
%9 = fdiv double %8, 1.800000e+02
%10 = tail call double @sin(double %9)
%11 = fmul double %10, %1
%12 = load double, double* @M_PI
%13 = fmul double %12, %0
%14 = fdiv double %13, 1.800000e+02
%15 = tail call double @cos(double %14)
%16 = fmul double %15, %1
store double %0, double* %4
%17 = fsub double %2, %16
%18 = tail call i32 @atan2(double %11, double %17)
%19 = mul nsw i32 %18, 180
%20 = sitofp i32 %19 to double
%21 = load double, double* @M_PI
%22 = fdiv double %20, %21
store double %22, double* %5
%23 = load double, double* @M_PI
%24 = fmul double %22, %23
%25 = fdiv double %24, 1.800000e+02
%26 = tail call double @sin(double %25)
%27 = fdiv double %11, %26
store double %27, double* %3
%28 = load double, double* %4
%29 = tail call i32 (i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %1, double %11, double %28)
%30 = load double, double* %5
%31 = tail call i32 (i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), double %11, double %17, double %30, double %2, double %27)
%32 = load double, double* %3
%33 = load double, double* %4
%34 = load double, double* %5
%35 = tail call i32 (i8*, double, double, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %32, double %33, double %34)
ret void
}