#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 s2i(char *);
void add_x_tuples(double *a_p, char *ntuple, int ntuplew, int ntuplei,
                  char *xtuple, int xtuplew, int xcnt) {
  if (xtuplew == ntuplew) {
    int xtuplei;
    xtuple[xtuplew] = '\0';
    xtuplei = s2i(xtuple);
    if (a_p[xtuplei] == -1)
      a_p[xtuplei] = 0;
    a_p[xtuplei] += a_p[ntuplei];
  } else {
    xtuple[xtuplew] = 'X';
    add_x_tuples(a_p, ntuple, ntuplew, ntuplei, xtuple, xtuplew + 1, xcnt + 1);
    if (xcnt || xtuplew < ntuplew - 1) {
      xtuple[xtuplew] = ntuple[xtuplew];
      add_x_tuples(a_p, ntuple, ntuplew, ntuplei, xtuple, xtuplew + 1, xcnt);
    }
  }
}


x86 assembly (clang, -O0):
<add_x_tuples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11be <add_x_tuples+0x9e>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
call   1030 <s2i@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    119a <add_x_tuples+0x7a>
jp     119a <add_x_tuples+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    124d <add_x_tuples+0x12d>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x58,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
add    $0x1,%r9d
mov    0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,(%rsp)
call   1040 <add_x_tuples@plt>
cmpl   $0x0,0x10(%rbp)
jne    120d <add_x_tuples+0xed>
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1248 <add_x_tuples+0x128>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
add    $0x1,%r9d
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <add_x_tuples@plt>
jmp    124d <add_x_tuples+0x12d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_x_tuples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%ebx
mov    %r8,%rbp
mov    %ecx,0x10(%rsp)
mov    %rdi,%r14
cmp    %edx,%r9d
je     11e2 <add_x_tuples+0xc2>
mov    %edx,%r12d
mov    %rsi,%r13
mov    %r14,0x18(%rsp)
mov    0x60(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x14(%rsp)
lea    -0x1(%r12),%eax
movslq %ebx,%r15
cltq
mov    %rax,0x20(%rsp)
mov    %edx,%r14d
neg    %r14d
add    $0x1,%ebx
jmp    11a2 <add_x_tuples+0x82>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x0(%r13,%r15,1),%eax
mov    %al,0x0(%rbp,%r15,1)
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
add    $0x1,%r15
mov    %ecx,%ebx
cmp    $0x1,%eax
je     11da <add_x_tuples+0xba>
movb   $0x58,0x0(%rbp,%r15,1)
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
mov    0x18(%rsp),%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    0x10(%rsp),%ecx
mov    %rbp,%r8
mov    %ebx,%r9d
call   1040 <add_x_tuples@plt>
mov    0x60(%rsp),%eax
test   %eax,%eax
jne    1180 <add_x_tuples+0x60>
cmp    0x20(%rsp),%r15
jl     1180 <add_x_tuples+0x60>
jmp    1223 <add_x_tuples+0x103>
mov    %r12d,%ebx
mov    0x18(%rsp),%r14
movslq %ebx,%rax
movb   $0x0,0x0(%rbp,%rax,1)
mov    %rbp,%rdi
call   1030 <s2i@plt>
cltq
movsd  (%r14,%rax,8),%xmm0
ucomisd 0xdfe(%rip),%xmm0
jne    1212 <add_x_tuples+0xf2>
jp     1212 <add_x_tuples+0xf2>
movq   $0x0,(%r14,%rax,8)
xorpd  %xmm0,%xmm0
movslq 0x10(%rsp),%rcx
addsd  (%r14,%rcx,8),%xmm0
movsd  %xmm0,(%r14,%rax,8)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @add_x_tuples(double* %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca double*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store double* %0, double** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%16 = load i32, i32* %13
%17 = load i32, i32* %10
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %49
19: ; preds = %7
%20 = load i8*, i8** %12
%21 = load i32, i32* %13
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %12
%25 = call i32 @s2i(i8* %24)
store i32 %25, i32* %15
%26 = load double*, double** %8
%27 = load i32, i32* %15
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = fcmp oeq double %30, -1.000000e+00
br i1 %31, label %32, label %37
32: ; preds = %19
%33 = load double*, double** %8
%34 = load i32, i32* %15
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double 0.000000e+00, double* %36
br label %37
37: ; preds = %32, %19
%38 = load double*, double** %8
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %8
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fadd double %47, %42
store double %48, double* %46
br label %89
49: ; preds = %7
%50 = load i8*, i8** %12
%51 = load i32, i32* %13
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 88, i8* %53
%54 = load double*, double** %8
%55 = load i8*, i8** %9
%56 = load i32, i32* %10
%57 = load i32, i32* %11
%58 = load i8*, i8** %12
%59 = load i32, i32* %13
%60 = add nsw i32 %59, 1
%61 = load i32, i32* %14
%62 = add nsw i32 %61, 1
%63 = load i32, i32* %14
%64 = icmp ne i32 %63, 0
br i1 %64, label %70, label %65
65: ; preds = %49
%66 = load i32, i32* %13
%67 = load i32, i32* %10
%68 = sub nsw i32 %67, 1
%69 = icmp slt i32 %66, %68
br i1 %69, label %70, label %88
70: ; preds = %65, %49
%71 = load i8*, i8** %9
%72 = load i32, i32* %13
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = load i8*, i8** %12
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
store i8 %75, i8* %79
%80 = load double*, double** %8
%81 = load i8*, i8** %9
%82 = load i32, i32* %10
%83 = load i32, i32* %11
%84 = load i8*, i8** %12
%85 = load i32, i32* %13
%86 = add nsw i32 %85, 1
%87 = load i32, i32* %14
br label %88
88: ; preds = %70, %65
br label %89
89: ; preds = %88, %37
ret void
}

LLVM IR (-O2):
define void @add_x_tuples(double* %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6) {
%8 = icmp eq i32 %5, %2
br i1 %8, label %15, label %9
9: ; preds = %7
%10 = add nsw i32 %6, 1
%11 = icmp ne i32 %6, 0
%12 = add nsw i32 %2, -1
%13 = sext i32 %5 to i64
%14 = sext i32 %12 to i64
br label %31
15: ; preds = %38, %7
%16 = phi i32 [ %5, %7 ], [ %2, %38 ]
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %4, i64 %17
store i8 0, i8* %18
%19 = tail call i32 @s2i(i8* %4)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = fcmp oeq double %22, -1.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %15
store double 0.000000e+00, double* %21
br label %25
25: ; preds = %24, %15
%26 = phi double [ 0.000000e+00, %24 ], [ %22, %15 ]
%27 = sext i32 %3 to i64
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = load double, double* %28
%30 = fadd double %29, %26
store double %30, double* %21
br label %42
31: ; preds = %9, %38
%32 = phi i64 [ %13, %9 ], [ %34, %38 ]
%33 = getelementptr inbounds i8, i8* %4, i64 %32
store i8 88, i8* %33
%34 = add nsw i64 %32, 1
%35 = trunc i64 %34 to i32
tail call void @add_x_tuples(double* %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %35, i32 %10)
%36 = icmp slt i64 %32, %14
%37 = select i1 %11, i1 true, i1 %36
br i1 %37, label %38, label %42
38: ; preds = %31
%39 = getelementptr inbounds i8, i8* %1, i64 %32
%40 = load i8, i8* %39
store i8 %40, i8* %33
%41 = icmp eq i32 %35, %2
br i1 %41, label %15, label %31
42: ; preds = %31, %25
ret void
}