#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*/ addOneBit(int *, int);
scalar_t__ highestBin(int *, int);
int /*<<< orphan*/ printSubset(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int binrep[1000];
  int ix;
  for (ix = 0; ix < 1000; ix++) {
    binrep[ix] = 0;
  }
  int input;
  printf("Problem 4: Prints the powerset of the set containing integers 1 - n");
  printf("\n 1 < n < 1000: ");
  scanf("%d", &input);
  while (highestBin(binrep, input) == 0) {
    printSubset(binrep, input);
    printf(", ");
    addOneBit(binrep, input);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfb0,%rsp
movl   $0x0,-0xfa4(%rbp)
cmpl   $0x3e8,-0xfa4(%rbp)
jge    119b <main+0x4b>
movslq -0xfa4(%rbp),%rax
movl   $0x0,-0xfa0(%rbp,%rax,4)
mov    -0xfa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfa4(%rbp)
jmp    1165 <main+0x15>
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0xfa8(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0xfa0(%rbp),%rdi
mov    -0xfa8(%rbp),%esi
call   1040 <highestBin@plt>
cmp    $0x0,%rax
jne    1217 <main+0xc7>
lea    -0xfa0(%rbp),%rdi
mov    -0xfa8(%rbp),%esi
call   1030 <printSubset@plt>
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
lea    -0xfa0(%rbp),%rdi
mov    -0xfa8(%rbp),%esi
call   1070 <addOneBit@plt>
jmp    11c6 <main+0x76>
add    $0xfb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xfb8,%rsp
lea    0x10(%rsp),%rbx
mov    $0xfa0,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <highestBin@plt>
test   %rax,%rax
jne    1201 <main+0xa1>
lea    0x10(%rsp),%rbx
lea    0xe94(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printSubset@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1080 <addOneBit@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <highestBin@plt>
test   %rax,%rax
je     11d0 <main+0x70>
add    $0xfb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Problem 4: Prints the powerset of the set containing integers 1 - n\00"
@.str.1 = [17 x i8] c"\0A 1 < n < 1000: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c", \00"
define void @main() {
%1 = alloca [1000 x i32]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %11, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1000
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %9
store i32 0, i32* %10
br label %11
11: ; preds = %7
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %4
14: ; preds = %4
%15 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
br label %18
18: ; preds = %23, %14
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%20 = load i32, i32* %3
%21 = call i64 @highestBin(i32* %19, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %18
%24 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%25 = load i32, i32* %3
%26 = call i32 @printSubset(i32* %24, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%29 = load i32, i32* %3
%30 = call i32 @addOneBit(i32* %28, i32 %29)
br label %18
31: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [68 x i8] c"Problem 4: Prints the powerset of the set containing integers 1 - n\00"
@.str.1 = [17 x i8] c"\0A 1 < n < 1000: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c", \00"
define void @main() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i64 @highestBin(i32* %8, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %0, %12
%13 = load i32, i32* %3
%14 = call i32 @printSubset(i32* %8, i32 %13)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @addOneBit(i32* %8, i32 %16)
%18 = load i32, i32* %3
%19 = call i64 @highestBin(i32* %8, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %12, label %21
21: ; preds = %12, %0
ret void
}