#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*/ swap(int *, int *);
int /*<<< orphan*/ swap_bits(int *, int *);
int test_positive_negative() {
  int a = 10;
  int b = -20;
  swap(&a, &b);
  int c = 30;
  int d = -40;
  swap_bits(&c, &d);
  return a == -20 && b == 10 && c == -40 && d == 30;
}


x86 assembly (clang, -O0):
<test_positive_negative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x4(%rbp)
movl   $0xffffffec,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <swap@plt>
movl   $0x1e,-0xc(%rbp)
movl   $0xffffffd8,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <swap_bits@plt>
xor    %eax,%eax
cmpl   $0xffffffec,-0x4(%rbp)
mov    %al,-0x11(%rbp)
jne    1195 <test_positive_negative+0x75>
xor    %eax,%eax
cmpl   $0xa,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jne    1195 <test_positive_negative+0x75>
xor    %eax,%eax
cmpl   $0xffffffd8,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jne    1195 <test_positive_negative+0x75>
cmpl   $0x1e,-0x10(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_positive_negative>:
sub    $0x18,%rsp
movl   $0xa,0x14(%rsp)
movl   $0xffffffec,0x10(%rsp)
ff
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <swap@plt>
movl   $0x1e,0xc(%rsp)
movl   $0xffffffd8,0x8(%rsp)
ff
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <swap_bits@plt>
mov    0x14(%rsp),%eax
xor    $0xffffffec,%eax
mov    0x10(%rsp),%ecx
xor    $0xa,%ecx
or     %eax,%ecx
mov    0xc(%rsp),%edx
xor    $0xffffffd8,%edx
or     %ecx,%edx
mov    0x8(%rsp),%ecx
xor    $0x1e,%ecx
xor    %eax,%eax
or     %edx,%ecx
sete   %al
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @test_positive_negative() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 10, i32* %1
store i32 -20, i32* %2
%5 = call i32 @swap(i32* %1, i32* %2)
store i32 30, i32* %3
store i32 -40, i32* %4
%6 = call i32 @swap_bits(i32* %3, i32* %4)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, -20
br i1 %8, label %9, label %18
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, -40
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 30
br label %18
18: ; preds = %15, %12, %9, %0
%19 = phi i1 [ false, %12 ], [ false, %9 ], [ false, %0 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
define i32 @test_positive_negative() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 10, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 -20, i32* %2
%7 = call i32 @swap(i32* %1, i32* %2)
%8 = bitcast i32* %3 to i8*
store i32 30, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 -40, i32* %4
%10 = call i32 @swap_bits(i32* %3, i32* %4)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, -20
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 10
%15 = select i1 %12, i1 %14, i1 false
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, -40
%18 = select i1 %15, i1 %17, i1 false
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 30
%21 = select i1 %18, i1 %20, i1 false
%22 = zext i1 %21 to i32
ret i32 %22
}