#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int abs(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
uintptr_t my_mul_2exp(uintptr_t, int);
uintptr_t fprintf_partial(FILE *out, int s, int n, int *a) {
  int prev = 0;
  uintptr_t sols = 1;
  for (int j = 0; j < s; j++) {
    if (a[j] < 0) {
      fprintf(out, "0 ");
    } else {
      fprintf(out, "1 ");
    }
    sols = my_mul_2exp(sols, abs(a[j]) - prev - 1);
    prev = abs(a[j]);
  }
  fprintf(out, "\n");
  return my_mul_2exp(sols, n - prev);
}


x86 assembly (clang, -O0):
<fprintf_partial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ed <fprintf_partial+0xbd>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    118f <fprintf_partial+0x5f>
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    119f <fprintf_partial+0x6f>
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <abs@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
sub    -0x1c(%rbp),%esi
sub    $0x1,%esi
call   1040 <my_mul_2exp@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <abs@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115c <fprintf_partial+0x2c>
mov    -0x8(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    -0x1c(%rbp),%esi
call   1040 <my_mul_2exp@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprintf_partial>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
mov    %rdi,%r15
test   %esi,%esi
jle    11b9 <fprintf_partial+0x89>
mov    %rcx,%r12
mov    %esi,%r13d
xor    %r14d,%r14d
mov    $0x1,%ebp
xor    %ebx,%ebx
jmp    11a2 <fprintf_partial+0x72>
nopl   0x0(%rax,%rax,1)
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1050 <fwrite@plt>
mov    (%r12,%r14,4),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
not    %ebx
add    %ecx,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1030 <my_mul_2exp@plt>
mov    %rax,%rbp
mov    (%r12,%r14,4),%eax
mov    %eax,%ebx
neg    %ebx
cmovs  %eax,%ebx
add    $0x1,%r14
cmp    %r14,%r13
je     11c0 <fprintf_partial+0x90>
cmpl   $0x0,(%r12,%r14,4)
lea    0xe52(%rip),%rdi
js     1160 <fprintf_partial+0x30>
lea    0xe4c(%rip),%rdi
jmp    1160 <fprintf_partial+0x30>
mov    $0x1,%ebp
xor    %ebx,%ebx
mov    $0xa,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
mov    0x4(%rsp),%esi
sub    %ebx,%esi
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <my_mul_2exp@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"0 \00"
@.str.1 = [3 x i8] c"1 \00"
define i64 @fprintf_partial(i32* nocapture %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %14
8: ; preds = %14, %4
%9 = phi i32 [ 0, %4 ], [ %29, %14 ]
%10 = phi i64 [ 1, %4 ], [ %27, %14 ]
%11 = tail call i32 @fputc(i32 10, i32* %0)
%12 = sub nsw i32 %2, %9
%13 = tail call i64 @my_mul_2exp(i64 %10, i32 %12)
ret i64 %13
14: ; preds = %6, %14
%15 = phi i64 [ 0, %6 ], [ %30, %14 ]
%16 = phi i64 [ 1, %6 ], [ %27, %14 ]
%17 = phi i32 [ 0, %6 ], [ %29, %14 ]
%18 = getelementptr inbounds i32, i32* %3, i64 %15
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%22 = tail call i64 @fwrite(i8* %21, i64 2, i64 1, i32* %0)
%23 = load i32, i32* %18
%24 = tail call i32 @llvm.abs.i32(i32 %23, i1 true)
%25 = xor i32 %17, -1
%26 = add nsw i32 %24, %25
%27 = tail call i64 @my_mul_2exp(i64 %16, i32 %26)
%28 = load i32, i32* %18
%29 = tail call i32 @llvm.abs.i32(i32 %28, i1 true)
%30 = add nuw nsw i64 %15, 1
%31 = icmp eq i64 %30, %7
br i1 %31, label %8, label %14
}