#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ td_add(double *, double *, double *);
int /*<<< orphan*/ td_div(double *, double *, double *);
int /*<<< orphan*/ td_mul(double *, double *, double *);
int /*<<< orphan*/ td_random(double *);
int /*<<< orphan*/ td_sub(double *, double *, double *);
int /*<<< orphan*/ td_write_doubles(double *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int basic_test(void) {
  double a[3], b[3], c[3], d[3];
  printf("Testing some basic operations ...\n");
  srand(time(NULL));
  td_random(a);
  printf("the first random number a :\n");
  td_write_doubles(a);
  td_random(b);
  printf("the second random number b :\n");
  td_write_doubles(b);
  td_add(a, b, c);
  printf("a+b :\n");
  td_write_doubles(c);
  td_sub(c, a, d);
  printf("a+b-a :\n");
  td_write_doubles(d);
  td_mul(a, b, c);
  printf("a*b :\n");
  td_write_doubles(c);
  td_div(c, a, d);
  printf("a*b/a :\n");
  td_write_doubles(d);
  return 0;
}


x86 assembly (clang, -O0):
<basic_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x20(%rbp),%rdi
call   10b0 <td_random@plt>
lea    0xe5c(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1090 <td_write_doubles@plt>
lea    -0x40(%rbp),%rdi
call   10b0 <td_random@plt>
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1090 <td_write_doubles@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <td_add@plt>
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1090 <td_write_doubles@plt>
lea    -0x60(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1040 <td_sub@plt>
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1090 <td_write_doubles@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1070 <td_mul@plt>
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1090 <td_write_doubles@plt>
lea    -0x60(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   10a0 <td_div@plt>
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1090 <td_write_doubles@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basic_test>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0x60(%rsp),%r14
mov    %r14,%rdi
call   10b0 <td_random@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1090 <td_write_doubles@plt>
lea    0x40(%rsp),%r15
mov    %r15,%rdi
call   10b0 <td_random@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1090 <td_write_doubles@plt>
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <td_add@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <td_write_doubles@plt>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <td_sub@plt>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1090 <td_write_doubles@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <td_mul@plt>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <td_write_doubles@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   10a0 <td_div@plt>
lea    0xdf5(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1090 <td_write_doubles@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Testing some basic operations ...\0A\00"
@.str.1 = [29 x i8] c"the first random number a :\0A\00"
@.str.2 = [30 x i8] c"the second random number b :\0A\00"
@.str.3 = [7 x i8] c"a+b :\0A\00"
@.str.4 = [9 x i8] c"a+b-a :\0A\00"
@.str.5 = [7 x i8] c"a*b :\0A\00"
@.str.6 = [9 x i8] c"a*b/a :\0A\00"
define i32 @basic_test() {
%1 = alloca [3 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
%8 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%9 = call i32 @td_random(double* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%12 = call i32 @td_write_doubles(double* %11)
%13 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%14 = call i32 @td_random(double* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%17 = call i32 @td_write_doubles(double* %16)
%18 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%19 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%20 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%21 = call i32 @td_add(double* %18, double* %19, double* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%23 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%24 = call i32 @td_write_doubles(double* %23)
%25 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%26 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%27 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%28 = call i32 @td_sub(double* %25, double* %26, double* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%30 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%31 = call i32 @td_write_doubles(double* %30)
%32 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%33 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%34 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%35 = call i32 @td_mul(double* %32, double* %33, double* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%37 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%38 = call i32 @td_write_doubles(double* %37)
%39 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%40 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%41 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%42 = call i32 @td_div(double* %39, double* %40, double* %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%44 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%45 = call i32 @td_write_doubles(double* %44)
ret i32 0
}

LLVM IR (-O2):
@str = [34 x i8] c"Testing some basic operations ...\00"
@str.7 = [28 x i8] c"the first random number a :\00"
@str.8 = [29 x i8] c"the second random number b :\00"
@str.9 = [6 x i8] c"a+b :\00"
@str.10 = [8 x i8] c"a+b-a :\00"
@str.11 = [6 x i8] c"a*b :\00"
@str.12 = [8 x i8] c"a*b/a :\00"
define i32 @basic_test() {
%1 = alloca [3 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %1 to i8*
%6 = bitcast [3 x double]* %2 to i8*
%7 = bitcast [3 x double]* %3 to i8*
%8 = bitcast [3 x double]* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @time(i32* null)
%11 = tail call i32 @srand(i32 %10)
%12 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%13 = call i32 @td_random(double* %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
%15 = call i32 @td_write_doubles(double* %12)
%16 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%17 = call i32 @td_random(double* %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%19 = call i32 @td_write_doubles(double* %16)
%20 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%21 = call i32 @td_add(double* %12, double* %16, double* %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.9, i64 0, i64 0))
%23 = call i32 @td_write_doubles(double* %20)
%24 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%25 = call i32 @td_sub(double* %20, double* %12, double* %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
%27 = call i32 @td_write_doubles(double* %24)
%28 = call i32 @td_mul(double* %12, double* %16, double* %20)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.11, i64 0, i64 0))
%30 = call i32 @td_write_doubles(double* %20)
%31 = call i32 @td_div(double* %20, double* %12, double* %24)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
%33 = call i32 @td_write_doubles(double* %24)
ret i32 0
}