#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 */
char *getbinary(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int n = 3, i, v;
  int count = 1 << 3;
  for (i = 0; i < count; ++i) {
    v = (i >> 1) ^ i;
    printf("#%i: %s (%d)\n", i, getbinary(v, n), v);
  }
  printf("%s\n", getbinary(281474976710656, 0));
  printf("%s\n", getbinary(28147497671065, 0));
  printf("%s\n", getbinary(3, 0));
  printf("%s\n", getbinary(25, 0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x8,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1192 <main+0x72>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <getbinary@plt>
mov    -0x18(%rbp),%esi
mov    %rax,%rdx
mov    -0x10(%rbp),%ecx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <main+0x24>
xor    %esi,%esi
mov    %esi,%edi
call   1040 <getbinary@plt>
mov    %rax,%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x99999999,%edi
xor    %esi,%esi
call   1040 <getbinary@plt>
mov    %rax,%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1040 <getbinary@plt>
mov    %rax,%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x19,%edi
xor    %esi,%esi
call   1040 <getbinary@plt>
mov    %rax,%rsi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
lea    0xebc(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %rax,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %rax,%rdx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %rax,%rdx
mov    $0x2,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x6,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %rax,%rdx
mov    $0x6,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x7,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %rax,%rdx
mov    $0x7,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x5,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %rax,%rdx
mov    $0x5,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x4,%edi
mov    $0x3,%esi
call   1050 <getbinary@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %rax,%rdx
mov    $0x4,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <getbinary@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    $0x99999999,%edi
xor    %esi,%esi
call   1050 <getbinary@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1050 <getbinary@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    $0x19,%edi
xor    %esi,%esi
call   1050 <getbinary@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"#%i: %s (%d)\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 8, i32* %5
store i32 0, i32* %3
br label %6
6: ; preds = %21, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %5
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i32, i32* %3
%12 = ashr i32 %11, 1
%13 = load i32, i32* %3
%14 = xor i32 %12, %13
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = call i8* @getbinary(i32 %16, i32 %17)
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %18, i32 %19)
br label %21
21: ; preds = %10
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %6
24: ; preds = %6
%25 = call i8* @getbinary(i32 0, i32 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = call i8* @getbinary(i32 -1717986919, i32 0)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i8* @getbinary(i32 3, i32 0)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = call i8* @getbinary(i32 25, i32 0)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"#%i: %s (%d)\0A\00"
define i32 @main() {
%1 = tail call i8* @getbinary(i32 0, i32 3)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i8* %1, i32 0)
%3 = tail call i8* @getbinary(i32 1, i32 3)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1, i8* %3, i32 1)
%5 = tail call i8* @getbinary(i32 3, i32 3)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 2, i8* %5, i32 3)
%7 = tail call i8* @getbinary(i32 2, i32 3)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 3, i8* %7, i32 2)
%9 = tail call i8* @getbinary(i32 6, i32 3)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 4, i8* %9, i32 6)
%11 = tail call i8* @getbinary(i32 7, i32 3)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 5, i8* %11, i32 7)
%13 = tail call i8* @getbinary(i32 5, i32 3)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 6, i8* %13, i32 5)
%15 = tail call i8* @getbinary(i32 4, i32 3)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 7, i8* %15, i32 4)
%17 = tail call i8* @getbinary(i32 0, i32 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
%19 = tail call i8* @getbinary(i32 -1717986919, i32 0)
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
%21 = tail call i8* @getbinary(i32 3, i32 0)
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
%23 = tail call i8* @getbinary(i32 25, i32 0)
%24 = tail call i32 @puts(i8* dereferenceable(1) %23)
ret i32 0
}