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


x86 assembly (clang, -O0):
<DoArgumentPrecTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1060 <sprintf@plt>
lea    -0x130(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x140(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     122f <DoArgumentPrecTest+0xef>
lea    -0x130(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x150(%rbp),%rdi
mov    -0x148(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     122f <DoArgumentPrecTest+0xef>
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    -0x130(%rbp),%rax
lea    0xdda(%rip),%rdi
mov    %rax,(%rsp)
call   1050 <Fail@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoArgumentPrecTest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r9,%r14
mov    %r8,%rbx
mov    %rcx,0x8(%rsp)
mov    %rdx,%rcx
mov    %esi,%r12d
mov    %rdi,%r15
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <memcmp@plt>
test   %rax,%rax
je     11d6 <DoArgumentPrecTest+0x96>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <memcmp@plt>
test   %rax,%rax
je     11d6 <DoArgumentPrecTest+0x96>
mov    %r13,(%rsp)
lea    0xe40(%rip),%rdi
mov    0x8(%rsp),%rsi
mov    %r15,%rdx
mov    %r12d,%ecx
mov    %rbx,%r8
mov    %r14,%r9
call   1050 <Fail@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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