#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__ absf(float);
scalar_t__ recipf(float);
scalar_t__ rsqrtf(float);
scalar_t__ sqrtf(float);
int /*<<< orphan*/ writeDigit(int);
int /*<<< orphan*/ writeString(char *);
void testmipsmath() {
  float f1 = -1324.123;
  float f2 = 25;
  float f3 = 0.01;
  writeString("Abs: ");
  writeDigit((int)absf(f1));
  writeString(".\n");
  writeString("Sqrt: ");
  writeDigit((int)sqrtf(f2));
  writeString(".\n");
  writeString("Recip: ");
  writeDigit((int)recipf(f3));
  writeString(".\n");
  writeString("Rsqrt: ");
  writeDigit((int)rsqrtf(f3));
  writeString(".\n");
}


x86 assembly (clang, -O0):
<testmipsmath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  0xe98(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xe87(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe76(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xe76(%rip),%rdi
call   1050 <writeString@plt>
movss  -0x4(%rbp),%xmm0
call   1040 <absf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
lea    0xe5f(%rip),%rdi
call   1050 <writeString@plt>
lea    0xe56(%rip),%rdi
call   1050 <writeString@plt>
movss  -0x8(%rbp),%xmm0
call   1060 <sqrtf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
lea    0xe36(%rip),%rdi
call   1050 <writeString@plt>
lea    0xe34(%rip),%rdi
call   1050 <writeString@plt>
movss  -0xc(%rbp),%xmm0
call   1070 <recipf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
lea    0xe0d(%rip),%rdi
call   1050 <writeString@plt>
lea    0xe13(%rip),%rdi
call   1050 <writeString@plt>
movss  -0xc(%rbp),%xmm0
call   1080 <rsqrtf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
lea    0xde4(%rip),%rdi
call   1050 <writeString@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testmipsmath>:
push   %rbx
lea    0xea4(%rip),%rdi
call   1050 <writeString@plt>
movss  0xe8b(%rip),%xmm0
call   1040 <absf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
lea    0xe8a(%rip),%rbx
mov    %rbx,%rdi
call   1050 <writeString@plt>
lea    0xe7e(%rip),%rdi
call   1050 <writeString@plt>
movss  0xe60(%rip),%xmm0
call   1060 <sqrtf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
mov    %rbx,%rdi
call   1050 <writeString@plt>
lea    0xe5d(%rip),%rdi
call   1050 <writeString@plt>
movss  0xe3c(%rip),%xmm0
call   1070 <recipf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
mov    %rbx,%rdi
call   1050 <writeString@plt>
lea    0xe3d(%rip),%rdi
call   1050 <writeString@plt>
movss  0xe14(%rip),%xmm0
call   1080 <rsqrtf@plt>
mov    %eax,%edi
call   1030 <writeDigit@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <writeString@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"Abs: \00"
@.str.1 = [3 x i8] c".\0A\00"
@.str.2 = [7 x i8] c"Sqrt: \00"
@.str.3 = [8 x i8] c"Recip: \00"
@.str.4 = [8 x i8] c"Rsqrt: \00"
define void @testmipsmath() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
store float 0xC094B07E00000000, float* %1
store float 2.500000e+01, float* %2
store float 0x3F847AE140000000, float* %3
%4 = call i32 @writeString(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = load float, float* %1
%6 = call i64 @absf(float %5)
%7 = trunc i64 %6 to i32
%8 = call i32 @writeDigit(i32 %7)
%9 = call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @writeString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = load float, float* %2
%12 = call i64 @sqrtf(float %11)
%13 = trunc i64 %12 to i32
%14 = call i32 @writeDigit(i32 %13)
%15 = call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @writeString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = load float, float* %3
%18 = call i64 @recipf(float %17)
%19 = trunc i64 %18 to i32
%20 = call i32 @writeDigit(i32 %19)
%21 = call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @writeString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%23 = load float, float* %3
%24 = call i64 @rsqrtf(float %23)
%25 = trunc i64 %24 to i32
%26 = call i32 @writeDigit(i32 %25)
%27 = call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"Abs: \00"
@.str.1 = [3 x i8] c".\0A\00"
@.str.2 = [7 x i8] c"Sqrt: \00"
@.str.3 = [8 x i8] c"Recip: \00"
@.str.4 = [8 x i8] c"Rsqrt: \00"
define void @testmipsmath() {
%1 = tail call i32 @writeString(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @absf(float 0xC094B07E00000000)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @writeDigit(i32 %3)
%5 = tail call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @writeString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i64 @sqrtf(float 2.500000e+01)
%8 = trunc i64 %7 to i32
%9 = tail call i32 @writeDigit(i32 %8)
%10 = tail call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @writeString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i64 @recipf(float 0x3F847AE140000000)
%13 = trunc i64 %12 to i32
%14 = tail call i32 @writeDigit(i32 %13)
%15 = tail call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @writeString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i64 @rsqrtf(float 0x3F847AE140000000)
%18 = trunc i64 %17 to i32
%19 = tail call i32 @writeDigit(i32 %18)
%20 = tail call i32 @writeString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}