#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 */
scalar_t__ fabsf(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, float, int, float, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ translate(float *, double, double, double);
bool test_translate() {
  bool result = true;
  float f[16];
  translate(f, -1.0, 2.0, 3.0);
  float e[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,
               0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 2.0f, 3.0f, 1.0f};
  for (int i = 0; i < 16; i++) {
    while (fabsf((e)[i] - (f)[i]) > fabsf(0.01 * (e)[i])) {
      fprintf(stderr,
              "compare failed: value:    "
              "%f ("
              "f"
              "[%d])\n"
              "                expected: "
              "%f ("
              "e"
              "[%d])\n",
              (f)[i], i, (e)[i], i);
      result = false;
      break;
    };
  }
  return result;
}


x86 assembly (clang, -O0):
<test_translate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x1,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
movsd  0xea2(%rip),%xmm0
movsd  0xea2(%rip),%xmm1
movsd  0xea2(%rip),%xmm2
call   1060 <translate@plt>
lea    -0x90(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x10,-0x94(%rbp)
jge    126a <test_translate+0x12a>
jmp    11a7 <test_translate+0x67>
movslq -0x94(%rbp),%rax
movss  -0x90(%rbp,%rax,4),%xmm0
ff ff
movslq -0x94(%rbp),%rax
subss  -0x50(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <fabsf@plt>
mov    %rax,-0xa0(%rbp)
movslq -0x94(%rbp),%rax
movss  -0x90(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm1
movsd  0xe28(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <fabsf@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
cmp    %rcx,%rax
jle    1251 <test_translate+0x111>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
movslq -0x94(%rbp),%rax
movss  -0x50(%rbp,%rax,4),%xmm0
mov    -0x94(%rbp),%edx
movslq -0x94(%rbp),%rax
movss  -0x90(%rbp,%rax,4),%xmm1
ff ff
mov    -0x94(%rbp),%ecx
lea    0xe1b(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <test_translate+0x116>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1195 <test_translate+0x55>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_translate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0x10(%rsp),%rdi
movsd  0xeb5(%rip),%xmm0
movsd  0xeb5(%rip),%xmm1
movsd  0xeb5(%rip),%xmm2
call   1050 <translate@plt>
mov    $0x1,%r15d
lea    0xeb3(%rip),%rbp
xor    %ebx,%ebx
mov    0x2e6a(%rip),%r13
lea    0xee3(%rip),%r14
jmp    118e <test_translate+0x5e>
nop
add    $0x1,%rbx
add    $0x4,%rbp
cmp    $0x10,%rbx
je     11e8 <test_translate+0xb8>
movss  0x0(%rbp),%xmm0
movss  %xmm0,0xc(%rsp)
subss  0x10(%rsp,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <fabsf@plt>
mov    %rax,%r12
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe5b(%rip),%xmm0
call   1030 <fabsf@plt>
cmp    %rax,%r12
jle    1180 <test_translate+0x50>
mov    0x0(%r13),%edi
movss  0x10(%rsp,%rbx,4),%xmm0
mov    %r14,%rsi
mov    %ebx,%edx
movss  0xc(%rsp),%xmm1
mov    %ebx,%ecx
call   1040 <fprintf@plt>
xor    %r15d,%r15d
jmp    1180 <test_translate+0x50>
mov    %r15d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test_translate.e = [16 x float] [float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 1.000000e+00]
@stderr = global i32 0
@.str = [75 x i8] c"compare failed: value: %f (f[%d])\0A expected: %f (e[%d])\0A\00"
define i32 @test_translate() {
%1 = alloca i32
%2 = alloca [16 x float]
%3 = alloca [16 x float]
%4 = alloca i32
store i32 1, i32* %1
%5 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 0
%6 = call i32 @translate(float* %5, double -1.000000e+00, double 2.000000e+00, double 3.000000e+00)
%7 = bitcast [16 x float]* %3 to i8*
store i32 0, i32* %4
br label %8
8: ; preds = %46, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %49
11: ; preds = %8
br label %12
12: ; preds = %11
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [16 x float], [16 x float]* %3, i64 0, i64 %14
%16 = load float, float* %15
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 %18
%20 = load float, float* %19
%21 = fsub float %16, %20
%22 = fpext float %21 to double
%23 = call i64 @fabsf(double %22)
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [16 x float], [16 x float]* %3, i64 0, i64 %25
%27 = load float, float* %26
%28 = fpext float %27 to double
%29 = fmul double 1.000000e-02, %28
%30 = call i64 @fabsf(double %29)
%31 = icmp sgt i64 %23, %30
br i1 %31, label %32, label %45
32: ; preds = %12
%33 = load i32, i32* @stderr
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 %35
%37 = load float, float* %36
%38 = load i32, i32* %4
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [16 x float], [16 x float]* %3, i64 0, i64 %40
%42 = load float, float* %41
%43 = load i32, i32* %4
%44 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), float %37, i32 %38, float %42, i32 %43)
store i32 0, i32* %1
br label %45
45: ; preds = %32, %12
br label %46
46: ; preds = %45
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %8
49: ; preds = %8
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@__const.test_translate.e = [16 x float] [float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 1.000000e+00]
@stderr = global i32 0
@.str = [75 x i8] c"compare failed: value: %f (f[%d])\0A expected: %f (e[%d])\0A\00"
define i32 @test_translate() {
%1 = alloca [16 x float]
%2 = bitcast [16 x float]* %1 to i8*
%3 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 0
%4 = call i32 @translate(float* %3, double -1.000000e+00, double 2.000000e+00, double 3.000000e+00)
br label %6
5: ; preds = %25
ret i32 %26
6: ; preds = %0, %25
%7 = phi i64 [ 0, %0 ], [ %27, %25 ]
%8 = phi i32 [ 1, %0 ], [ %26, %25 ]
%9 = getelementptr inbounds [16 x float], [16 x float]* @__const.test_translate.e, i64 0, i64 %7
%10 = load float, float* %9
%11 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 %7
%12 = load float, float* %11
%13 = fsub float %10, %12
%14 = fpext float %13 to double
%15 = call i64 @fabsf(double %14)
%16 = fpext float %10 to double
%17 = fmul double %16, 1.000000e-02
%18 = call i64 @fabsf(double %17)
%19 = icmp sgt i64 %15, %18
br i1 %19, label %20, label %25
20: ; preds = %6
%21 = load i32, i32* @stderr
%22 = load float, float* %11
%23 = trunc i64 %7 to i32
%24 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), float %22, i32 %23, float %10, i32 %23)
br label %25
25: ; preds = %6, %20
%26 = phi i32 [ 0, %20 ], [ %8, %6 ]
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, 16
br i1 %28, label %5, label %6
}