#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*/ fiolSWriteDouble(char *, double, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void testWriteDouble() {
  char str[7] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0'};
  printf("Testing fiolSWriteDouble...\r\n");
  printf("\t-42.7\r\n");
  fiolSWriteDouble(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");
  fiolSWriteDouble(&(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):
<testWriteDouble>:
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    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7(%rbp),%rdi
movsd  0xe80(%rip),%xmm0
mov    $0x1,%esi
call   1060 <fiolSWriteDouble@plt>
lea    -0x7(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <testWriteDouble+0x77>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d0 <testWriteDouble+0x90>
lea    -0x7(%rbp),%rsi
lea    0xe87(%rip),%rdi
lea    0xe6e(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7(%rbp),%rdi
movsd  0xe1e(%rip),%xmm0
mov    $0x2,%esi
call   1060 <fiolSWriteDouble@plt>
lea    -0x7(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <testWriteDouble+0xe1>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <testWriteDouble+0xfa>
lea    -0x7(%rbp),%rsi
lea    0xe1d(%rip),%rdi
lea    0xe4a(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [30 x i8] c"Testing fiolSWriteDouble...\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 @testWriteDouble() {
%1 = alloca [7 x i8]
%2 = bitcast [7 x i8]* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 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 @fiolSWriteDouble(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 @fiolSWriteDouble(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 = [29 x i8] c"Testing fiolSWriteDouble...\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 @testWriteDouble() {
%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 ([29 x i8], [29 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 @fiolSWriteDouble(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 @fiolSWriteDouble(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
}