#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 */
typedef int uint64_t;

/* Variables and functions */
int closest_same_weight(int);
int /*<<< orphan*/ printb(int);
int /*<<< orphan*/ printf(char *);
int rand64();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  uint64_t x = rand64();
  printb(x);
  printf("\n");
  uint64_t y = closest_same_weight(x);
  printb(y);
  printf("\n");
  printb(x ^ y);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   1080 <rand64@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <printb@plt>
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <closest_same_weight@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <printb@plt>
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
xor    -0x8(%rbp),%edi
call   1040 <printb@plt>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1080 <rand64@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <printb@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1040 <closest_same_weight@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <printb@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebp
mov    %ebp,%edi
call   1050 <printb@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
%5 = call i32 (...) @rand64()
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @printb(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = call i32 @closest_same_weight(i32 %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 @printb(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = xor i32 %14, %15
%17 = call i32 @printb(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 (...) @rand64()
%4 = tail call i32 @printb(i32 %3)
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 @closest_same_weight(i32 %3)
%7 = tail call i32 @printb(i32 %6)
%8 = tail call i32 @putchar(i32 10)
%9 = xor i32 %6, %3
%10 = tail call i32 @printb(i32 %9)
%11 = tail call i32 @putchar(i32 10)
ret i32 0
}