#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_SHARED;
int /*<<< orphan*/ ksft_exit_fail_msg(char *, int);
int /*<<< orphan*/ ksft_test_result_pass(char *, int);
scalar_t__ sys_membarrier(int, int);
int test_membarrier_success(void) {
  int cmd = MEMBARRIER_CMD_SHARED, flags = 0;
  const char *test_name = "sys membarrier MEMBARRIER_CMD_SHARED\n";
  if (sys_membarrier(cmd, flags) != 0) {
    ksft_exit_fail_msg(
        "sys membarrier MEMBARRIER_CMD_SHARED test: flags = %d\n", flags);
  }
  ksft_test_result_pass(
      "sys membarrier MEMBARRIER_CMD_SHARED test: flags = %d\n", flags);
  return 0;
}


x86 assembly (clang, -O0):
<test_membarrier_success>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <sys_membarrier@plt>
cmp    $0x0,%rax
je     117a <test_membarrier_success+0x4a>
mov    -0x8(%rbp),%esi
lea    0xeb1(%rip),%rdi
call   1040 <ksft_exit_fail_msg@plt>
mov    -0x8(%rbp),%esi
lea    0xea2(%rip),%rdi
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_membarrier_success>:
push   %rax
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <sys_membarrier@plt>
test   %rax,%rax
je     1154 <test_membarrier_success+0x24>
lea    0xeb3(%rip),%rdi
xor    %esi,%esi
call   1040 <ksft_exit_fail_msg@plt>
lea    0xea5(%rip),%rdi
xor    %esi,%esi
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@MEMBARRIER_CMD_SHARED = global i32 0
@.str = [38 x i8] c"sys membarrier MEMBARRIER_CMD_SHARED\0A\00"
@.str.1 = [55 x i8] c"sys membarrier MEMBARRIER_CMD_SHARED test: flags = %d\0A\00"
define i32 @test_membarrier_success() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = load i32, i32* @MEMBARRIER_CMD_SHARED
store i32 %4, i32* %1
store i32 0, i32* %2
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = call i64 @sys_membarrier(i32 %5, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* %2
%11 = call i32 @ksft_exit_fail_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %0
%13 = load i32, i32* %2
%14 = call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %13)
ret i32 0
}

LLVM IR (-O2):
@MEMBARRIER_CMD_SHARED = global i32 0
@.str.1 = [55 x i8] c"sys membarrier MEMBARRIER_CMD_SHARED test: flags = %d\0A\00"
define i32 @test_membarrier_success() {
%1 = load i32, i32* @MEMBARRIER_CMD_SHARED
%2 = tail call i64 @sys_membarrier(i32 %1, i32 0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @ksft_exit_fail_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %6
6: ; preds = %4, %0
%7 = tail call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 0)
ret i32 0
}