#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 SWAP_FLAG_PREFER;
int SWAP_FLAG_PRIO_MASK;
int SWAP_FLAG_PRIO_SHIFT;
int /*<<< orphan*/ swapoff(char *);
int /*<<< orphan*/ swapon(char *, int);
int main() {
  swapon("foobar_swap", 0);
  swapon("foobar_swap", ((1 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) |
                            SWAP_FLAG_PREFER);
  swapon("foobar_swap", ((7 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) |
                            SWAP_FLAG_PREFER);
  swapon(0, 0);
  swapon("foobar_swap", -1);
  swapon((char *)-1, SWAP_FLAG_PREFER);
  swapoff("foobar_swap");
  swapoff(0);
  swapoff((char *)-1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %esi,%esi
call   1030 <swapon@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
shl    %cl,%esi
mov    0x2e8c(%rip),%rax
and    (%rax),%esi
mov    0x2e8b(%rip),%rax
or     (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1030 <swapon@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%ecx
mov    $0x7,%esi
shl    %cl,%esi
mov    0x2e5e(%rip),%rax
and    (%rax),%esi
mov    0x2e5d(%rip),%rax
or     (%rax),%esi
lea    0xe6c(%rip),%rdi
call   1030 <swapon@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1030 <swapon@plt>
lea    0xe55(%rip),%rdi
mov    $0xffffffff,%esi
call   1030 <swapon@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffffffffffff,%rdi
call   1030 <swapon@plt>
lea    0xe2f(%rip),%rdi
call   1040 <swapoff@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <swapoff@plt>
mov    $0xffffffffffffffff,%rdi
call   1040 <swapoff@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <swapon@plt>
mov    0x2e90(%rip),%r15
mov    (%r15),%cl
mov    $0x1,%esi
shl    %cl,%esi
mov    0x2e8f(%rip),%r12
and    (%r12),%esi
mov    0x2e8c(%rip),%r14
or     (%r14),%esi
mov    %rbx,%rdi
call   1030 <swapon@plt>
mov    (%r15),%cl
mov    $0x7,%esi
shl    %cl,%esi
and    (%r12),%esi
or     (%r14),%esi
mov    %rbx,%rdi
call   1030 <swapon@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <swapon@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1030 <swapon@plt>
mov    (%r14),%esi
mov    $0xffffffffffffffff,%rdi
call   1030 <swapon@plt>
mov    %rbx,%rdi
call   1040 <swapoff@plt>
xor    %edi,%edi
call   1040 <swapoff@plt>
mov    $0xffffffffffffffff,%rdi
call   1040 <swapoff@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"foobar_swap\00"
@SWAP_FLAG_PRIO_SHIFT = global i32 0
@SWAP_FLAG_PRIO_MASK = global i32 0
@SWAP_FLAG_PREFER = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%3 = load i32, i32* @SWAP_FLAG_PRIO_SHIFT
%4 = shl i32 1, %3
%5 = load i32, i32* @SWAP_FLAG_PRIO_MASK
%6 = and i32 %4, %5
%7 = load i32, i32* @SWAP_FLAG_PREFER
%8 = or i32 %6, %7
%9 = call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @SWAP_FLAG_PRIO_SHIFT
%11 = shl i32 7, %10
%12 = load i32, i32* @SWAP_FLAG_PRIO_MASK
%13 = and i32 %11, %12
%14 = load i32, i32* @SWAP_FLAG_PREFER
%15 = or i32 %13, %14
%16 = call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @swapon(i8* null, i32 0)
%18 = call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 -1)
%19 = load i32, i32* @SWAP_FLAG_PREFER
%20 = call i32 @swapon(i8* inttoptr (i64 -1 to i8*), i32 %19)
%21 = call i32 @swapoff(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @swapoff(i8* null)
%23 = call i32 @swapoff(i8* inttoptr (i64 -1 to i8*))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"foobar_swap\00"
@SWAP_FLAG_PRIO_SHIFT = global i32 0
@SWAP_FLAG_PRIO_MASK = global i32 0
@SWAP_FLAG_PREFER = global i32 0
define i32 @main() {
%1 = tail call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = load i32, i32* @SWAP_FLAG_PRIO_SHIFT
%3 = shl nuw i32 1, %2
%4 = load i32, i32* @SWAP_FLAG_PRIO_MASK
%5 = and i32 %3, %4
%6 = load i32, i32* @SWAP_FLAG_PREFER
%7 = or i32 %5, %6
%8 = tail call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @SWAP_FLAG_PRIO_SHIFT
%10 = shl i32 7, %9
%11 = load i32, i32* @SWAP_FLAG_PRIO_MASK
%12 = and i32 %10, %11
%13 = load i32, i32* @SWAP_FLAG_PREFER
%14 = or i32 %12, %13
%15 = tail call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = tail call i32 @swapon(i8* null, i32 0)
%17 = tail call i32 @swapon(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 -1)
%18 = load i32, i32* @SWAP_FLAG_PREFER
%19 = tail call i32 @swapon(i8* inttoptr (i64 -1 to i8*), i32 %18)
%20 = tail call i32 @swapoff(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @swapoff(i8* null)
%22 = tail call i32 @swapoff(i8* inttoptr (i64 -1 to i8*))
ret i32 0
}