#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 MEMBARRIER_CMD_QUERY;
int /*<<< orphan*/ ksft_exit_fail_msg(char *, int);
int /*<<< orphan*/ ksft_test_result_pass(char *, int);
int sys_membarrier(int, int);
int test_membarrier_flags_fail(void) {
  int cmd = MEMBARRIER_CMD_QUERY, flags = 1;
  if (sys_membarrier(cmd, flags) != -1) {
    ksft_exit_fail_msg("sys membarrier MEMBARRIER_CMD_QUERY invalid flags "
                       "test: flags = %d. Should fail, but passed\n",
                       flags);
  }
  ksft_test_result_pass("sys membarrier MEMBARRIER_CMD_QUERY invalid flags "
                        "test: flags = %d. Failed as expected\n",
                        flags);
  return 0;
}


x86 assembly (clang, -O0):
<test_membarrier_flags_fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <sys_membarrier@plt>
cmp    $0xffffffff,%eax
je     116e <test_membarrier_flags_fail+0x3e>
mov    -0x8(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1040 <ksft_exit_fail_msg@plt>
mov    -0x8(%rbp),%esi
lea    0xee5(%rip),%rdi
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_membarrier_flags_fail>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1050 <sys_membarrier@plt>
cmp    $0xffffffff,%eax
je     115a <test_membarrier_flags_fail+0x2a>
lea    0xeb0(%rip),%rdi
mov    $0x1,%esi
call   1040 <ksft_exit_fail_msg@plt>
lea    0xefc(%rip),%rdi
mov    $0x1,%esi
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@MEMBARRIER_CMD_QUERY = global i32 0
@.str = [93 x i8] c"sys membarrier MEMBARRIER_CMD_QUERY invalid flags test: flags = %d. Should fail, but passed\0A\00"
@.str.1 = [88 x i8] c"sys membarrier MEMBARRIER_CMD_QUERY invalid flags test: flags = %d. Failed as expected\0A\00"
define i32 @test_membarrier_flags_fail() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @MEMBARRIER_CMD_QUERY
store i32 %3, i32* %1
store i32 1, i32* %2
%4 = load i32, i32* %1
%5 = load i32, i32* %2
%6 = call i32 @sys_membarrier(i32 %4, i32 %5)
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* %2
%10 = call i32 @ksft_exit_fail_msg(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* %2
%13 = call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret i32 0
}

LLVM IR (-O2):
@MEMBARRIER_CMD_QUERY = global i32 0
@.str = [93 x i8] c"sys membarrier MEMBARRIER_CMD_QUERY invalid flags test: flags = %d. Should fail, but passed\0A\00"
@.str.1 = [88 x i8] c"sys membarrier MEMBARRIER_CMD_QUERY invalid flags test: flags = %d. Failed as expected\0A\00"
define i32 @test_membarrier_flags_fail() {
%1 = load i32, i32* @MEMBARRIER_CMD_QUERY
%2 = tail call i32 @sys_membarrier(i32 %1, i32 1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @ksft_exit_fail_msg(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0), i32 1)
br label %6
6: ; preds = %4, %0
%7 = tail call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret i32 0
}