#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*/ Fail(char *, double, char const *, char const *, char *,
                        char *);
int /*<<< orphan*/ Testvsnprintf(char *, int, char const *, double);
scalar_t__ memcmp(char *, char const *, scalar_t__);
scalar_t__ strlen(char const *);
void DoDoubleTest(const char *formatstr, double value, const char *checkstr1,
                  char *checkstr2) {
  char buf[256] = {0};
  Testvsnprintf(buf, 256, formatstr, value);
  if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
      memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) {
    Fail("ERROR: failed to insert %f into \"%s\"\n"
         "Expected \"%s\" or \"%s\", got \"%s\".\n",
         value, formatstr, checkstr1, checkstr2, buf);
  }
}


x86 assembly (clang, -O0):
<DoDoubleTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movsd  -0x10(%rbp),%xmm0
mov    $0x100,%esi
call   1050 <Testvsnprintf@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x130(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1249 <DoDoubleTest+0xf9>
lea    -0x120(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x140(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1249 <DoDoubleTest+0xf9>
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x120(%rbp),%r8
lea    0xdbc(%rip),%rdi
call   1070 <Fail@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoDoubleTest>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xorps  %xmm1,%xmm1
movaps %xmm1,0x100(%rsp)
movaps %xmm1,0xf0(%rsp)
movaps %xmm1,0xe0(%rsp)
movaps %xmm1,0xd0(%rsp)
movaps %xmm1,0xc0(%rsp)
movaps %xmm1,0xb0(%rsp)
movaps %xmm1,0xa0(%rsp)
movaps %xmm1,0x90(%rsp)
movaps %xmm1,0x80(%rsp)
movaps %xmm1,0x70(%rsp)
movaps %xmm1,0x60(%rsp)
movaps %xmm1,0x50(%rsp)
movaps %xmm1,0x40(%rsp)
movaps %xmm1,0x30(%rsp)
movaps %xmm1,0x20(%rsp)
movaps %xmm1,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
movsd  %xmm0,0x8(%rsp)
call   1040 <Testvsnprintf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <memcmp@plt>
test   %rax,%rax
je     123a <DoDoubleTest+0xfa>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
lea    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1050 <memcmp@plt>
test   %rax,%rax
je     123a <DoDoubleTest+0xfa>
lea    0xddf(%rip),%rdi
lea    0x10(%rsp),%r8
movsd  0x8(%rsp),%xmm0
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1060 <Fail@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [71 x i8] c"ERROR: failed to insert %f into \22%s\22\0AExpected \22%s\22 or \22%s\22, got \22%s\22.\0A\00"
define void @DoDoubleTest(i8* %0, double %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [256 x i8]
store i8* %0, i8** %5
store double %1, double* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = bitcast [256 x i8]* %9 to i8*
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %5
%13 = load double, double* %6
%14 = call i32 @Testvsnprintf(i8* %11, i32 256, i8* %12, double %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%16 = load i8*, i8** %7
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
%19 = add nsw i64 %18, 1
%20 = call i64 @memcmp(i8* %15, i8* %16, i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %37
22: ; preds = %4
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%24 = load i8*, i8** %8
%25 = load i8*, i8** %8
%26 = call i64 @strlen(i8* %25)
%27 = add nsw i64 %26, 1
%28 = call i64 @memcmp(i8* %23, i8* %24, i64 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %22
%31 = load double, double* %6
%32 = load i8*, i8** %5
%33 = load i8*, i8** %7
%34 = load i8*, i8** %8
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%36 = call i32 @Fail(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), double %31, i8* %32, i8* %33, i8* %34, i8* %35)
br label %37
37: ; preds = %30, %22, %4
ret void
}

LLVM IR (-O2):
@.str = [71 x i8] c"ERROR: failed to insert %f into \22%s\22\0AExpected \22%s\22 or \22%s\22, got \22%s\22.\0A\00"
define void @DoDoubleTest(i8* %0, double %1, i8* %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i32 @Testvsnprintf(i8* %6, i32 256, i8* %0, double %1)
%8 = call i64 @strlen(i8* dereferenceable(1) %2)
%9 = add nsw i64 %8, 1
%10 = call i64 @memcmp(i8* %6, i8* %2, i64 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %4
%13 = call i64 @strlen(i8* dereferenceable(1) %3)
%14 = add nsw i64 %13, 1
%15 = call i64 @memcmp(i8* %6, i8* %3, i64 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 @Fail(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), double %1, i8* %0, i8* %2, i8* %3, i8* %6)
br label %19
19: ; preds = %17, %12, %4
ret void
}