#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__ Float2Int(float);
float Fminf(float, float);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, float, float, float, float);
void TestMin(float a, float b, float ret) {
  float x = Fminf(a, b);
  if (x != ret)
    printf("min(%f, %f) returned %f, should return ret: %f\n", a, b, x, ret);
  assert(Float2Int(x) == Float2Int(ret));
  float y = Fminf(b, a);
  if (y != ret)
    printf("min(%f, %f) returned %f, should return ret: %f\n", b, a, y, ret);
  assert(Float2Int(y) == Float2Int(ret));
}


x86 assembly (clang, -O0):
<TestMin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1060 <Fminf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1185 <TestMin+0x45>
jp     1185 <TestMin+0x45>
jmp    11a5 <TestMin+0x65>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
call   1050 <Float2Int@plt>
mov    %rax,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <Float2Int@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movss  -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
call   1060 <Fminf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1202 <TestMin+0xc2>
jp     1202 <TestMin+0xc2>
jmp    1222 <TestMin+0xe2>
movss  -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
call   1050 <Float2Int@plt>
mov    %rax,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <Float2Int@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestMin>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm2,0x4(%rsp)
movss  %xmm0,(%rsp)
movss  %xmm1,0x8(%rsp)
call   1060 <Fminf@plt>
movaps %xmm0,%xmm2
ucomiss 0x4(%rsp),%xmm0
jne    1167 <TestMin+0x27>
jnp    1196 <TestMin+0x56>
lea    0xe92(%rip),%rdi
movss  (%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  %xmm2,0xc(%rsp)
movss  0xc(%rsp),%xmm2
movss  0x4(%rsp),%xmm3
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm2
movaps %xmm2,%xmm0
call   1050 <Float2Int@plt>
mov    %rax,%rbx
movss  0x4(%rsp),%xmm0
call   1050 <Float2Int@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1040 <assert@plt>
movss  0x8(%rsp),%xmm0
movss  (%rsp),%xmm1
call   1060 <Fminf@plt>
movaps %xmm0,%xmm2
ucomiss 0x4(%rsp),%xmm0
jne    11d6 <TestMin+0x96>
jnp    1202 <TestMin+0xc2>
lea    0xe23(%rip),%rdi
movss  0x8(%rsp),%xmm0
movss  (%rsp),%xmm1
movss  %xmm2,(%rsp)
movss  (%rsp),%xmm2
movss  0x4(%rsp),%xmm3
call   1030 <printf@plt>
movss  (%rsp),%xmm2
movaps %xmm2,%xmm0
call   1050 <Float2Int@plt>
mov    %rax,%rbx
movss  0x4(%rsp),%xmm0
call   1050 <Float2Int@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
add    $0x10,%rsp
pop    %rbx
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"min(%f, %f) returned %f, should return ret: %f\0A\00"
define void @TestMin(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%9 = load float, float* %4
%10 = load float, float* %5
%11 = call float @Fminf(float %9, float %10)
store float %11, float* %7
%12 = load float, float* %7
%13 = load float, float* %6
%14 = fcmp une float %12, %13
br i1 %14, label %15, label %21
15: ; preds = %3
%16 = load float, float* %4
%17 = load float, float* %5
%18 = load float, float* %7
%19 = load float, float* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), float %16, float %17, float %18, float %19)
br label %21
21: ; preds = %15, %3
%22 = load float, float* %7
%23 = call i64 @Float2Int(float %22)
%24 = load float, float* %6
%25 = call i64 @Float2Int(float %24)
%26 = icmp eq i64 %23, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load float, float* %5
%30 = load float, float* %4
%31 = call float @Fminf(float %29, float %30)
store float %31, float* %8
%32 = load float, float* %8
%33 = load float, float* %6
%34 = fcmp une float %32, %33
br i1 %34, label %35, label %41
35: ; preds = %21
%36 = load float, float* %5
%37 = load float, float* %4
%38 = load float, float* %8
%39 = load float, float* %6
%40 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), float %36, float %37, float %38, float %39)
br label %41
41: ; preds = %35, %21
%42 = load float, float* %8
%43 = call i64 @Float2Int(float %42)
%44 = load float, float* %6
%45 = call i64 @Float2Int(float %44)
%46 = icmp eq i64 %43, %45
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"min(%f, %f) returned %f, should return ret: %f\0A\00"
define void @TestMin(float %0, float %1, float %2) {
%4 = tail call float @Fminf(float %0, float %1)
%5 = fcmp une float %4, %2
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), float %0, float %1, float %4, float %2)
br label %8
8: ; preds = %6, %3
%9 = tail call i64 @Float2Int(float %4)
%10 = tail call i64 @Float2Int(float %2)
%11 = icmp eq i64 %9, %10
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call float @Fminf(float %1, float %0)
%15 = fcmp une float %14, %2
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), float %1, float %0, float %14, float %2)
br label %18
18: ; preds = %16, %8
%19 = tail call i64 @Float2Int(float %14)
%20 = tail call i64 @Float2Int(float %2)
%21 = icmp eq i64 %19, %20
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
ret void
}