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


x86 assembly (clang, -O0):
<test_membarrier_cmd_fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <sys_membarrier@plt>
cmp    $0xffffffff,%eax
je     116c <test_membarrier_cmd_fail+0x3c>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1040 <ksft_exit_fail_msg@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xedf(%rip),%rdi
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_membarrier_cmd_fail>:
push   %rax
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1050 <sys_membarrier@plt>
cmp    $0xffffffff,%eax
je     1155 <test_membarrier_cmd_fail+0x25>
lea    0xeb7(%rip),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1040 <ksft_exit_fail_msg@plt>
lea    0xefc(%rip),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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