#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ f2m_is_equal(int, int *, int *);
int /*<<< orphan*/ f2m_mult(int, int *, int *, int *);
int /*<<< orphan*/ f2m_print(int, int *);
int /*<<< orphan*/ f2m_print_as_array(int, int *);
int /*<<< orphan*/ f2m_print_human(int, int *);
int /*<<< orphan*/ f2m_square(int, int *, int *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ initZero(int, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int *shiftLeft(int *, int *, int);
int /*<<< orphan*/ testeqprint(char *, int /*<<< orphan*/, int, int *, int *);
void multvssqrt() {
  uint32_t *t = (uint32_t *)malloc((1) * sizeof(uint32_t));
  t[0] = 1;
  int testnr = 0;
  uint32_t *a = (uint32_t *)malloc((*t) * sizeof(uint32_t));
  a[0] = a[0] = 0;
  while (*t < 4) {
    uint32_t *ptr = shiftLeft(t, a, 1);
    if (ptr) {
      free(a);
      a = ptr;
    }
    a[*t - 1] = a[*t - 1] ^ 0x1;
    uint32_t *result_mult = (uint32_t *)malloc(2 * (*t) * sizeof(uint32_t));
    uint32_t *result_sqrt = (uint32_t *)malloc(2 * (*t) * sizeof(uint32_t));
    initZero(2 * (*t), result_mult);
    initZero(2 * (*t), result_sqrt);
    f2m_mult(*t, a, a, result_mult);
    f2m_square(*t, a, result_sqrt);
    testeqprint("multvssqrt", testnr++, 2 * (*t), result_mult, result_sqrt);
    if (!f2m_is_equal(2 * (*t), result_mult, result_sqrt)) {
      printf("\n    a: ");
      f2m_print(*t, a);
      printf("       ");
      f2m_print_human(*t, a);
      printf("\n       ");
      f2m_print_as_array(*t, a);
      break;
    }
    free(result_mult);
    free(result_sqrt);
  }
}


x86 assembly (clang, -O0):
<multvssqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x4,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0x4,(%rax)
jge    13af <multvssqrt+0x1ef>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1040 <shiftLeft@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1250 <multvssqrt+0x90>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
xor    $0x1,%edx
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
shl    $0x1,%edi
mov    -0x28(%rbp),%rsi
call   1060 <initZero@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
shl    $0x1,%edi
mov    -0x30(%rbp),%rsi
call   1060 <initZero@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   10c0 <f2m_mult@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10b0 <f2m_square@plt>
mov    -0xc(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
shl    $0x1,%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xce2(%rip),%rdi
call   10d0 <testeqprint@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
shl    $0x1,%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <f2m_is_equal@plt>
cmp    $0x0,%eax
jne    1398 <multvssqrt+0x1d8>
lea    0xcc2(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1090 <f2m_print@plt>
lea    0xcb1(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   10e0 <f2m_print_human@plt>
lea    0xc95(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1080 <f2m_print_as_array@plt>
jmp    13af <multvssqrt+0x1ef>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1211 <multvssqrt+0x51>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multvssqrt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x4,%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
movl   $0x1,(%rax)
mov    $0x4,%edi
call   10a0 <malloc@plt>
movl   $0x0,(%rax)
cmpl   $0x3,0x0(%r13)
jg     12e3 <multvssqrt+0x123>
mov    %rax,%r14
xor    %r12d,%r12d
lea    0xdfa(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <shiftLeft@plt>
test   %rax,%rax
je     1233 <multvssqrt+0x73>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%r14
movslq 0x0(%r13),%rax
xorl   $0x1,-0x4(%r14,%rax,4)
mov    0x0(%r13),%edi
shl    $0x3,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbp
mov    0x0(%r13),%edi
shl    $0x3,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    0x0(%r13),%edi
add    %edi,%edi
mov    %rbp,%rsi
call   1060 <initZero@plt>
mov    0x0(%r13),%edi
add    %edi,%edi
mov    %rbx,%rsi
call   1060 <initZero@plt>
mov    0x0(%r13),%edi
mov    %r14,%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10c0 <f2m_mult@plt>
mov    0x0(%r13),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10b0 <f2m_square@plt>
mov    0x0(%r13),%edx
add    %edx,%edx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %rbp,%rcx
mov    %rbx,%r8
call   10d0 <testeqprint@plt>
mov    0x0(%r13),%edi
add    %edi,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1050 <f2m_is_equal@plt>
test   %eax,%eax
je     12f2 <multvssqrt+0x132>
add    $0x1,%r12d
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
cmpl   $0x4,0x0(%r13)
jl     1210 <multvssqrt+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd12(%rip),%rdi
call   1070 <printf@plt>
mov    0x0(%r13),%edi
mov    %r14,%rsi
call   1090 <f2m_print@plt>
lea    0xd04(%rip),%rdi
call   1070 <printf@plt>
mov    0x0(%r13),%edi
mov    %r14,%rsi
call   10e0 <f2m_print_human@plt>
lea    0xceb(%rip),%rdi
call   1070 <printf@plt>
mov    0x0(%r13),%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <f2m_print_as_array@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"multvssqrt\00"
@.str.1 = [9 x i8] c"\0A a: \00"
@.str.2 = [8 x i8] c" \00"
@.str.3 = [9 x i8] c"\0A \00"
define void @multvssqrt() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = call i64 @malloc(i32 4)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %1
%9 = load i32*, i32** %1
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 1, i32* %10
store i32 0, i32* %2
%11 = load i32*, i32** %1
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %3
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 0, i32* %19
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 0
store i32 0, i32* %21
br label %22
22: ; preds = %119, %0
%23 = load i32*, i32** %1
%24 = load i32, i32* %23
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %124
26: ; preds = %22
%27 = load i32*, i32** %1
%28 = load i32*, i32** %3
%29 = call i32* @shiftLeft(i32* %27, i32* %28, i32 1)
store i32* %29, i32** %4
%30 = load i32*, i32** %4
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32*, i32** %3
%34 = call i32 @free(i32* %33)
%35 = load i32*, i32** %4
store i32* %35, i32** %3
br label %36
36: ; preds = %32, %26
%37 = load i32*, i32** %3
%38 = load i32*, i32** %1
%39 = load i32, i32* %38
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %37, i64 %41
%43 = load i32, i32* %42
%44 = xor i32 %43, 1
%45 = load i32*, i32** %3
%46 = load i32*, i32** %1
%47 = load i32, i32* %46
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %45, i64 %49
store i32 %44, i32* %50
%51 = load i32*, i32** %1
%52 = load i32, i32* %51
%53 = mul nsw i32 2, %52
%54 = sext i32 %53 to i64
%55 = mul i64 %54, 4
%56 = trunc i64 %55 to i32
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to i32*
store i32* %58, i32** %5
%59 = load i32*, i32** %1
%60 = load i32, i32* %59
%61 = mul nsw i32 2, %60
%62 = sext i32 %61 to i64
%63 = mul i64 %62, 4
%64 = trunc i64 %63 to i32
%65 = call i64 @malloc(i32 %64)
%66 = inttoptr i64 %65 to i32*
store i32* %66, i32** %6
%67 = load i32*, i32** %1
%68 = load i32, i32* %67
%69 = mul nsw i32 2, %68
%70 = load i32*, i32** %5
%71 = call i32 @initZero(i32 %69, i32* %70)
%72 = load i32*, i32** %1
%73 = load i32, i32* %72
%74 = mul nsw i32 2, %73
%75 = load i32*, i32** %6
%76 = call i32 @initZero(i32 %74, i32* %75)
%77 = load i32*, i32** %1
%78 = load i32, i32* %77
%79 = load i32*, i32** %3
%80 = load i32*, i32** %3
%81 = load i32*, i32** %5
%82 = call i32 @f2m_mult(i32 %78, i32* %79, i32* %80, i32* %81)
%83 = load i32*, i32** %1
%84 = load i32, i32* %83
%85 = load i32*, i32** %3
%86 = load i32*, i32** %6
%87 = call i32 @f2m_square(i32 %84, i32* %85, i32* %86)
%88 = load i32, i32* %2
%89 = add nsw i32 %88, 1
store i32 %89, i32* %2
%90 = load i32*, i32** %1
%91 = load i32, i32* %90
%92 = mul nsw i32 2, %91
%93 = load i32*, i32** %5
%94 = load i32*, i32** %6
%95 = call i32 @testeqprint(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %88, i32 %92, i32* %93, i32* %94)
%96 = load i32*, i32** %1
%97 = load i32, i32* %96
%98 = mul nsw i32 2, %97
%99 = load i32*, i32** %5
%100 = load i32*, i32** %6
%101 = call i32 @f2m_is_equal(i32 %98, i32* %99, i32* %100)
%102 = icmp ne i32 %101, 0
br i1 %102, label %119, label %103
103: ; preds = %36
%104 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%105 = load i32*, i32** %1
%106 = load i32, i32* %105
%107 = load i32*, i32** %3
%108 = call i32 @f2m_print(i32 %106, i32* %107)
%109 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%110 = load i32*, i32** %1
%111 = load i32, i32* %110
%112 = load i32*, i32** %3
%113 = call i32 @f2m_print_human(i32 %111, i32* %112)
%114 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%115 = load i32*, i32** %1
%116 = load i32, i32* %115
%117 = load i32*, i32** %3
%118 = call i32 @f2m_print_as_array(i32 %116, i32* %117)
br label %124
119: ; preds = %36
%120 = load i32*, i32** %5
%121 = call i32 @free(i32* %120)
%122 = load i32*, i32** %6
%123 = call i32 @free(i32* %122)
br label %22
124: ; preds = %103, %22
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"multvssqrt\00"
@.str.1 = [9 x i8] c"\0A a: \00"
@.str.2 = [8 x i8] c" \00"
@.str.3 = [9 x i8] c"\0A \00"
define void @multvssqrt() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to i32*
store i32 1, i32* %2
%3 = tail call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to i32*
store i32 0, i32* %4
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 4
br i1 %6, label %7, label %63
7: ; preds = %0, %57
%8 = phi i32 [ %58, %57 ], [ 0, %0 ]
%9 = phi i32* [ %15, %57 ], [ %4, %0 ]
%10 = tail call i32* @shiftLeft(i32* %2, i32* %9, i32 1)
%11 = icmp eq i32* %10, null
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = tail call i32 @free(i32* %9)
br label %14
14: ; preds = %12, %7
%15 = phi i32* [ %10, %12 ], [ %9, %7 ]
%16 = load i32, i32* %2
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = xor i32 %20, 1
store i32 %21, i32* %19
%22 = load i32, i32* %2
%23 = shl i32 %22, 3
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
%26 = load i32, i32* %2
%27 = shl i32 %26, 3
%28 = tail call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i32*
%30 = load i32, i32* %2
%31 = shl nsw i32 %30, 1
%32 = tail call i32 @initZero(i32 %31, i32* %25)
%33 = load i32, i32* %2
%34 = shl nsw i32 %33, 1
%35 = tail call i32 @initZero(i32 %34, i32* %29)
%36 = load i32, i32* %2
%37 = tail call i32 @f2m_mult(i32 %36, i32* %15, i32* %15, i32* %25)
%38 = load i32, i32* %2
%39 = tail call i32 @f2m_square(i32 %38, i32* %15, i32* %29)
%40 = load i32, i32* %2
%41 = shl nsw i32 %40, 1
%42 = tail call i32 @testeqprint(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %41, i32* %25, i32* %29)
%43 = load i32, i32* %2
%44 = shl nsw i32 %43, 1
%45 = tail call i32 @f2m_is_equal(i32 %44, i32* %25, i32* %29)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %14
%48 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* %2
%50 = tail call i32 @f2m_print(i32 %49, i32* %15)
%51 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32, i32* %2
%53 = tail call i32 @f2m_print_human(i32 %52, i32* %15)
%54 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32, i32* %2
%56 = tail call i32 @f2m_print_as_array(i32 %55, i32* %15)
br label %63
57: ; preds = %14
%58 = add nuw nsw i32 %8, 1
%59 = tail call i32 @free(i32* %25)
%60 = tail call i32 @free(i32* %29)
%61 = load i32, i32* %2
%62 = icmp slt i32 %61, 4
br i1 %62, label %7, label %63
63: ; preds = %57, %0, %47
ret void
}