#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 diff_buffer_float(int, float *, float *);
int /*<<< orphan*/ printf(char *, char *, ...);
void test_buffer_diff_float(int size, float *a, float *b, char *test_name) {
  float diff = diff_buffer_float(size, a, b);
  if (diff != 0.0) {
    printf("\n\nERROR in %s: diff = %f\n\n", test_name, diff);
  } else {
    printf("%s PASSED\n", test_name);
  }
}


x86 assembly (clang, -O0):
<test_buffer_diff_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <diff_buffer_float@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116d <test_buffer_diff_float+0x4d>
jp     116d <test_buffer_diff_float+0x4d>
jmp    118d <test_buffer_diff_float+0x6d>
mov    -0x20(%rbp),%rsi
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    119f <test_buffer_diff_float+0x7f>
mov    -0x20(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_buffer_diff_float>:
push   %rbx
mov    %rcx,%rbx
call   1040 <diff_buffer_float@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1133 <test_buffer_diff_float+0x13>
jnp    1149 <test_buffer_diff_float+0x29>
cvtss2sd %xmm0,%xmm0
lea    0xec2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
pop    %rbx
jmp    1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"\0A\0AERROR in %s: diff = %f\0A\0A\00"
@.str.1 = [11 x i8] c"%s PASSED\0A\00"
define void @test_buffer_diff_float(i32 %0, float* %1, float* %2, i8* %3) {
%5 = alloca i32
%6 = alloca float*
%7 = alloca float*
%8 = alloca i8*
%9 = alloca float
store i32 %0, i32* %5
store float* %1, float** %6
store float* %2, float** %7
store i8* %3, i8** %8
%10 = load i32, i32* %5
%11 = load float*, float** %6
%12 = load float*, float** %7
%13 = call float @diff_buffer_float(i32 %10, float* %11, float* %12)
store float %13, float* %9
%14 = load float, float* %9
%15 = fpext float %14 to double
%16 = fcmp une double %15, 0.000000e+00
br i1 %16, label %17, label %22
17: ; preds = %4
%18 = load i8*, i8** %8
%19 = load float, float* %9
%20 = fpext float %19 to double
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18, double %20)
br label %25
22: ; preds = %4
%23 = load i8*, i8** %8
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %17
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"\0A\0AERROR in %s: diff = %f\0A\0A\00"
@.str.1 = [11 x i8] c"%s PASSED\0A\00"
define void @test_buffer_diff_float(i32 %0, float* %1, float* %2, i8* %3) {
%5 = tail call float @diff_buffer_float(i32 %0, float* %1, float* %2)
%6 = fcmp une float %5, 0.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = fpext float %5 to double
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %3, double %8)
br label %12
10: ; preds = %4
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %12
12: ; preds = %10, %7
ret void
}