#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ is_special_sum_set(int *, int);
scalar_t__ next_set(int *, int, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ set_boundary_set_derived(int *, int, int);
int /*<<< orphan*/ set_boundary_set_heuristic(int *, int);
int /*<<< orphan*/ set_initial_set(int *, int);
int /*<<< orphan*/ stderr;
int sum_array_int(int *, int);
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s <N>\n", argv[0]);
    return 1;
  }
  int N = atoi(argv[1]);
  if (N < 1)
    return 1;
  int set[N];
  int boundary_set[N];
  set_initial_set(set, N);
  set_boundary_set_heuristic(boundary_set, N);
  int smallest_set[N];
  int smallest_sum = -1;
  for (int pass = 1; pass <= 2; pass++) {
    do {
      if (is_special_sum_set(set, N)) {
        int sum = sum_array_int(set, N);
        if (smallest_sum == -1 || sum < smallest_sum) {
          smallest_sum = sum;
          for (int i = 0; i < N; i++)
            smallest_set[i] = set[i];
        }
      }
    } while (next_set(set, N, boundary_set));
    if (smallest_sum == -1)
      return 1;
    else
      set_boundary_set_derived(boundary_set, N, smallest_sum);
  }
  for (int i = 0; i < N; i++)
    printf("%d", smallest_set[i]);
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e8 <main+0x48>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe29(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13dd <main+0x23d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    120e <main+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    13dd <main+0x23d>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%esi
call   10b0 <set_initial_set@plt>
mov    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <set_boundary_set_heuristic@plt>
mov    -0x14(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0xffffffff,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
cmpl   $0x2,-0x40(%rbp)
jg     1386 <main+0x1e6>
jmp    12a6 <main+0x106>
mov    -0x68(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <is_special_sum_set@plt>
cmp    $0x0,%rax
je     1328 <main+0x188>
mov    -0x68(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <sum_array_int@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
je     12e1 <main+0x141>
mov    -0x44(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1323 <main+0x183>
mov    -0x44(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    131e <main+0x17e>
mov    -0x58(%rbp),%rax
mov    -0x68(%rbp),%rcx
movslq -0x48(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
movslq -0x48(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    12ee <main+0x14e>
jmp    1323 <main+0x183>
jmp    1328 <main+0x188>
jmp    132d <main+0x18d>
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <next_set@plt>
cmp    $0x0,%rax
jne    12a6 <main+0x106>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1364 <main+0x1c4>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    13d6 <main+0x236>
mov    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   1050 <set_boundary_set_derived@plt>
jmp    1378 <main+0x1d8>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1297 <main+0xf7>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13be <main+0x21e>
mov    -0x58(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc64(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    138d <main+0x1ed>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jne    1291 <main+0xe1>
mov    0x8(%rsi),%rdi
call   10d0 <atoi@plt>
test   %eax,%eax
jle    12a9 <main+0xf9>
mov    %eax,%r12d
mov    %rsp,-0x48(%rbp)
mov    %eax,%r13d
mov    %rsp,%rbx
lea    0xf(,%r13,4),%r14
and    $0xfffffffffffffff0,%r14
sub    %r14,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
sub    %r14,%r15
mov    %r15,%rsp
mov    %rbx,%rdi
mov    %eax,%esi
call   10c0 <set_initial_set@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1070 <set_boundary_set_heuristic@plt>
mov    %rsp,%rax
sub    %r14,%rax
mov    %rax,-0x30(%rbp)
mov    %rax,%rsp
mov    %r13,-0x40(%rbp)
lea    0x0(,%r13,4),%rax
mov    %rax,-0x38(%rbp)
mov    $0xffffffff,%r14d
jmp    1266 <main+0xb6>
nopl   (%rax)
mov    -0x30(%rbp),%rdi
mov    %rbx,%rsi
mov    -0x38(%rbp),%rdx
call   10b0 <memcpy@plt>
mov    %r13d,%r14d
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1080 <next_set@plt>
test   %rax,%rax
je     12b3 <main+0x103>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1060 <is_special_sum_set@plt>
test   %rax,%rax
je     1253 <main+0xa3>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1090 <sum_array_int@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%r14d
je     1240 <main+0x90>
cmp    %r14d,%r13d
jge    1253 <main+0xa3>
jmp    1240 <main+0x90>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd5c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%eax
jmp    1385 <main+0x1d5>
mov    $0x1,%eax
cmp    $0xffffffff,%r14d
je     1381 <main+0x1d1>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1050 <set_boundary_set_derived@plt>
jmp    1306 <main+0x156>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x30(%rbp),%rdi
mov    %rbx,%rsi
mov    -0x38(%rbp),%rdx
call   10b0 <memcpy@plt>
mov    %r13d,%r14d
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1080 <next_set@plt>
test   %rax,%rax
je     1331 <main+0x181>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1060 <is_special_sum_set@plt>
test   %rax,%rax
je     12f3 <main+0x143>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1090 <sum_array_int@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%r14d
je     12e0 <main+0x130>
cmp    %r14d,%r13d
jge    12f3 <main+0x143>
jmp    12e0 <main+0x130>
cmp    $0xffffffff,%r14d
mov    $0x1,%eax
je     1381 <main+0x1d1>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1050 <set_boundary_set_derived@plt>
test   %r12d,%r12d
mov    -0x40(%rbp),%r15
mov    -0x30(%rbp),%r12
jle    1375 <main+0x1c5>
xor    %ebx,%ebx
lea    0xcaf(%rip),%r14
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1360 <main+0x1b0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
mov    -0x48(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %119
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 1, i32* %3
br label %119
33: ; preds = %25
%34 = load i32, i32* %6
%35 = zext i32 %34 to i64
%36 = call i8* @llvm.stacksave()
store i8* %36, i8** %7
%37 = alloca i32, i64 %35
store i64 %35, i64* %8
%38 = load i32, i32* %6
%39 = zext i32 %38 to i64
%40 = alloca i32, i64 %39
store i64 %39, i64* %9
%41 = load i32, i32* %6
%42 = call i32 @set_initial_set(i32* %37, i32 %41)
%43 = load i32, i32* %6
%44 = call i32 @set_boundary_set_heuristic(i32* %40, i32 %43)
%45 = load i32, i32* %6
%46 = zext i32 %45 to i64
%47 = alloca i32, i64 %46
store i64 %46, i64* %10
store i32 -1, i32* %11
store i32 1, i32* %12
br label %48
48: ; preds = %98, %33
%49 = load i32, i32* %12
%50 = icmp sle i32 %49, 2
br i1 %50, label %51, label %101
51: ; preds = %48
br label %52
52: ; preds = %85, %51
%53 = load i32, i32* %6
%54 = call i64 @is_special_sum_set(i32* %37, i32 %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %84
56: ; preds = %52
%57 = load i32, i32* %6
%58 = call i32 @sum_array_int(i32* %37, i32 %57)
store i32 %58, i32* %13
%59 = load i32, i32* %11
%60 = icmp eq i32 %59, -1
br i1 %60, label %65, label %61
61: ; preds = %56
%62 = load i32, i32* %13
%63 = load i32, i32* %11
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %83
65: ; preds = %61, %56
%66 = load i32, i32* %13
store i32 %66, i32* %11
store i32 0, i32* %14
br label %67
67: ; preds = %79, %65
%68 = load i32, i32* %14
%69 = load i32, i32* %6
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %82
71: ; preds = %67
%72 = load i32, i32* %14
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %37, i64 %73
%75 = load i32, i32* %74
%76 = load i32, i32* %14
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %47, i64 %77
store i32 %75, i32* %78
br label %79
79: ; preds = %71
%80 = load i32, i32* %14
%81 = add nsw i32 %80, 1
store i32 %81, i32* %14
br label %67
82: ; preds = %67
br label %83
83: ; preds = %82, %61
br label %84
84: ; preds = %83, %52
br label %85
85: ; preds = %84
%86 = load i32, i32* %6
%87 = call i64 @next_set(i32* %37, i32 %86, i32* %40)
%88 = icmp ne i64 %87, 0
br i1 %88, label %52, label %89
89: ; preds = %85
%90 = load i32, i32* %11
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %93
92: ; preds = %89
store i32 1, i32* %3
store i32 1, i32* %15
br label %117
93: ; preds = %89
%94 = load i32, i32* %6
%95 = load i32, i32* %11
%96 = call i32 @set_boundary_set_derived(i32* %40, i32 %94, i32 %95)
br label %97
97: ; preds = %93
br label %98
98: ; preds = %97
%99 = load i32, i32* %12
%100 = add nsw i32 %99, 1
store i32 %100, i32* %12
br label %48
101: ; preds = %48
store i32 0, i32* %16
br label %102
102: ; preds = %112, %101
%103 = load i32, i32* %16
%104 = load i32, i32* %6
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %115
106: ; preds = %102
%107 = load i32, i32* %16
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i32, i32* %47, i64 %108
%110 = load i32, i32* %109
%111 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %110)
br label %112
112: ; preds = %106
%113 = load i32, i32* %16
%114 = add nsw i32 %113, 1
store i32 %114, i32* %16
br label %102
115: ; preds = %102
%116 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %3
store i32 1, i32* %15
br label %117
117: ; preds = %115, %92
%118 = load i8*, i8** %7
br label %119
119: ; preds = %117, %32, %19
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %72
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %72, label %13
13: ; preds = %8
%14 = zext i32 %11 to i64
%15 = tail call i8* @llvm.stacksave()
%16 = alloca i32, i64 %14
%17 = bitcast i32* %16 to i8*
%18 = alloca i32, i64 %14
%19 = call i32 @set_initial_set(i32* %16, i32 %11)
%20 = call i32 @set_boundary_set_heuristic(i32* %18, i32 %11)
%21 = alloca i32, i64 %14
%22 = bitcast i32* %21 to i8*
%23 = shl nuw nsw i64 %14, 2
br label %24
24: ; preds = %13, %34
%25 = phi i32 [ %35, %34 ], [ -1, %13 ]
%26 = call i64 @is_special_sum_set(i32* %16, i32 %11)
%27 = icmp eq i64 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %24
%29 = call i32 @sum_array_int(i32* %16, i32 %11)
%30 = icmp ne i32 %25, -1
%31 = icmp sge i32 %29, %25
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %34, label %33
33: ; preds = %28
br label %34
34: ; preds = %33, %28, %24
%35 = phi i32 [ %25, %24 ], [ %25, %28 ], [ %29, %33 ]
%36 = call i64 @next_set(i32* %16, i32 %11, i32* %18)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %24
38: ; preds = %34
%39 = icmp eq i32 %35, -1
br i1 %39, label %70, label %40
40: ; preds = %38
%41 = call i32 @set_boundary_set_derived(i32* %18, i32 %11, i32 %35)
br label %42
42: ; preds = %52, %40
%43 = phi i32 [ %53, %52 ], [ %35, %40 ]
%44 = call i64 @is_special_sum_set(i32* %16, i32 %11)
%45 = icmp eq i64 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %42
%47 = call i32 @sum_array_int(i32* %16, i32 %11)
%48 = icmp ne i32 %43, -1
%49 = icmp sge i32 %47, %43
%50 = select i1 %48, i1 %49, i1 false
br i1 %50, label %52, label %51
51: ; preds = %46
br label %52
52: ; preds = %51, %46, %42
%53 = phi i32 [ %43, %42 ], [ %43, %46 ], [ %47, %51 ]
%54 = call i64 @next_set(i32* %16, i32 %11, i32* %18)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %42
56: ; preds = %52
%57 = icmp eq i32 %53, -1
br i1 %57, label %70, label %58
58: ; preds = %56
%59 = call i32 @set_boundary_set_derived(i32* %18, i32 %11, i32 %53)
%60 = icmp sgt i32 %11, 0
br i1 %60, label %63, label %61
61: ; preds = %63, %58
%62 = call i32 @putchar(i8 signext 10)
br label %70
63: ; preds = %58, %63
%64 = phi i64 [ %68, %63 ], [ 0, %58 ]
%65 = getelementptr inbounds i32, i32* %21, i64 %64
%66 = load i32, i32* %65
%67 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %66)
%68 = add nuw nsw i64 %64, 1
%69 = icmp eq i64 %68, %14
br i1 %69, label %61, label %63
70: ; preds = %56, %38, %61
%71 = phi i32 [ 0, %61 ], [ 1, %38 ], [ 1, %56 ]
br label %72
72: ; preds = %70, %8, %4
%73 = phi i32 [ 1, %4 ], [ %71, %70 ], [ 1, %8 ]
ret i32 %73
}