#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*/ dm_FailVariation();
int /*<<< orphan*/ dm_LogPrintf(int, char *, char *, int, ...);
int /*<<< orphan*/ dm_PassVariation();
int errno;
void dm_EndVariation_FailureExpected(char *funcname, int expectedRC,
                                     int actualRC, int expectedErrno) {
  if (actualRC == expectedRC) {
    if (errno == expectedErrno) {
      dm_LogPrintf(3,
                   "%s passed with expected rc = %d and expected errno = %d\n",
                   funcname, expectedRC, expectedErrno);
      dm_PassVariation();
    } else {
      dm_LogPrintf(1,
                   "%s failed with expected rc = %d but unexpected errno = %d "
                   "(expected %d)\n",
                   funcname, expectedRC, errno, expectedErrno);
      dm_FailVariation();
    }
  } else {
    dm_LogPrintf(1, "%s failed with unexpected rc = %d\n", funcname, actualRC);
    dm_FailVariation();
  }
}


x86 assembly (clang, -O0):
<dm_EndVariation_FailureExpected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11c1 <dm_EndVariation_FailureExpected+0x91>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jne    118d <dm_EndVariation_FailureExpected+0x5d>
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    $0x3,%edi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <dm_LogPrintf@plt>
mov    $0x0,%al
call   1050 <dm_PassVariation@plt>
jmp    11bc <dm_EndVariation_FailureExpected+0x8c>
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    0x2e45(%rip),%rax
mov    (%rax),%r8d
mov    -0x14(%rbp),%r9d
mov    $0x1,%edi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <dm_LogPrintf@plt>
mov    $0x0,%al
call   1040 <dm_FailVariation@plt>
jmp    11e2 <dm_EndVariation_FailureExpected+0xb2>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    $0x1,%edi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <dm_LogPrintf@plt>
mov    $0x0,%al
call   1040 <dm_FailVariation@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dm_EndVariation_FailureExpected>:
push   %rax
mov    %ecx,%r9d
mov    %edx,%ecx
mov    %rdi,%rdx
cmp    %esi,%ecx
jne    116a <dm_EndVariation_FailureExpected+0x3a>
mov    0x2e9c(%rip),%rax
mov    (%rax),%r8d
cmp    %r9d,%r8d
jne    117f <dm_EndVariation_FailureExpected+0x4f>
lea    0xead(%rip),%rsi
mov    $0x3,%edi
mov    %r9d,%r8d
xor    %eax,%eax
call   1030 <dm_LogPrintf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <dm_PassVariation@plt>
lea    0xf11(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <dm_LogPrintf@plt>
jmp    1192 <dm_EndVariation_FailureExpected+0x62>
lea    0xeb3(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <dm_LogPrintf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <dm_FailVariation@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [57 x i8] c"%s passed with expected rc = %d and expected errno = %d\0A\00"
@.str.1 = [73 x i8] c"%s failed with expected rc = %d but unexpected errno = %d (expected %d)\0A\00"
@.str.2 = [35 x i8] c"%s failed with unexpected rc = %d\0A\00"
define void @dm_EndVariation_FailureExpected(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %4
%13 = load i32, i32* @errno
%14 = load i32, i32* %8
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = load i32, i32* %8
%20 = call i32 (i32, i8*, i8*, i32, ...) @dm_LogPrintf(i32 3, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18, i32 %19)
%21 = call i32 (...) @dm_PassVariation()
br label %29
22: ; preds = %12
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = load i32, i32* @errno
%26 = load i32, i32* %8
%27 = call i32 (i32, i8*, i8*, i32, ...) @dm_LogPrintf(i32 1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %24, i32 %25, i32 %26)
%28 = call i32 (...) @dm_FailVariation()
br label %29
29: ; preds = %22, %16
br label %35
30: ; preds = %4
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = call i32 (i32, i8*, i8*, i32, ...) @dm_LogPrintf(i32 1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %31, i32 %32)
%34 = call i32 (...) @dm_FailVariation()
br label %35
35: ; preds = %30, %29
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [57 x i8] c"%s passed with expected rc = %d and expected errno = %d\0A\00"
@.str.1 = [73 x i8] c"%s failed with expected rc = %d but unexpected errno = %d (expected %d)\0A\00"
@.str.2 = [35 x i8] c"%s failed with unexpected rc = %d\0A\00"
define void @dm_EndVariation_FailureExpected(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, %1
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = load i32, i32* @errno
%8 = icmp eq i32 %7, %3
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 (i32, i8*, i8*, i32, ...) @dm_LogPrintf(i32 3, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i32 %3)
%11 = tail call i32 (...) @dm_PassVariation()
br label %18
12: ; preds = %6
%13 = tail call i32 (i32, i8*, i8*, i32, ...) @dm_LogPrintf(i32 1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %2, i32 %7, i32 %3)
%14 = tail call i32 (...) @dm_FailVariation()
br label %18
15: ; preds = %4
%16 = tail call i32 (i32, i8*, i8*, i32, ...) @dm_LogPrintf(i32 1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %2)
%17 = tail call i32 (...) @dm_FailVariation()
br label %18
18: ; preds = %9, %12, %15
ret void
}