#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*/ fiolSWriteFloat(char *, double, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void testWriteFloat() {
  char str[7] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0'};
  printf("Testing fiolSWriteFloat...\r\n");
  printf("\t-42.7\r\n");
  fiolSWriteFloat(str, -42.7, 1);
  if (strcmp(str, "-42.7") == 0)
    printf("\t\tPassed!\r\n");
  else
    printf("\t\tfailed, returned '%s' instead of '%s'\r\n", str, "-42.7");
  printf("\t+846.6\r\n");
  fiolSWriteFloat(&(str[0]), +846.6, 2);
  if (strcmp(str, "846.60") == 0)
    printf("\t\tPassed!\r\n");
  else
    printf("\t\tfailed, returned '%s' instead of '%s'\r\n", str, "846.60");
}


x86 assembly (clang, -O0):
<testWriteFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x7(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1040 <memset@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7(%rbp),%rdi
movsd  0xe80(%rip),%xmm0
mov    $0x1,%esi
call   1060 <fiolSWriteFloat@plt>
lea    -0x7(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <testWriteFloat+0x77>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d0 <testWriteFloat+0x90>
lea    -0x7(%rbp),%rsi
lea    0xe86(%rip),%rdi
lea    0xe6d(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7(%rbp),%rdi
movsd  0xe1e(%rip),%xmm0
mov    $0x2,%esi
call   1060 <fiolSWriteFloat@plt>
lea    -0x7(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <testWriteFloat+0xe1>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <testWriteFloat+0xfa>
lea    -0x7(%rbp),%rsi
lea    0xe1c(%rip),%rdi
lea    0xe49(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testWriteFloat>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
movsd  0xe86(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <fiolSWriteFloat@plt>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b7 <testWriteFloat+0x77>
lea    0xe74(%rip),%rdi
lea    0xe67(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c3 <testWriteFloat+0x83>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
movsd  0xe2c(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <fiolSWriteFloat@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1219 <testWriteFloat+0xd9>
lea    0xe12(%rip),%rdi
lea    0xe35(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1225 <testWriteFloat+0xe5>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Testing fiolSWriteFloat...\0D\0A\00"
@.str.1 = [9 x i8] c"\09-42.7\0D\0A\00"
@.str.2 = [6 x i8] c"-42.7\00"
@.str.3 = [12 x i8] c"\09\09Passed!\0D\0A\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%s' instead of '%s'\0D\0A\00"
@.str.5 = [10 x i8] c"\09+846.6\0D\0A\00"
@.str.6 = [7 x i8] c"846.60\00"
define void @testWriteFloat() {
%1 = alloca [7 x i8]
%2 = bitcast [7 x i8]* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%6 = call i32 @fiolSWriteFloat(i8* %5, double -4.270000e+01, i32 1)
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %15
12: ; preds = %0
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %12, %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%18 = call i32 @fiolSWriteFloat(i8* %17, double 8.466000e+02, i32 2)
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %27
24: ; preds = %15
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %24, %22
ret void
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"-42.7\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%s' instead of '%s'\0D\0A\00"
@.str.6 = [7 x i8] c"846.60\00"
@str = [28 x i8] c"Testing fiolSWriteFloat...\0D\00"
@str.7 = [8 x i8] c"\09-42.7\0D\00"
@str.8 = [9 x i8] c"\09+846.6\0D\00"
@str.10 = [11 x i8] c"\09\09Passed!\0D\00"
define void @testWriteFloat() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
%5 = call i32 @fiolSWriteFloat(i8* %2, double -4.270000e+01, i32 1)
%6 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @fiolSWriteFloat(i8* %2, double 8.466000e+02, i32 2)
%15 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
br label %21
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret void
}