#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ wait(int *);
void binary(int *vet, int n) {
  int i, j;
  pid_t pid1, pid2;
  for (i = 0; i <= n; i++) {
    if (i == n) {
      for (j = 0; j < n; j++) {
        fprintf(stdout, "%d ", vet[j]);
      }
      fprintf(stdout, "\n");
      exit(0);
    } else {
      pid1 = fork();
      if (pid1 == 0) {
        vet[i] = 0;
      } else {
        pid2 = fork();
        if (pid2 == 0) {
          vet[i] = 1;
        } else {
          wait((int *)0);
          wait((int *)0);
          exit(1);
        }
      }
    }
  }
  return;
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     125c <binary+0x11c>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11cf <binary+0x8f>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b1 <binary+0x71>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1175 <binary+0x35>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f9 <binary+0xb9>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1244 <binary+0x104>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1223 <binary+0xe3>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    123f <binary+0xff>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    1244 <binary+0x104>
jmp    1249 <binary+0x109>
jmp    124e <binary+0x10e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1156 <binary+0x16>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jns    1155 <binary+0x15>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%ebp
mov    %rdi,%r15
mov    %esi,%r14d
jne    11b9 <binary+0x79>
test   %ebp,%ebp
jle    119b <binary+0x5b>
mov    0x2e76(%rip),%r12
lea    0xe8f(%rip),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edi
mov    (%r15,%rbx,4),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <binary+0x40>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
xor    %ebx,%ebx
jmp    11cd <binary+0x8d>
nopl   (%rax)
mov    %ecx,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
je     115f <binary+0x1f>
xor    %eax,%eax
call   1060 <fork@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     11c0 <binary+0x80>
xor    %eax,%eax
call   1060 <fork@plt>
mov    $0x1,%ecx
test   %rax,%rax
je     11c0 <binary+0x80>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %edi,%edi
call   1050 <wait@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @binary(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %62, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %65
13: ; preds = %9
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %37
17: ; preds = %13
store i32 0, i32* %6
br label %18
18: ; preds = %30, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i32, i32* @stdout
%24 = load i32*, i32** %3
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %18
33: ; preds = %18
%34 = load i32, i32* @stdout
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %13
%38 = call i64 (...) @fork()
store i64 %38, i64* %7
%39 = load i64, i64* %7
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i32*, i32** %3
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 0, i32* %45
br label %60
46: ; preds = %37
%47 = call i64 (...) @fork()
store i64 %47, i64* %8
%48 = load i64, i64* %8
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i32*, i32** %3
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 1, i32* %54
br label %59
55: ; preds = %46
%56 = call i32 @wait(i32* null)
%57 = call i32 @wait(i32* null)
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %50
br label %60
60: ; preds = %59, %41
br label %61
61: ; preds = %60
br label %62
62: ; preds = %61
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %9
65: ; preds = %9
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @binary(i32* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %37, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %21
7: ; preds = %32, %4
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %17
9: ; preds = %7, %9
%10 = phi i64 [ %15, %9 ], [ 0, %7 ]
%11 = load i32, i32* @stdout
%12 = getelementptr inbounds i32, i32* %0, i64 %10
%13 = load i32, i32* %12
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %17, label %9
17: ; preds = %9, %7
%18 = load i32, i32* @stdout
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %4, %32
%22 = phi i64 [ %35, %32 ], [ 0, %4 ]
%23 = tail call i64 (...) @fork()
%24 = icmp eq i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %21
%26 = tail call i64 (...) @fork()
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i32 @wait(i32* null)
%30 = tail call i32 @wait(i32* null)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %25, %21
%33 = phi i32 [ 0, %21 ], [ 1, %25 ]
%34 = getelementptr inbounds i32, i32* %0, i64 %22
store i32 %33, i32* %34
%35 = add nuw nsw i64 %22, 1
%36 = icmp eq i64 %35, %5
br i1 %36, label %7, label %21
37: ; preds = %2
ret void
}