#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 */
float cos(float);
int /*<<< orphan*/ graphic_draw_circle(float, float, double, int);
int /*<<< orphan*/ graphic_draw_segment(float, float, float, float);
int /*<<< orphan*/ graphic_set_color3f(double, double, int);
int /*<<< orphan*/ graphic_set_line_width(int);
float sin(float);
void chaine_dessine(float l1, float l2, float alpha, float beta) {
  float px = l1 * cos(alpha), py = l1 * sin(alpha);
  float qx = px + l2 * cos(alpha + beta), qy = py + l2 * sin(alpha + beta);
  graphic_set_color3f(.2, .8, 1.);
  graphic_set_line_width(3.);
  graphic_draw_segment(0., 0., px, py);
  graphic_draw_segment(px, py, qx, qy);
  graphic_draw_circle(0., 0., 0.2, 1);
  graphic_draw_circle(px, py, 0.2, 1);
  graphic_set_line_width(1.);
}


x86 assembly (clang, -O0):
<chaine_dessine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
call   1070 <cos@plt>
movss  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x2c(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
call   1050 <sin@plt>
movss  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x24(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movsd  0xdb8(%rip),%xmm0
movsd  0xdb8(%rip),%xmm1
mov    $0x1,%edi
call   1030 <graphic_set_color3f@plt>
mov    $0x3,%edi
call   1040 <graphic_set_line_width@plt>
movss  -0x14(%rbp),%xmm2
movss  -0x18(%rbp),%xmm3
xorps  %xmm1,%xmm1
movaps %xmm1,%xmm0
call   1060 <graphic_draw_segment@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
movss  -0x20(%rbp),%xmm3
call   1060 <graphic_draw_segment@plt>
xorps  %xmm1,%xmm1
movsd  0xd63(%rip),%xmm2
mov    $0x1,%edi
movaps %xmm1,%xmm0
call   1080 <graphic_draw_circle@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movsd  0xd44(%rip),%xmm2
mov    $0x1,%edi
call   1080 <graphic_draw_circle@plt>
mov    $0x1,%edi
call   1040 <graphic_set_line_width@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaine_dessine>:
sub    $0x18,%rsp
movss  %xmm3,0x14(%rsp)
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x4(%rsp)
movaps %xmm2,%xmm0
call   1070 <cos@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x14(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
call   1070 <cos@plt>
mulss  0xc(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x14(%rsp),%xmm0
call   1050 <sin@plt>
movss  0xc(%rsp),%xmm1
mulss  %xmm0,%xmm1
addss  0x4(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movsd  0xe03(%rip),%xmm0
movsd  0xe03(%rip),%xmm1
mov    $0x1,%edi
call   1030 <graphic_set_color3f@plt>
mov    $0x3,%edi
call   1040 <graphic_set_line_width@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movss  0x10(%rsp),%xmm2
movss  0x4(%rsp),%xmm3
call   1060 <graphic_draw_segment@plt>
movss  0x10(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
call   1060 <graphic_draw_segment@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movsd  0xda5(%rip),%xmm2
mov    $0x1,%edi
call   1080 <graphic_draw_circle@plt>
movss  0x10(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movsd  0xd87(%rip),%xmm2
mov    $0x1,%edi
call   1080 <graphic_draw_circle@plt>
mov    $0x1,%edi
add    $0x18,%rsp
jmp    1040 <graphic_set_line_width@plt>

LLVM IR (-O0):
define void @chaine_dessine(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%13 = load float, float* %5
%14 = load float, float* %7
%15 = call float @cos(float %14)
%16 = fmul float %13, %15
store float %16, float* %9
%17 = load float, float* %5
%18 = load float, float* %7
%19 = call float @sin(float %18)
%20 = fmul float %17, %19
store float %20, float* %10
%21 = load float, float* %9
%22 = load float, float* %6
%23 = load float, float* %7
%24 = load float, float* %8
%25 = fadd float %23, %24
%26 = call float @cos(float %25)
%27 = call float @llvm.fmuladd.f32(float %22, float %26, float %21)
store float %27, float* %11
%28 = load float, float* %10
%29 = load float, float* %6
%30 = load float, float* %7
%31 = load float, float* %8
%32 = fadd float %30, %31
%33 = call float @sin(float %32)
%34 = call float @llvm.fmuladd.f32(float %29, float %33, float %28)
store float %34, float* %12
%35 = call i32 @graphic_set_color3f(double 2.000000e-01, double 8.000000e-01, i32 1)
%36 = call i32 @graphic_set_line_width(i32 3)
%37 = load float, float* %9
%38 = load float, float* %10
%39 = call i32 @graphic_draw_segment(float 0.000000e+00, float 0.000000e+00, float %37, float %38)
%40 = load float, float* %9
%41 = load float, float* %10
%42 = load float, float* %11
%43 = load float, float* %12
%44 = call i32 @graphic_draw_segment(float %40, float %41, float %42, float %43)
%45 = call i32 @graphic_draw_circle(float 0.000000e+00, float 0.000000e+00, double 2.000000e-01, i32 1)
%46 = load float, float* %9
%47 = load float, float* %10
%48 = call i32 @graphic_draw_circle(float %46, float %47, double 2.000000e-01, i32 1)
%49 = call i32 @graphic_set_line_width(i32 1)
ret void
}

LLVM IR (-O2):
define void @chaine_dessine(float %0, float %1, float %2, float %3) {
%5 = tail call float @cos(float %2)
%6 = fmul float %5, %0
%7 = tail call float @sin(float %2)
%8 = fmul float %7, %0
%9 = fadd float %2, %3
%10 = tail call float @cos(float %9)
%11 = tail call float @llvm.fmuladd.f32(float %1, float %10, float %6)
%12 = tail call float @sin(float %9)
%13 = tail call float @llvm.fmuladd.f32(float %1, float %12, float %8)
%14 = tail call i32 @graphic_set_color3f(double 2.000000e-01, double 8.000000e-01, i32 1)
%15 = tail call i32 @graphic_set_line_width(i32 3)
%16 = tail call i32 @graphic_draw_segment(float 0.000000e+00, float 0.000000e+00, float %6, float %8)
%17 = tail call i32 @graphic_draw_segment(float %6, float %8, float %11, float %13)
%18 = tail call i32 @graphic_draw_circle(float 0.000000e+00, float 0.000000e+00, double 2.000000e-01, i32 1)
%19 = tail call i32 @graphic_draw_circle(float %6, float %8, double 2.000000e-01, i32 1)
%20 = tail call i32 @graphic_set_line_width(i32 1)
ret void
}