#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 *, ...);
scalar_t__ memcmp(char *, char const *, scalar_t__);
scalar_t__ strlen(char *);
int /*<<< orphan*/ testvsp(char *, char const *, int *);
void DoTest(const char *formatstr, int param, const char *checkstr) {
  char buf[256] = {0};
  int n = -1;
  testvsp(buf, formatstr, &n);
  if (n != param) {
    Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", param,
         n);
  }
  if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) {
    Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf);
  }
}


x86 assembly (clang, -O0):
<DoTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movl   $0xffffffff,-0x124(%rbp)
ff ff ff
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x124(%rbp),%rdx
call   1030 <testvsp@plt>
mov    -0x124(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11c0 <DoTest+0x70>
mov    -0xc(%rbp),%esi
mov    -0x124(%rbp),%edx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1070 <Fail@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x138(%rbp),%rdi
mov    -0x130(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1222 <DoTest+0xd2>
mov    -0x18(%rbp),%rsi
lea    -0x120(%rbp),%rdx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1070 <Fail@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoTest>:
push   %rbp
push   %rbx
sub    $0x118,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%rsi
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0xffffffff,0xc(%rsp)
ff
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1030 <testvsp@plt>
mov    0xc(%rsp),%edx
cmp    %ebp,%edx
je     11ee <DoTest+0xae>
lea    0xe1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <Fail@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <memcmp@plt>
test   %rax,%rax
je     1225 <DoTest+0xe5>
lea    0xe24(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <Fail@plt>
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"ERROR: Expected count parameter to resolve to %d, got %X\0A\00"
@.str.1 = [32 x i8] c"ERROR: Expected \22%s\22 got \22%s\22.\0A\00"
define void @DoTest(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [256 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = bitcast [256 x i8]* %7 to i8*
store i32 -1, i32* %8
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @testvsp(i8* %10, i8* %11, i32* %8)
%13 = load i32, i32* %8
%14 = load i32, i32* %5
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = load i32, i32* %5
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
br label %20
20: ; preds = %16, %3
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%24 = call i64 @strlen(i8* %23)
%25 = add nsw i64 %24, 1
%26 = call i64 @memcmp(i8* %21, i8* %22, i64 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %20
%29 = load i8*, i8** %6
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%31 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
br label %32
32: ; preds = %28, %20
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"ERROR: Expected count parameter to resolve to %d, got %X\0A\00"
@.str.1 = [32 x i8] c"ERROR: Expected \22%s\22 got \22%s\22.\0A\00"
define void @DoTest(i8* %0, i32 %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
store i32 -1, i32* %5
%8 = call i32 @testvsp(i8* %6, i8* %0, i32* %5)
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, %1
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %9)
br label %13
13: ; preds = %11, %3
%14 = call i64 @strlen(i8* %6)
%15 = add nsw i64 %14, 1
%16 = call i64 @memcmp(i8* %6, i8* %2, i64 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %6)
br label %20
20: ; preds = %18, %13
ret void
}