#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 */
struct shape_data {
  int dummy;
};

/* Variables and functions */
double random_double();
int /*<<< orphan*/ triangle_init(struct shape_data *, double, double, double);
void triangle_random_init(struct shape_data *data) {
  double u = random_double();
  double v = random_double();
  double w = random_double();
  double a = u + v;
  double b = v + w;
  double c = u + w;
  triangle_init(data, a, b, c);
}


x86 assembly (clang, -O0):
<triangle_random_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <random_double@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <random_double@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <random_double@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1030 <triangle_init@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangle_random_init>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <random_double@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <random_double@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <random_double@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm3
movsd  (%rsp),%xmm1
addsd  %xmm1,%xmm3
addsd  %xmm0,%xmm1
addsd  %xmm0,%xmm2
mov    %rbx,%rdi
movapd %xmm3,%xmm0
add    $0x10,%rsp
pop    %rbx
jmp    1030 <triangle_init@plt>

LLVM IR (-O0):
%struct.shape_data = type { i32 }
define void @triangle_random_init(%struct.shape_data* %0) {
%2 = alloca %struct.shape_data*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store %struct.shape_data* %0, %struct.shape_data** %2
%9 = call double (...) @random_double()
store double %9, double* %3
%10 = call double (...) @random_double()
store double %10, double* %4
%11 = call double (...) @random_double()
store double %11, double* %5
%12 = load double, double* %3
%13 = load double, double* %4
%14 = fadd double %12, %13
store double %14, double* %6
%15 = load double, double* %4
%16 = load double, double* %5
%17 = fadd double %15, %16
store double %17, double* %7
%18 = load double, double* %3
%19 = load double, double* %5
%20 = fadd double %18, %19
store double %20, double* %8
%21 = load %struct.shape_data*, %struct.shape_data** %2
%22 = load double, double* %6
%23 = load double, double* %7
%24 = load double, double* %8
%25 = call i32 @triangle_init(%struct.shape_data* %21, double %22, double %23, double %24)
ret void
}

LLVM IR (-O2):
%struct.shape_data = type { i32 }
define void @triangle_random_init(%struct.shape_data* %0) {
%2 = tail call double (...) @random_double()
%3 = tail call double (...) @random_double()
%4 = tail call double (...) @random_double()
%5 = fadd double %2, %3
%6 = fadd double %3, %4
%7 = fadd double %2, %4
%8 = tail call i32 @triangle_init(%struct.shape_data* %0, double %5, double %6, double %7)
ret void
}