#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*/ printBin(int);
int /*<<< orphan*/ printf(char *, int);
void printTwoSetBitNums(int n) {
  int x = 1;
  int num;
  while (n > 0) {
    int y = 0;
    while (y < x) {
      num = (1 << x) + (1 << y);
      printBin(1 << x);
      printf(" %d \n", 1 << x);
      printBin(1 << y);
      printf(" %d \n---\n", 1 << y);
      printBin(num);
      printf(" %d \n\n", num);
      n--;
      if (n == 0)
        return;
      y++;
    }
    x++;
  }
}


x86 assembly (clang, -O0):
<printTwoSetBitNums>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11ff <printTwoSetBitNums+0xdf>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f1 <printTwoSetBitNums+0xd1>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1030 <printBin@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1030 <printBin@plt>
mov    -0x10(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1030 <printBin@plt>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11e3 <printTwoSetBitNums+0xc3>
jmp    11ff <printTwoSetBitNums+0xdf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <printTwoSetBitNums+0x23>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <printTwoSetBitNums+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTwoSetBitNums>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %edi,%edi
jle    11d9 <printTwoSetBitNums+0xb9>
mov    $0x1,%ebp
mov    $0x1,%r14d
mov    %ebp,%ecx
shl    %cl,%r14d
mov    (%rsp),%rax
lea    -0x1(%rax),%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r15d
mov    %ebx,%ecx
shl    %cl,%r15d
lea    (%r15,%r14,1),%r12d
mov    %r14d,%edi
call   1030 <printBin@plt>
lea    0xe82(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    %r15d,%edi
call   1030 <printBin@plt>
lea    0xe71(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    %r12d,%edi
call   1030 <printBin@plt>
lea    0xe64(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
cmp    %ebx,%r13d
je     11d9 <printTwoSetBitNums+0xb9>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1160 <printTwoSetBitNums+0x40>
add    $0x1,%ebp
mov    (%rsp),%rax
sub    %ebx,%eax
mov    %rax,(%rsp)
add    $0x1,%eax
cmp    $0x1,%eax
jg     113c <printTwoSetBitNums+0x1c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" %d \0A\00"
@.str.1 = [10 x i8] c" %d \0A---\0A\00"
@.str.2 = [7 x i8] c" %d \0A\0A\00"
define void @printTwoSetBitNums(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %44, %1
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %47
9: ; preds = %6
store i32 0, i32* %5
br label %10
10: ; preds = %41, %9
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %44
14: ; preds = %10
%15 = load i32, i32* %3
%16 = shl i32 1, %15
%17 = load i32, i32* %5
%18 = shl i32 1, %17
%19 = add nsw i32 %16, %18
store i32 %19, i32* %4
%20 = load i32, i32* %3
%21 = shl i32 1, %20
%22 = call i32 @printBin(i32 %21)
%23 = load i32, i32* %3
%24 = shl i32 1, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %5
%27 = shl i32 1, %26
%28 = call i32 @printBin(i32 %27)
%29 = load i32, i32* %5
%30 = shl i32 1, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %4
%33 = call i32 @printBin(i32 %32)
%34 = load i32, i32* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %2
%37 = add nsw i32 %36, -1
store i32 %37, i32* %2
%38 = load i32, i32* %2
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %14
br label %47
41: ; preds = %14
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %10
44: ; preds = %10
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %6
47: ; preds = %40, %6
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" %d \0A\00"
@.str.1 = [10 x i8] c" %d \0A---\0A\00"
@.str.2 = [7 x i8] c" %d \0A\0A\00"
define void @printTwoSetBitNums(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %26
3: ; preds = %1, %23
%4 = phi i32 [ %20, %23 ], [ %0, %1 ]
%5 = phi i32 [ %24, %23 ], [ 1, %1 ]
%6 = shl nuw i32 1, %5
br label %9
7: ; preds = %9
%8 = icmp eq i32 %22, %5
br i1 %8, label %23, label %9
9: ; preds = %3, %7
%10 = phi i32 [ 0, %3 ], [ %22, %7 ]
%11 = phi i32 [ %4, %3 ], [ %20, %7 ]
%12 = shl nuw i32 1, %10
%13 = add nsw i32 %12, %6
%14 = tail call i32 @printBin(i32 %6)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %6)
%16 = tail call i32 @printBin(i32 %12)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%18 = tail call i32 @printBin(i32 %13)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%20 = add nsw i32 %11, -1
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i32 %10, 1
br i1 %21, label %26, label %7
23: ; preds = %7
%24 = add nuw nsw i32 %5, 1
%25 = icmp sgt i32 %11, 1
br i1 %25, label %3, label %26
26: ; preds = %23, %9, %1
ret void
}