#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*/ printf(char *, ...);
int main(int argc, char **argv) {
  int N, x, y, z;
  printf("void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)\n"
         "{\n"
         "   fp_digit c0, c1, c2, at[32];\n"
         "   switch (MAX(A->used, B->used)) { \n");
  for (N = 1; N <= 16; N++) {
    printf("\n"
           "   case %d:\n"
           "      memcpy(at, A->dp, %d * sizeof(fp_digit));\n"
           "      memcpy(at+%d, B->dp, %d * sizeof(fp_digit));\n"
           "      COMBA_START;\n"
           "\n"
           "      COMBA_CLEAR;\n",
           N, N, N, N);
    for (x = 0; x < (N + N - 1); x++) {
      printf("      /* %d */\n", x);
      if (x > 0) {
        printf("      COMBA_FORWARD;\n");
      }
      for (y = 0; y < N; y++) {
        for (z = 0; z < N; z++) {
          if ((y + z) == x) {
            printf("      MULADD(at[%d], at[%d]); ", y, z + N);
          }
        }
      }
      printf("\n"
             "      COMBA_STORE(C->dp[%d]);\n",
             x);
    }
    printf("      COMBA_STORE2(C->dp[%d]);\n"
           "      C->used = %d;\n"
           "      C->sign = A->sign ^ B->sign;\n"
           "      fp_clamp(C);\n"
           "      COMBA_FINI;\n"
           "      break;\n",
           N + N - 1, N + N);
  }
  printf("   }\n}\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jg     1260 <main+0x150>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xf28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1235 <main+0x125>
mov    -0x18(%rbp),%esi
lea    0xf94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jle    11a4 <main+0x94>
lea    0xf8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1216 <main+0x106>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1203 <main+0xf3>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11f0 <main+0xe0>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
add    -0x14(%rbp),%edx
lea    0xf56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <main+0xe5>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11be <main+0xae>
jmp    1208 <main+0xf8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ab <main+0x9b>
mov    -0x18(%rbp),%esi
lea    0xf3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1167 <main+0x57>
mov    -0x14(%rbp),%esi
add    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
add    -0x14(%rbp),%edx
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <main+0x2b>
lea    0xfa0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x103b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,0xc(%rsp)
lea    0xf5f(%rip),%rbx
mov    $0x1,%r14d
jmp    1189 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xf80(%rip),%rdi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
addl   $0x2,0xc(%rsp)
cmp    $0x11,%r14d
je     1250 <main+0x130>
lea    0xe70(%rip),%rdi
mov    %r14d,%esi
mov    %r14d,%edx
mov    %r14d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r14,%r14,1),%eax
mov    %eax,0x14(%rsp)
lea    (%r14,%r14,1),%eax
add    $0xffffffff,%eax
mov    %eax,0x10(%rsp)
xor    %r12d,%r12d
jmp    11dc <main+0xbc>
nopl   0x0(%rax,%rax,1)
lea    0xf00(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
je     1160 <main+0x40>
lea    0xeb5(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
je     11fe <main+0xde>
lea    0xfff(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %r12d,%r13d
jmp    121c <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
add    $0xffffffff,%r13d
cmp    %r14d,%ebp
je     11c0 <main+0xa0>
xor    %r15d,%r15d
jmp    1239 <main+0x119>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    %r15d,%r14d
je     1210 <main+0xf0>
cmp    %r15d,%r13d
jne    1230 <main+0x110>
lea    (%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1230 <main+0x110>
lea    0xf99(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [129 x i8] c"void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)\0A{\0A fp_digit c0, c1, c2, at[32];\0A switch (MAX(A->used, B->used)) { \0A\00"
@.str.1 = [152 x i8] c"\0A case %d:\0A memcpy(at, A->dp, %d * sizeof(fp_digit));\0A memcpy(at+%d, B->dp, %d * sizeof(fp_digit));\0A COMBA_START;\0A\0A COMBA_CLEAR;\0A\00"
@.str.2 = [16 x i8] c" /* %d */\0A\00"
@.str.3 = [22 x i8] c" COMBA_FORWARD;\0A\00"
@.str.4 = [31 x i8] c" MULADD(at[%d], at[%d]); \00"
@.str.5 = [32 x i8] c"\0A COMBA_STORE(C->dp[%d]);\0A\00"
@.str.6 = [137 x i8] c" COMBA_STORE2(C->dp[%d]);\0A C->used = %d;\0A C->sign = A->sign ^ B->sign;\0A fp_clamp(C);\0A COMBA_FINI;\0A break;\0A\00"
@.str.7 = [9 x i8] c" }\0A}\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %11
11: ; preds = %79, %2
%12 = load i32, i32* %6
%13 = icmp sle i32 %12, 16
br i1 %13, label %14, label %82
14: ; preds = %11
%15 = load i32, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* %6
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16, i32 %17, i32 %18)
store i32 0, i32* %7
br label %20
20: ; preds = %67, %14
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = load i32, i32* %6
%24 = add nsw i32 %22, %23
%25 = sub nsw i32 %24, 1
%26 = icmp slt i32 %21, %25
br i1 %26, label %27, label %70
27: ; preds = %20
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %27
store i32 0, i32* %8
br label %35
35: ; preds = %61, %34
%36 = load i32, i32* %8
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %64
39: ; preds = %35
store i32 0, i32* %9
br label %40
40: ; preds = %57, %39
%41 = load i32, i32* %9
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %60
44: ; preds = %40
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = add nsw i32 %45, %46
%48 = load i32, i32* %7
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %56
50: ; preds = %44
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = load i32, i32* %6
%54 = add nsw i32 %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 %54)
br label %56
56: ; preds = %50, %44
br label %57
57: ; preds = %56
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %40
60: ; preds = %40
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %35
64: ; preds = %35
%65 = load i32, i32* %7
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %64
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %20
70: ; preds = %20
%71 = load i32, i32* %6
%72 = load i32, i32* %6
%73 = add nsw i32 %71, %72
%74 = sub nsw i32 %73, 1
%75 = load i32, i32* %6
%76 = load i32, i32* %6
%77 = add nsw i32 %75, %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.6, i64 0, i64 0), i32 %74, i32 %77)
br label %79
79: ; preds = %70
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %11
82: ; preds = %11
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [152 x i8] c"\0A case %d:\0A memcpy(at, A->dp, %d * sizeof(fp_digit));\0A memcpy(at+%d, B->dp, %d * sizeof(fp_digit));\0A COMBA_START;\0A\0A COMBA_CLEAR;\0A\00"
@.str.2 = [16 x i8] c" /* %d */\0A\00"
@.str.4 = [31 x i8] c" MULADD(at[%d], at[%d]); \00"
@.str.5 = [32 x i8] c"\0A COMBA_STORE(C->dp[%d]);\0A\00"
@.str.6 = [137 x i8] c" COMBA_STORE2(C->dp[%d]);\0A C->used = %d;\0A C->sign = A->sign ^ B->sign;\0A fp_clamp(C);\0A COMBA_FINI;\0A break;\0A\00"
@str = [128 x i8] c"void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)\0A{\0A fp_digit c0, c1, c2, at[32];\0A switch (MAX(A->used, B->used)) { \00"
@str.8 = [8 x i8] c" }\0A}\0A\00"
@str.9 = [21 x i8] c" COMBA_FORWARD;\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %36, %2
%5 = phi i32 [ 1, %2 ], [ %39, %36 ]
%6 = phi i32 [ 1, %2 ], [ %38, %36 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %6, i32 %6, i32 %6)
%8 = shl nuw nsw i32 %6, 1
%9 = add nsw i32 %8, -1
br label %10
10: ; preds = %4, %32
%11 = phi i32 [ %34, %32 ], [ 0, %4 ]
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %11, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
br label %17
17: ; preds = %16, %29
%18 = phi i32 [ %30, %29 ], [ 0, %16 ]
br label %19
19: ; preds = %17, %26
%20 = phi i32 [ 0, %17 ], [ %27, %26 ]
%21 = add nuw nsw i32 %20, %18
%22 = icmp eq i32 %21, %11
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = add nuw nsw i32 %20, %6
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %24)
br label %26
26: ; preds = %19, %23
%27 = add nuw nsw i32 %20, 1
%28 = icmp eq i32 %27, %6
br i1 %28, label %29, label %19
29: ; preds = %26
%30 = add nuw nsw i32 %18, 1
%31 = icmp eq i32 %30, %6
br i1 %31, label %32, label %17
32: ; preds = %29
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%34 = add nuw nsw i32 %11, 1
%35 = icmp eq i32 %34, %5
br i1 %35, label %36, label %10
36: ; preds = %32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([137 x i8], [137 x i8]* @.str.6, i64 0, i64 0), i32 %9, i32 %8)
%38 = add nuw nsw i32 %6, 1
%39 = add nuw nsw i32 %5, 2
%40 = icmp eq i32 %38, 17
br i1 %40, label %41, label %4
41: ; preds = %36
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}