#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 bit_swap(int);
int test_bit_swap() {
  return 0b1111 == bit_swap(0b1111) && 0b1010 == bit_swap(0b0101) &&
         0b1110 == bit_swap(0b1101) && 0 == bit_swap(0) & ~0 == bit_swap(~0);
}


x86 assembly (clang, -O0):
<test_bit_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xf,%edi
call   1030 <bit_swap@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xf,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11b4 <test_bit_swap+0xa4>
mov    $0x5,%edi
call   1030 <bit_swap@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xa,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11b4 <test_bit_swap+0xa4>
mov    $0xd,%edi
call   1030 <bit_swap@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xe,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11b4 <test_bit_swap+0xa4>
xor    %edi,%edi
call   1030 <bit_swap@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
mov    $0xffffffff,%edi
call   1030 <bit_swap@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%eax
mov    $0xffffffff,%ecx
cmp    %edx,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bit_swap>:
push   %rbp
push   %rbx
push   %rax
mov    $0xf,%edi
call   1030 <bit_swap@plt>
xor    %ebx,%ebx
cmp    $0xf,%eax
jne    115e <test_bit_swap+0x4e>
mov    $0x5,%edi
call   1030 <bit_swap@plt>
cmp    $0xa,%eax
jne    115e <test_bit_swap+0x4e>
mov    $0xd,%edi
call   1030 <bit_swap@plt>
cmp    $0xe,%eax
jne    115e <test_bit_swap+0x4e>
xor    %edi,%edi
call   1030 <bit_swap@plt>
mov    %eax,%ebp
mov    $0xffffffff,%edi
call   1030 <bit_swap@plt>
not    %eax
xor    %ebx,%ebx
or     %ebp,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_bit_swap() {
%1 = call i32 @bit_swap(i32 15)
%2 = icmp eq i32 15, %1
br i1 %2, label %3, label %18
3: ; preds = %0
%4 = call i32 @bit_swap(i32 5)
%5 = icmp eq i32 10, %4
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = call i32 @bit_swap(i32 13)
%8 = icmp eq i32 14, %7
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i32 @bit_swap(i32 0)
%11 = icmp eq i32 0, %10
%12 = zext i1 %11 to i32
%13 = call i32 @bit_swap(i32 -1)
%14 = icmp eq i32 -1, %13
%15 = zext i1 %14 to i32
%16 = and i32 %12, %15
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %9, %6, %3, %0
%19 = phi i1 [ false, %6 ], [ false, %3 ], [ false, %0 ], [ %17, %9 ]
%20 = zext i1 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
define i32 @test_bit_swap() {
%1 = tail call i32 @bit_swap(i32 15)
%2 = icmp eq i32 %1, 15
br i1 %2, label %3, label %16
3: ; preds = %0
%4 = tail call i32 @bit_swap(i32 5)
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = tail call i32 @bit_swap(i32 13)
%8 = icmp eq i32 %7, 14
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i32 @bit_swap(i32 0)
%11 = icmp eq i32 %10, 0
%12 = tail call i32 @bit_swap(i32 -1)
%13 = icmp eq i32 %12, -1
%14 = and i1 %11, %13
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %9, %6, %3, %0
%17 = phi i32 [ 0, %6 ], [ 0, %3 ], [ 0, %0 ], [ %15, %9 ]
ret i32 %17
}