{"code":"//===- unittest/Tooling/StencilTest.cpp -----------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include \"clang/Tooling/Transformer/Stencil.h\"\n#include \"clang/ASTMatchers/ASTMatchers.h\"\n#include \"clang/Tooling/FixIt.h\"\n#include \"clang/Tooling/Tooling.h\"\n#include \"llvm/Support/Error.h\"\n#include \"llvm/Testing/Support/Error.h\"\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\nusing namespace clang;\nusing namespace transformer;\nusing namespace ast_matchers;\n\nnamespace {\nusing ::llvm::Failed;\nusing ::llvm::HasValue;\nusing ::llvm::StringError;\nusing ::testing::AllOf;\nusing ::testing::HasSubstr;\nusing MatchResult = MatchFinder::MatchResult;\n\n// Create a valid translation-unit from a statement.\nstatic std::string wrapSnippet(StringRef StatementCode) {\n  return (\"struct S { int field; }; auto stencil_test_snippet = []{\" +\n          StatementCode + \"};\")\n      .str();\n}\n\nstatic DeclarationMatcher wrapMatcher(const StatementMatcher &Matcher) {\n  return varDecl(hasName(\"stencil_test_snippet\"),\n                 hasDescendant(compoundStmt(hasAnySubstatement(Matcher))));\n}\n\nstruct TestMatch {\n  // The AST unit from which `result` is built. We bundle it because it backs\n  // the result. Users are not expected to access it.\n  std::unique_ptr<ASTUnit> AstUnit;\n  // The result to use in the test. References `ast_unit`.\n  MatchResult Result;\n};\n\n// Matches `Matcher` against the statement `StatementCode` and returns the\n// result. Handles putting the statement inside a function and modifying the\n// matcher correspondingly. `Matcher` should match one of the statements in\n// `StatementCode` exactly -- that is, produce exactly one match. However,\n// `StatementCode` may contain other statements not described by `Matcher`.\nstatic llvm::Optional<TestMatch> matchStmt(StringRef StatementCode,\n                                           StatementMatcher Matcher) {\n  auto AstUnit = tooling::buildASTFromCode(wrapSnippet(StatementCode));\n  if (AstUnit == nullptr) {\n    ADD_FAILURE() << \"AST construction failed\";\n    return llvm::None;\n  }\n  ASTContext &Context = AstUnit->getASTContext();\n  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);\n  // We expect a single, exact match for the statement.\n  if (Matches.size() != 1) {\n    ADD_FAILURE() << \"Wrong number of matches: \" << Matches.size();\n    return llvm::None;\n  }\n  return TestMatch{std::move(AstUnit), MatchResult(Matches[0], &Context)};\n}\n\nclass StencilTest : public ::testing::Test {\nprotected:\n  // Verifies that the given stencil fails when evaluated on a valid match\n  // result. Binds a statement to \"stmt\", a (non-member) ctor-initializer to\n  // \"init\", an expression to \"expr\" and a (nameless) declaration to \"decl\".\n  void testError(const Stencil &Stencil,\n                 ::testing::Matcher<std::string> Matcher) {\n    const std::string Snippet = R\"cc(\n      struct A {};\n      class F : public A {\n       public:\n        F(int) {}\n      };\n      F(1);\n    )cc\";\n    auto StmtMatch = matchStmt(\n        Snippet,\n        stmt(hasDescendant(\n                 cxxConstructExpr(\n                     hasDeclaration(decl(hasDescendant(cxxCtorInitializer(\n                                                           isBaseInitializer())\n                                                           .bind(\"init\")))\n                                        .bind(\"decl\")))\n                     .bind(\"expr\")))\n            .bind(\"stmt\"));\n    ASSERT_TRUE(StmtMatch);\n    if (auto ResultOrErr = Stencil->eval(StmtMatch->Result)) {\n      ADD_FAILURE() << \"Expected failure but succeeded: \" << *ResultOrErr;\n    } else {\n      auto Err = llvm::handleErrors(ResultOrErr.takeError(),\n                                    [&Matcher](const StringError &Err) {\n                                      EXPECT_THAT(Err.getMessage(), Matcher);\n                                    });\n      if (Err) {\n        ADD_FAILURE() << \"Unhandled error: \" << llvm::toString(std::move(Err));\n      }\n    }\n  }\n\n  // Tests failures caused by references to unbound nodes. `unbound_id` is the\n  // id that will cause the failure.\n  void testUnboundNodeError(const Stencil &Stencil, StringRef UnboundId) {\n    testError(Stencil, AllOf(HasSubstr(UnboundId), HasSubstr(\"not bound\")));\n  }\n};\n\nTEST_F(StencilTest, SingleStatement) {\n  StringRef Condition(\"C\"), Then(\"T\"), Else(\"E\");\n  const std::string Snippet = R\"cc(\n    if (true)\n      return 1;\n    else\n      return 0;\n  )cc\";\n  auto StmtMatch = matchStmt(\n      Snippet, ifStmt(hasCondition(expr().bind(Condition)),\n                      hasThen(stmt().bind(Then)), hasElse(stmt().bind(Else))));\n  ASSERT_TRUE(StmtMatch);\n  // Invert the if-then-else.\n  auto Stencil = cat(\"if (!\", node(Condition), \") \", statement(Else), \" else \",\n                     statement(Then));\n  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),\n                       HasValue(\"if (!true) return 0; else return 1;\"));\n}\n\nTEST_F(StencilTest, UnboundNode) {\n  const std::string Snippet = R\"cc(\n    if (true)\n      return 1;\n    else\n      return 0;\n  )cc\";\n  auto StmtMatch = matchStmt(Snippet, ifStmt(hasCondition(stmt().bind(\"a1\")),\n                                             hasThen(stmt().bind(\"a2\"))));\n  ASSERT_TRUE(StmtMatch);\n  auto Stencil = cat(\"if(!\", node(\"a1\"), \") \", node(\"UNBOUND\"), \";\");\n  auto ResultOrErr = Stencil->eval(StmtMatch->Result);\n  EXPECT_TRUE(llvm::errorToBool(ResultOrErr.takeError()))\n      << \"Expected unbound node, got \" << *ResultOrErr;\n}\n\n// Tests that a stencil with a single parameter (`Id`) evaluates to the expected\n// string, when `Id` is bound to the expression-statement in `Snippet`.\nvoid testExpr(StringRef Id, StringRef Snippet, const Stencil &Stencil,\n              StringRef Expected) {\n  auto StmtMatch = matchStmt(Snippet, expr().bind(Id));\n  ASSERT_TRUE(StmtMatch);\n  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(Expected));\n}\n\nvoid testFailure(StringRef Id, StringRef Snippet, const Stencil &Stencil,\n                 testing::Matcher<std::string> MessageMatcher) {\n  auto StmtMatch = matchStmt(Snippet, expr().bind(Id));\n  ASSERT_TRUE(StmtMatch);\n  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),\n                       Failed<StringError>(testing::Property(\n                           &StringError::getMessage, MessageMatcher)));\n}\n\nTEST_F(StencilTest, SelectionOp) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"3;\", cat(node(Id)), \"3\");\n}\n\nTEST_F(StencilTest, IfBoundOpBound) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"3;\", ifBound(Id, text(\"5\"), text(\"7\")), \"5\");\n}\n\nTEST_F(StencilTest, IfBoundOpUnbound) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"3;\", ifBound(\"other\", text(\"5\"), text(\"7\")), \"7\");\n}\n\nTEST_F(StencilTest, ExpressionOpNoParens) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"3;\", expression(Id), \"3\");\n}\n\n// Don't parenthesize a parens expression.\nTEST_F(StencilTest, ExpressionOpNoParensParens) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"(3);\", expression(Id), \"(3)\");\n}\n\nTEST_F(StencilTest, ExpressionOpBinaryOpParens) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"3+4;\", expression(Id), \"(3+4)\");\n}\n\n// `expression` shares code with other ops, so we get sufficient coverage of the\n// error handling code with this test. If that changes in the future, more error\n// tests should be added.\nTEST_F(StencilTest, ExpressionOpUnbound) {\n  StringRef Id = \"id\";\n  testFailure(Id, \"3;\", expression(\"ACACA\"),\n              AllOf(HasSubstr(\"ACACA\"), HasSubstr(\"not bound\")));\n}\n\nTEST_F(StencilTest, DerefPointer) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; x;\", deref(Id), \"*x\");\n}\n\nTEST_F(StencilTest, DerefBinOp) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; x + 1;\", deref(Id), \"*(x + 1)\");\n}\n\nTEST_F(StencilTest, DerefAddressExpr) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int x; &x;\", deref(Id), \"x\");\n}\n\nTEST_F(StencilTest, AddressOfValue) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int x; x;\", addressOf(Id), \"&x\");\n}\n\nTEST_F(StencilTest, AddressOfDerefExpr) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; *x;\", addressOf(Id), \"x\");\n}\n\nTEST_F(StencilTest, MaybeDerefValue) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int x; x;\", maybeDeref(Id), \"x\");\n}\n\nTEST_F(StencilTest, MaybeDerefPointer) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; x;\", maybeDeref(Id), \"*x\");\n}\n\nTEST_F(StencilTest, MaybeDerefBinOp) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; x + 1;\", maybeDeref(Id), \"*(x + 1)\");\n}\n\nTEST_F(StencilTest, MaybeDerefAddressExpr) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int x; &x;\", maybeDeref(Id), \"x\");\n}\n\nTEST_F(StencilTest, MaybeAddressOfPointer) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; x;\", maybeAddressOf(Id), \"x\");\n}\n\nTEST_F(StencilTest, MaybeAddressOfValue) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int x; x;\", addressOf(Id), \"&x\");\n}\n\nTEST_F(StencilTest, MaybeAddressOfBinOp) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int x; x + 1;\", maybeAddressOf(Id), \"&(x + 1)\");\n}\n\nTEST_F(StencilTest, MaybeAddressOfDerefExpr) {\n  StringRef Id = \"id\";\n  testExpr(Id, \"int *x; *x;\", addressOf(Id), \"x\");\n}\n\nTEST_F(StencilTest, AccessOpValue) {\n  StringRef Snippet = R\"cc(\n    S x;\n    x;\n  )cc\";\n  StringRef Id = \"id\";\n  testExpr(Id, Snippet, access(Id, \"field\"), \"x.field\");\n}\n\nTEST_F(StencilTest, AccessOpValueExplicitText) {\n  StringRef Snippet = R\"cc(\n    S x;\n    x;\n  )cc\";\n  StringRef Id = \"id\";\n  testExpr(Id, Snippet, access(Id, text(\"field\")), \"x.field\");\n}\n\nTEST_F(StencilTest, AccessOpValueAddress) {\n  StringRef Snippet = R\"cc(\n    S x;\n    &x;\n  )cc\";\n  StringRef Id = \"id\";\n  testExpr(Id, Snippet, access(Id, \"field\"), \"x.field\");\n}\n\nTEST_F(StencilTest, AccessOpPointer) {\n  StringRef Snippet = R\"cc(\n    S *x;\n    x;\n  )cc\";\n  StringRef Id = \"id\";\n  testExpr(Id, Snippet, access(Id, \"field\"), \"x->field\");\n}\n\nTEST_F(StencilTest, AccessOpPointerDereference) {\n  StringRef Snippet = R\"cc(\n    S *x;\n    *x;\n  )cc\";\n  StringRef Id = \"id\";\n  testExpr(Id, Snippet, access(Id, \"field\"), \"x->field\");\n}\n\nTEST_F(StencilTest, AccessOpExplicitThis) {\n  using clang::ast_matchers::hasObjectExpression;\n  using clang::ast_matchers::memberExpr;\n\n  // Set up the code so we can bind to a use of this.\n  StringRef Snippet = R\"cc(\n    class C {\n     public:\n      int x;\n      int foo() { return this->x; }\n    };\n  )cc\";\n  auto StmtMatch =\n      matchStmt(Snippet, returnStmt(hasReturnValue(ignoringImplicit(memberExpr(\n                             hasObjectExpression(expr().bind(\"obj\")))))));\n  ASSERT_TRUE(StmtMatch);\n  const Stencil Stencil = access(\"obj\", \"field\");\n  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),\n                       HasValue(\"this->field\"));\n}\n\nTEST_F(StencilTest, AccessOpImplicitThis) {\n  using clang::ast_matchers::hasObjectExpression;\n  using clang::ast_matchers::memberExpr;\n\n  // Set up the code so we can bind to a use of (implicit) this.\n  StringRef Snippet = R\"cc(\n    class C {\n     public:\n      int x;\n      int foo() { return x; }\n    };\n  )cc\";\n  auto StmtMatch =\n      matchStmt(Snippet, returnStmt(hasReturnValue(ignoringImplicit(memberExpr(\n                             hasObjectExpression(expr().bind(\"obj\")))))));\n  ASSERT_TRUE(StmtMatch);\n  const Stencil Stencil = access(\"obj\", \"field\");\n  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(\"field\"));\n}\n\nTEST_F(StencilTest, RunOp) {\n  StringRef Id = \"id\";\n  auto SimpleFn = [Id](const MatchResult &R) {\n    return std::string(R.Nodes.getNodeAs<Stmt>(Id) != nullptr ? \"Bound\"\n                                                              : \"Unbound\");\n  };\n  testExpr(Id, \"3;\", run(SimpleFn), \"Bound\");\n}\n\nTEST(StencilToStringTest, RawTextOp) {\n  auto S = cat(\"foo bar baz\");\n  StringRef Expected = R\"(\"foo bar baz\")\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, RawTextOpEscaping) {\n  auto S = cat(\"foo \\\"bar\\\" baz\\\\n\");\n  StringRef Expected = R\"(\"foo \\\"bar\\\" baz\\\\n\")\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, DebugPrintNodeOp) {\n  auto S = dPrint(\"Id\");\n  StringRef Expected = R\"repr(dPrint(\"Id\"))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, ExpressionOp) {\n  auto S = expression(\"Id\");\n  StringRef Expected = R\"repr(expression(\"Id\"))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, DerefOp) {\n  auto S = deref(\"Id\");\n  StringRef Expected = R\"repr(deref(\"Id\"))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, AddressOfOp) {\n  auto S = addressOf(\"Id\");\n  StringRef Expected = R\"repr(addressOf(\"Id\"))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, SelectionOp) {\n  auto S1 = cat(node(\"node1\"));\n  EXPECT_EQ(S1->toString(), \"selection(...)\");\n}\n\nTEST(StencilToStringTest, AccessOpText) {\n  auto S = access(\"Id\", \"memberData\");\n  StringRef Expected = R\"repr(access(\"Id\", \"memberData\"))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, AccessOpSelector) {\n  auto S = access(\"Id\", selection(name(\"otherId\")));\n  StringRef Expected = R\"repr(access(\"Id\", selection(...)))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, AccessOpStencil) {\n  auto S = access(\"Id\", cat(\"foo_\", \"bar\"));\n  StringRef Expected = R\"repr(access(\"Id\", seq(\"foo_\", \"bar\")))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, IfBoundOp) {\n  auto S = ifBound(\"Id\", text(\"trueText\"), access(\"exprId\", \"memberData\"));\n  StringRef Expected =\n      R\"repr(ifBound(\"Id\", \"trueText\", access(\"exprId\", \"memberData\")))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, RunOp) {\n  auto F1 = [](const MatchResult &R) { return \"foo\"; };\n  auto S1 = run(F1);\n  EXPECT_EQ(S1->toString(), \"run(...)\");\n}\n\nTEST(StencilToStringTest, Sequence) {\n  auto S = cat(\"foo\", access(\"x\", \"m()\"), \"bar\",\n               ifBound(\"x\", text(\"t\"), access(\"e\", \"f\")));\n  StringRef Expected = R\"repr(seq(\"foo\", access(\"x\", \"m()\"), \"bar\", )repr\"\n                       R\"repr(ifBound(\"x\", \"t\", access(\"e\", \"f\"))))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, SequenceEmpty) {\n  auto S = cat();\n  StringRef Expected = \"seq()\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, SequenceSingle) {\n  auto S = cat(\"foo\");\n  StringRef Expected = \"\\\"foo\\\"\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n\nTEST(StencilToStringTest, SequenceFromVector) {\n  auto S = catVector({text(\"foo\"), access(\"x\", \"m()\"), text(\"bar\"),\n                      ifBound(\"x\", text(\"t\"), access(\"e\", \"f\"))});\n  StringRef Expected = R\"repr(seq(\"foo\", access(\"x\", \"m()\"), \"bar\", )repr\"\n                       R\"repr(ifBound(\"x\", \"t\", access(\"e\", \"f\"))))repr\";\n  EXPECT_EQ(S->toString(), Expected);\n}\n} // namespace\n\n/*\n * Socket Splickt\n * by zx2c4\n * \n * This is an attempt to exploit CVE-2011-4594.\n * \n * It was patched in bc909d9ddbf7778371e36a651d6e4194b1cc7d4c.\n * \n */\n\n\n#define _GNU_SOURCE\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <unistd.h>\n#include <signal.h>\n#include <netdb.h>\n#include <sys/types.h>\n#include <sys/ioctl.h>\n#include <sys/socket.h>\n#include <net/if.h>\n#include <net/ethernet.h>\n#include <linux/if_packet.h>\n#include <asm/unistd.h>\n#include <errno.h>\n\n#ifndef __NR_sendmmsg\n#if defined( __PPC__)\n#define __NR_sendmmsg   349\n#elif defined(__x86_64__)\n#define __NR_sendmmsg   307\n#elif defined(__i386__)\n#define __NR_sendmmsg   345\n#else\n#error __NR_sendmmsg not defined\n#endif\n#endif\n\nstruct reimp_mmsghdr {\n        struct msghdr msg_hdr;\n        unsigned int msg_len;\n};\nstatic inline int reimp_sendmmsg(int fd, struct reimp_mmsghdr *mmsg, unsigned int vlen, unsigned int flags)\n{\n        return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags, NULL);\n}\n\nint main(int argc, char *argv[])\n{\n\tconst int fd = socket(AF_INET, SOCK_DGRAM, 0);\n\tchar buf[10];\n\tstruct iovec iovec[1];\n\tstruct reimp_mmsghdr datagram[2];\n\tstruct sockaddr_in addr;\n\n\tmemset(buf, 0, sizeof(buf));\n\tmemset(iovec, 0, sizeof(iovec));\n\tmemset(&datagram[0], 0, sizeof(datagram[0]));\n\tmemset(&datagram[1], 0, sizeof(datagram[1]));\n\tmemset(&addr, 0, sizeof(addr));\n\taddr.sin_family = AF_INET;\n\taddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n\taddr.sin_port = htons(10000);\n\tiovec[0].iov_base = buf;\n\tiovec[0].iov_len = sizeof(buf);\n\tdatagram[0].msg_hdr.msg_iov = iovec;\n\tdatagram[0].msg_hdr.msg_iovlen = 1;\n\tdatagram[1].msg_hdr.msg_iov = iovec;\n\tdatagram[1].msg_hdr.msg_iovlen = 1;\n\t\n\t/* TODO: Pass something naughty here. */\n\tdatagram[0].msg_hdr.msg_name = &addr;\n\tdatagram[0].msg_hdr.msg_namelen = sizeof(addr);\n\tdatagram[1].msg_hdr.msg_name = &addr;\n\tdatagram[1].msg_hdr.msg_namelen = sizeof(addr);\n\n\tint ret;\n\tif ((ret = reimp_sendmmsg(fd, datagram, 2, 0)) < 0) {\n\t\tperror(\"reimp_sendmmsg\");\n\t\texit(1);\n\t}\n\tprintf(\"Sent %d packets.\\n\", ret);\n\n\treturn 0;\n}\n// SPDX-License-Identifier: GPL-2.0 OR MIT\n/*\n * Copyright (C) 2015-2016 The fiat-crypto Authors.\n * Copyright (C) 2018-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.\n *\n * This is a machine-generated formally verified implementation of Curve25519\n * ECDH from: <https://github.com/mit-plv/fiat-crypto>. Though originally\n * machine generated, it has been tweaked to be suitable for use in the kernel.\n * It is optimized for 32-bit machines and machines that cannot work efficiently\n * with 128-bit integer types.\n */\n\n/* fe means field element. Here the field is \\Z/(2^255-19). An element t,\n * entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77\n * t[3]+2^102 t[4]+...+2^230 t[9].\n * fe limbs are bounded by 1.125*2^26,1.125*2^25,1.125*2^26,1.125*2^25,etc.\n * Multiplication and carrying produce fe from fe_loose.\n */\ntypedef struct fe { u32 v[10]; } fe;\n\n/* fe_loose limbs are bounded by 3.375*2^26,3.375*2^25,3.375*2^26,3.375*2^25,etc\n * Addition and subtraction produce fe_loose from (fe, fe).\n */\ntypedef struct fe_loose { u32 v[10]; } fe_loose;\n\nstatic __always_inline void fe_frombytes_impl(u32 h[10], const u8 *s)\n{\n\t/* Ignores top bit of s. */\n\tu32 a0 = get_unaligned_le32(s);\n\tu32 a1 = get_unaligned_le32(s+4);\n\tu32 a2 = get_unaligned_le32(s+8);\n\tu32 a3 = get_unaligned_le32(s+12);\n\tu32 a4 = get_unaligned_le32(s+16);\n\tu32 a5 = get_unaligned_le32(s+20);\n\tu32 a6 = get_unaligned_le32(s+24);\n\tu32 a7 = get_unaligned_le32(s+28);\n\th[0] = a0&((1<<26)-1);                    /* 26 used, 32-26 left.   26 */\n\th[1] = (a0>>26) | ((a1&((1<<19)-1))<< 6); /* (32-26) + 19 =  6+19 = 25 */\n\th[2] = (a1>>19) | ((a2&((1<<13)-1))<<13); /* (32-19) + 13 = 13+13 = 26 */\n\th[3] = (a2>>13) | ((a3&((1<< 6)-1))<<19); /* (32-13) +  6 = 19+ 6 = 25 */\n\th[4] = (a3>> 6);                          /* (32- 6)              = 26 */\n\th[5] = a4&((1<<25)-1);                    /*                        25 */\n\th[6] = (a4>>25) | ((a5&((1<<19)-1))<< 7); /* (32-25) + 19 =  7+19 = 26 */\n\th[7] = (a5>>19) | ((a6&((1<<12)-1))<<13); /* (32-19) + 12 = 13+12 = 25 */\n\th[8] = (a6>>12) | ((a7&((1<< 6)-1))<<20); /* (32-12) +  6 = 20+ 6 = 26 */\n\th[9] = (a7>> 6)&((1<<25)-1); /*                                     25 */\n}\n\nstatic __always_inline void fe_frombytes(fe *h, const u8 *s)\n{\n\tfe_frombytes_impl(h->v, s);\n}\n\nstatic __always_inline u8 /*bool*/\naddcarryx_u25(u8 /*bool*/ c, u32 a, u32 b, u32 *low)\n{\n\t/* This function extracts 25 bits of result and 1 bit of carry\n\t * (26 total), so a 32-bit intermediate is sufficient.\n\t */\n\tu32 x = a + b + c;\n\t*low = x & ((1 << 25) - 1);\n\treturn (x >> 25) & 1;\n}\n\nstatic __always_inline u8 /*bool*/\naddcarryx_u26(u8 /*bool*/ c, u32 a, u32 b, u32 *low)\n{\n\t/* This function extracts 26 bits of result and 1 bit of carry\n\t * (27 total), so a 32-bit intermediate is sufficient.\n\t */\n\tu32 x = a + b + c;\n\t*low = x & ((1 << 26) - 1);\n\treturn (x >> 26) & 1;\n}\n\nstatic __always_inline u8 /*bool*/\nsubborrow_u25(u8 /*bool*/ c, u32 a, u32 b, u32 *low)\n{\n\t/* This function extracts 25 bits of result and 1 bit of borrow\n\t * (26 total), so a 32-bit intermediate is sufficient.\n\t */\n\tu32 x = a - b - c;\n\t*low = x & ((1 << 25) - 1);\n\treturn x >> 31;\n}\n\nstatic __always_inline u8 /*bool*/\nsubborrow_u26(u8 /*bool*/ c, u32 a, u32 b, u32 *low)\n{\n\t/* This function extracts 26 bits of result and 1 bit of borrow\n\t *(27 total), so a 32-bit intermediate is sufficient.\n\t */\n\tu32 x = a - b - c;\n\t*low = x & ((1 << 26) - 1);\n\treturn x >> 31;\n}\n\nstatic __always_inline u32 cmovznz32(u32 t, u32 z, u32 nz)\n{\n\tt = -!!t; /* all set if nonzero, 0 if 0 */\n\treturn (t&nz) | ((~t)&z);\n}\n\nstatic __always_inline void fe_freeze(u32 out[10], const u32 in1[10])\n{\n\t{ const u32 x17 = in1[9];\n\t{ const u32 x18 = in1[8];\n\t{ const u32 x16 = in1[7];\n\t{ const u32 x14 = in1[6];\n\t{ const u32 x12 = in1[5];\n\t{ const u32 x10 = in1[4];\n\t{ const u32 x8 = in1[3];\n\t{ const u32 x6 = in1[2];\n\t{ const u32 x4 = in1[1];\n\t{ const u32 x2 = in1[0];\n\t{ u32 x20; u8/*bool*/ x21 = subborrow_u26(0x0, x2, 0x3ffffed, &x20);\n\t{ u32 x23; u8/*bool*/ x24 = subborrow_u25(x21, x4, 0x1ffffff, &x23);\n\t{ u32 x26; u8/*bool*/ x27 = subborrow_u26(x24, x6, 0x3ffffff, &x26);\n\t{ u32 x29; u8/*bool*/ x30 = subborrow_u25(x27, x8, 0x1ffffff, &x29);\n\t{ u32 x32; u8/*bool*/ x33 = subborrow_u26(x30, x10, 0x3ffffff, &x32);\n\t{ u32 x35; u8/*bool*/ x36 = subborrow_u25(x33, x12, 0x1ffffff, &x35);\n\t{ u32 x38; u8/*bool*/ x39 = subborrow_u26(x36, x14, 0x3ffffff, &x38);\n\t{ u32 x41; u8/*bool*/ x42 = subborrow_u25(x39, x16, 0x1ffffff, &x41);\n\t{ u32 x44; u8/*bool*/ x45 = subborrow_u26(x42, x18, 0x3ffffff, &x44);\n\t{ u32 x47; u8/*bool*/ x48 = subborrow_u25(x45, x17, 0x1ffffff, &x47);\n\t{ u32 x49 = cmovznz32(x48, 0x0, 0xffffffff);\n\t{ u32 x50 = (x49 & 0x3ffffed);\n\t{ u32 x52; u8/*bool*/ x53 = addcarryx_u26(0x0, x20, x50, &x52);\n\t{ u32 x54 = (x49 & 0x1ffffff);\n\t{ u32 x56; u8/*bool*/ x57 = addcarryx_u25(x53, x23, x54, &x56);\n\t{ u32 x58 = (x49 & 0x3ffffff);\n\t{ u32 x60; u8/*bool*/ x61 = addcarryx_u26(x57, x26, x58, &x60);\n\t{ u32 x62 = (x49 & 0x1ffffff);\n\t{ u32 x64; u8/*bool*/ x65 = addcarryx_u25(x61, x29, x62, &x64);\n\t{ u32 x66 = (x49 & 0x3ffffff);\n\t{ u32 x68; u8/*bool*/ x69 = addcarryx_u26(x65, x32, x66, &x68);\n\t{ u32 x70 = (x49 & 0x1ffffff);\n\t{ u32 x72; u8/*bool*/ x73 = addcarryx_u25(x69, x35, x70, &x72);\n\t{ u32 x74 = (x49 & 0x3ffffff);\n\t{ u32 x76; u8/*bool*/ x77 = addcarryx_u26(x73, x38, x74, &x76);\n\t{ u32 x78 = (x49 & 0x1ffffff);\n\t{ u32 x80; u8/*bool*/ x81 = addcarryx_u25(x77, x41, x78, &x80);\n\t{ u32 x82 = (x49 & 0x3ffffff);\n\t{ u32 x84; u8/*bool*/ x85 = addcarryx_u26(x81, x44, x82, &x84);\n\t{ u32 x86 = (x49 & 0x1ffffff);\n\t{ u32 x88; addcarryx_u25(x85, x47, x86, &x88);\n\tout[0] = x52;\n\tout[1] = x56;\n\tout[2] = x60;\n\tout[3] = x64;\n\tout[4] = x68;\n\tout[5] = x72;\n\tout[6] = x76;\n\tout[7] = x80;\n\tout[8] = x84;\n\tout[9] = x88;\n\t}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n}\n\nstatic __always_inline void fe_tobytes(u8 s[32], const fe *f)\n{\n\tu32 h[10];\n\tfe_freeze(h, f->v);\n\ts[0] = h[0] >> 0;\n\ts[1] = h[0] >> 8;\n\ts[2] = h[0] >> 16;\n\ts[3] = (h[0] >> 24) | (h[1] << 2);\n\ts[4] = h[1] >> 6;\n\ts[5] = h[1] >> 14;\n\ts[6] = (h[1] >> 22) | (h[2] << 3);\n\ts[7] = h[2] >> 5;\n\ts[8] = h[2] >> 13;\n\ts[9] = (h[2] >> 21) | (h[3] << 5);\n\ts[10] = h[3] >> 3;\n\ts[11] = h[3] >> 11;\n\ts[12] = (h[3] >> 19) | (h[4] << 6);\n\ts[13] = h[4] >> 2;\n\ts[14] = h[4] >> 10;\n\ts[15] = h[4] >> 18;\n\ts[16] = h[5] >> 0;\n\ts[17] = h[5] >> 8;\n\ts[18] = h[5] >> 16;\n\ts[19] = (h[5] >> 24) | (h[6] << 1);\n\ts[20] = h[6] >> 7;\n\ts[21] = h[6] >> 15;\n\ts[22] = (h[6] >> 23) | (h[7] << 3);\n\ts[23] = h[7] >> 5;\n\ts[24] = h[7] >> 13;\n\ts[25] = (h[7] >> 21) | (h[8] << 4);\n\ts[26] = h[8] >> 4;\n\ts[27] = h[8] >> 12;\n\ts[28] = (h[8] >> 20) | (h[9] << 6);\n\ts[29] = h[9] >> 2;\n\ts[30] = h[9] >> 10;\n\ts[31] = h[9] >> 18;\n}\n\n/* h = f */\nstatic __always_inline void fe_copy(fe *h, const fe *f)\n{\n\tmemmove(h, f, sizeof(u32) * 10);\n}\n\nstatic __always_inline void fe_copy_lt(fe_loose *h, const fe *f)\n{\n\tmemmove(h, f, sizeof(u32) * 10);\n}\n\n/* h = 0 */\nstatic __always_inline void fe_0(fe *h)\n{\n\tmemset(h, 0, sizeof(u32) * 10);\n}\n\n/* h = 1 */\nstatic __always_inline void fe_1(fe *h)\n{\n\tmemset(h, 0, sizeof(u32) * 10);\n\th->v[0] = 1;\n}\n\nstatic void fe_add_impl(u32 out[10], const u32 in1[10], const u32 in2[10])\n{\n\t{ const u32 x20 = in1[9];\n\t{ const u32 x21 = in1[8];\n\t{ const u32 x19 = in1[7];\n\t{ const u32 x17 = in1[6];\n\t{ const u32 x15 = in1[5];\n\t{ const u32 x13 = in1[4];\n\t{ const u32 x11 = in1[3];\n\t{ const u32 x9 = in1[2];\n\t{ const u32 x7 = in1[1];\n\t{ const u32 x5 = in1[0];\n\t{ const u32 x38 = in2[9];\n\t{ const u32 x39 = in2[8];\n\t{ const u32 x37 = in2[7];\n\t{ const u32 x35 = in2[6];\n\t{ const u32 x33 = in2[5];\n\t{ const u32 x31 = in2[4];\n\t{ const u32 x29 = in2[3];\n\t{ const u32 x27 = in2[2];\n\t{ const u32 x25 = in2[1];\n\t{ const u32 x23 = in2[0];\n\tout[0] = (x5 + x23);\n\tout[1] = (x7 + x25);\n\tout[2] = (x9 + x27);\n\tout[3] = (x11 + x29);\n\tout[4] = (x13 + x31);\n\tout[5] = (x15 + x33);\n\tout[6] = (x17 + x35);\n\tout[7] = (x19 + x37);\n\tout[8] = (x21 + x39);\n\tout[9] = (x20 + x38);\n\t}}}}}}}}}}}}}}}}}}}}\n}\n\n/* h = f + g\n * Can overlap h with f or g.\n */\nstatic __always_inline void fe_add(fe_loose *h, const fe *f, const fe *g)\n{\n\tfe_add_impl(h->v, f->v, g->v);\n}\n\nstatic void fe_sub_impl(u32 out[10], const u32 in1[10], const u32 in2[10])\n{\n\t{ const u32 x20 = in1[9];\n\t{ const u32 x21 = in1[8];\n\t{ const u32 x19 = in1[7];\n\t{ const u32 x17 = in1[6];\n\t{ const u32 x15 = in1[5];\n\t{ const u32 x13 = in1[4];\n\t{ const u32 x11 = in1[3];\n\t{ const u32 x9 = in1[2];\n\t{ const u32 x7 = in1[1];\n\t{ const u32 x5 = in1[0];\n\t{ const u32 x38 = in2[9];\n\t{ const u32 x39 = in2[8];\n\t{ const u32 x37 = in2[7];\n\t{ const u32 x35 = in2[6];\n\t{ const u32 x33 = in2[5];\n\t{ const u32 x31 = in2[4];\n\t{ const u32 x29 = in2[3];\n\t{ const u32 x27 = in2[2];\n\t{ const u32 x25 = in2[1];\n\t{ const u32 x23 = in2[0];\n\tout[0] = ((0x7ffffda + x5) - x23);\n\tout[1] = ((0x3fffffe + x7) - x25);\n\tout[2] = ((0x7fffffe + x9) - x27);\n\tout[3] = ((0x3fffffe + x11) - x29);\n\tout[4] = ((0x7fffffe + x13) - x31);\n\tout[5] = ((0x3fffffe + x15) - x33);\n\tout[6] = ((0x7fffffe + x17) - x35);\n\tout[7] = ((0x3fffffe + x19) - x37);\n\tout[8] = ((0x7fffffe + x21) - x39);\n\tout[9] = ((0x3fffffe + x20) - x38);\n\t}}}}}}}}}}}}}}}}}}}}\n}\n\n/* h = f - g\n * Can overlap h with f or g.\n */\nstatic __always_inline void fe_sub(fe_loose *h, const fe *f, const fe *g)\n{\n\tfe_sub_impl(h->v, f->v, g->v);\n}\n\nstatic void fe_mul_impl(u32 out[10], const u32 in1[10], const u32 in2[10])\n{\n\t{ const u32 x20 = in1[9];\n\t{ const u32 x21 = in1[8];\n\t{ const u32 x19 = in1[7];\n\t{ const u32 x17 = in1[6];\n\t{ const u32 x15 = in1[5];\n\t{ const u32 x13 = in1[4];\n\t{ const u32 x11 = in1[3];\n\t{ const u32 x9 = in1[2];\n\t{ const u32 x7 = in1[1];\n\t{ const u32 x5 = in1[0];\n\t{ const u32 x38 = in2[9];\n\t{ const u32 x39 = in2[8];\n\t{ const u32 x37 = in2[7];\n\t{ const u32 x35 = in2[6];\n\t{ const u32 x33 = in2[5];\n\t{ const u32 x31 = in2[4];\n\t{ const u32 x29 = in2[3];\n\t{ const u32 x27 = in2[2];\n\t{ const u32 x25 = in2[1];\n\t{ const u32 x23 = in2[0];\n\t{ u64 x40 = ((u64)x23 * x5);\n\t{ u64 x41 = (((u64)x23 * x7) + ((u64)x25 * x5));\n\t{ u64 x42 = ((((u64)(0x2 * x25) * x7) + ((u64)x23 * x9)) + ((u64)x27 * x5));\n\t{ u64 x43 = (((((u64)x25 * x9) + ((u64)x27 * x7)) + ((u64)x23 * x11)) + ((u64)x29 * x5));\n\t{ u64 x44 = (((((u64)x27 * x9) + (0x2 * (((u64)x25 * x11) + ((u64)x29 * x7)))) + ((u64)x23 * x13)) + ((u64)x31 * x5));\n\t{ u64 x45 = (((((((u64)x27 * x11) + ((u64)x29 * x9)) + ((u64)x25 * x13)) + ((u64)x31 * x7)) + ((u64)x23 * x15)) + ((u64)x33 * x5));\n\t{ u64 x46 = (((((0x2 * ((((u64)x29 * x11) + ((u64)x25 * x15)) + ((u64)x33 * x7))) + ((u64)x27 * x13)) + ((u64)x31 * x9)) + ((u64)x23 * x17)) + ((u64)x35 * x5));\n\t{ u64 x47 = (((((((((u64)x29 * x13) + ((u64)x31 * x11)) + ((u64)x27 * x15)) + ((u64)x33 * x9)) + ((u64)x25 * x17)) + ((u64)x35 * x7)) + ((u64)x23 * x19)) + ((u64)x37 * x5));\n\t{ u64 x48 = (((((((u64)x31 * x13) + (0x2 * (((((u64)x29 * x15) + ((u64)x33 * x11)) + ((u64)x25 * x19)) + ((u64)x37 * x7)))) + ((u64)x27 * x17)) + ((u64)x35 * x9)) + ((u64)x23 * x21)) + ((u64)x39 * x5));\n\t{ u64 x49 = (((((((((((u64)x31 * x15) + ((u64)x33 * x13)) + ((u64)x29 * x17)) + ((u64)x35 * x11)) + ((u64)x27 * x19)) + ((u64)x37 * x9)) + ((u64)x25 * x21)) + ((u64)x39 * x7)) + ((u64)x23 * x20)) + ((u64)x38 * x5));\n\t{ u64 x50 = (((((0x2 * ((((((u64)x33 * x15) + ((u64)x29 * x19)) + ((u64)x37 * x11)) + ((u64)x25 * x20)) + ((u64)x38 * x7))) + ((u64)x31 * x17)) + ((u64)x35 * x13)) + ((u64)x27 * x21)) + ((u64)x39 * x9));\n\t{ u64 x51 = (((((((((u64)x33 * x17) + ((u64)x35 * x15)) + ((u64)x31 * x19)) + ((u64)x37 * x13)) + ((u64)x29 * x21)) + ((u64)x39 * x11)) + ((u64)x27 * x20)) + ((u64)x38 * x9));\n\t{ u64 x52 = (((((u64)x35 * x17) + (0x2 * (((((u64)x33 * x19) + ((u64)x37 * x15)) + ((u64)x29 * x20)) + ((u64)x38 * x11)))) + ((u64)x31 * x21)) + ((u64)x39 * x13));\n\t{ u64 x53 = (((((((u64)x35 * x19) + ((u64)x37 * x17)) + ((u64)x33 * x21)) + ((u64)x39 * x15)) + ((u64)x31 * x20)) + ((u64)x38 * x13));\n\t{ u64 x54 = (((0x2 * ((((u64)x37 * x19) + ((u64)x33 * x20)) + ((u64)x38 * x15))) + ((u64)x35 * x21)) + ((u64)x39 * x17));\n\t{ u64 x55 = (((((u64)x37 * x21) + ((u64)x39 * x19)) + ((u64)x35 * x20)) + ((u64)x38 * x17));\n\t{ u64 x56 = (((u64)x39 * x21) + (0x2 * (((u64)x37 * x20) + ((u64)x38 * x19))));\n\t{ u64 x57 = (((u64)x39 * x20) + ((u64)x38 * x21));\n\t{ u64 x58 = ((u64)(0x2 * x38) * x20);\n\t{ u64 x59 = (x48 + (x58 << 0x4));\n\t{ u64 x60 = (x59 + (x58 << 0x1));\n\t{ u64 x61 = (x60 + x58);\n\t{ u64 x62 = (x47 + (x57 << 0x4));\n\t{ u64 x63 = (x62 + (x57 << 0x1));\n\t{ u64 x64 = (x63 + x57);\n\t{ u64 x65 = (x46 + (x56 << 0x4));\n\t{ u64 x66 = (x65 + (x56 << 0x1));\n\t{ u64 x67 = (x66 + x56);\n\t{ u64 x68 = (x45 + (x55 << 0x4));\n\t{ u64 x69 = (x68 + (x55 << 0x1));\n\t{ u64 x70 = (x69 + x55);\n\t{ u64 x71 = (x44 + (x54 << 0x4));\n\t{ u64 x72 = (x71 + (x54 << 0x1));\n\t{ u64 x73 = (x72 + x54);\n\t{ u64 x74 = (x43 + (x53 << 0x4));\n\t{ u64 x75 = (x74 + (x53 << 0x1));\n\t{ u64 x76 = (x75 + x53);\n\t{ u64 x77 = (x42 + (x52 << 0x4));\n\t{ u64 x78 = (x77 + (x52 << 0x1));\n\t{ u64 x79 = (x78 + x52);\n\t{ u64 x80 = (x41 + (x51 << 0x4));\n\t{ u64 x81 = (x80 + (x51 << 0x1));\n\t{ u64 x82 = (x81 + x51);\n\t{ u64 x83 = (x40 + (x50 << 0x4));\n\t{ u64 x84 = (x83 + (x50 << 0x1));\n\t{ u64 x85 = (x84 + x50);\n\t{ u64 x86 = (x85 >> 0x1a);\n\t{ u32 x87 = ((u32)x85 & 0x3ffffff);\n\t{ u64 x88 = (x86 + x82);\n\t{ u64 x89 = (x88 >> 0x19);\n\t{ u32 x90 = ((u32)x88 & 0x1ffffff);\n\t{ u64 x91 = (x89 + x79);\n\t{ u64 x92 = (x91 >> 0x1a);\n\t{ u32 x93 = ((u32)x91 & 0x3ffffff);\n\t{ u64 x94 = (x92 + x76);\n\t{ u64 x95 = (x94 >> 0x19);\n\t{ u32 x96 = ((u32)x94 & 0x1ffffff);\n\t{ u64 x97 = (x95 + x73);\n\t{ u64 x98 = (x97 >> 0x1a);\n\t{ u32 x99 = ((u32)x97 & 0x3ffffff);\n\t{ u64 x100 = (x98 + x70);\n\t{ u64 x101 = (x100 >> 0x19);\n\t{ u32 x102 = ((u32)x100 & 0x1ffffff);\n\t{ u64 x103 = (x101 + x67);\n\t{ u64 x104 = (x103 >> 0x1a);\n\t{ u32 x105 = ((u32)x103 & 0x3ffffff);\n\t{ u64 x106 = (x104 + x64);\n\t{ u64 x107 = (x106 >> 0x19);\n\t{ u32 x108 = ((u32)x106 & 0x1ffffff);\n\t{ u64 x109 = (x107 + x61);\n\t{ u64 x110 = (x109 >> 0x1a);\n\t{ u32 x111 = ((u32)x109 & 0x3ffffff);\n\t{ u64 x112 = (x110 + x49);\n\t{ u64 x113 = (x112 >> 0x19);\n\t{ u32 x114 = ((u32)x112 & 0x1ffffff);\n\t{ u64 x115 = (x87 + (0x13 * x113));\n\t{ u32 x116 = (u32) (x115 >> 0x1a);\n\t{ u32 x117 = ((u32)x115 & 0x3ffffff);\n\t{ u32 x118 = (x116 + x90);\n\t{ u32 x119 = (x118 >> 0x19);\n\t{ u32 x120 = (x118 & 0x1ffffff);\n\tout[0] = x117;\n\tout[1] = x120;\n\tout[2] = (x119 + x93);\n\tout[3] = x96;\n\tout[4] = x99;\n\tout[5] = x102;\n\tout[6] = x105;\n\tout[7] = x108;\n\tout[8] = x111;\n\tout[9] = x114;\n\t}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n}\n\nstatic __always_inline void fe_mul_ttt(fe *h, const fe *f, const fe *g)\n{\n\tfe_mul_impl(h->v, f->v, g->v);\n}\n\nstatic __always_inline void fe_mul_tlt(fe *h, const fe_loose *f, const fe *g)\n{\n\tfe_mul_impl(h->v, f->v, g->v);\n}\n\nstatic __always_inline void\nfe_mul_tll(fe *h, const fe_loose *f, const fe_loose *g)\n{\n\tfe_mul_impl(h->v, f->v, g->v);\n}\n\nstatic void fe_sqr_impl(u32 out[10], const u32 in1[10])\n{\n\t{ const u32 x17 = in1[9];\n\t{ const u32 x18 = in1[8];\n\t{ const u32 x16 = in1[7];\n\t{ const u32 x14 = in1[6];\n\t{ const u32 x12 = in1[5];\n\t{ const u32 x10 = in1[4];\n\t{ const u32 x8 = in1[3];\n\t{ const u32 x6 = in1[2];\n\t{ const u32 x4 = in1[1];\n\t{ const u32 x2 = in1[0];\n\t{ u64 x19 = ((u64)x2 * x2);\n\t{ u64 x20 = ((u64)(0x2 * x2) * x4);\n\t{ u64 x21 = (0x2 * (((u64)x4 * x4) + ((u64)x2 * x6)));\n\t{ u64 x22 = (0x2 * (((u64)x4 * x6) + ((u64)x2 * x8)));\n\t{ u64 x23 = ((((u64)x6 * x6) + ((u64)(0x4 * x4) * x8)) + ((u64)(0x2 * x2) * x10));\n\t{ u64 x24 = (0x2 * ((((u64)x6 * x8) + ((u64)x4 * x10)) + ((u64)x2 * x12)));\n\t{ u64 x25 = (0x2 * (((((u64)x8 * x8) + ((u64)x6 * x10)) + ((u64)x2 * x14)) + ((u64)(0x2 * x4) * x12)));\n\t{ u64 x26 = (0x2 * (((((u64)x8 * x10) + ((u64)x6 * x12)) + ((u64)x4 * x14)) + ((u64)x2 * x16)));\n\t{ u64 x27 = (((u64)x10 * x10) + (0x2 * ((((u64)x6 * x14) + ((u64)x2 * x18)) + (0x2 * (((u64)x4 * x16) + ((u64)x8 * x12))))));\n\t{ u64 x28 = (0x2 * ((((((u64)x10 * x12) + ((u64)x8 * x14)) + ((u64)x6 * x16)) + ((u64)x4 * x18)) + ((u64)x2 * x17)));\n\t{ u64 x29 = (0x2 * (((((u64)x12 * x12) + ((u64)x10 * x14)) + ((u64)x6 * x18)) + (0x2 * (((u64)x8 * x16) + ((u64)x4 * x17)))));\n\t{ u64 x30 = (0x2 * (((((u64)x12 * x14) + ((u64)x10 * x16)) + ((u64)x8 * x18)) + ((u64)x6 * x17)));\n\t{ u64 x31 = (((u64)x14 * x14) + (0x2 * (((u64)x10 * x18) + (0x2 * (((u64)x12 * x16) + ((u64)x8 * x17))))));\n\t{ u64 x32 = (0x2 * ((((u64)x14 * x16) + ((u64)x12 * x18)) + ((u64)x10 * x17)));\n\t{ u64 x33 = (0x2 * ((((u64)x16 * x16) + ((u64)x14 * x18)) + ((u64)(0x2 * x12) * x17)));\n\t{ u64 x34 = (0x2 * (((u64)x16 * x18) + ((u64)x14 * x17)));\n\t{ u64 x35 = (((u64)x18 * x18) + ((u64)(0x4 * x16) * x17));\n\t{ u64 x36 = ((u64)(0x2 * x18) * x17);\n\t{ u64 x37 = ((u64)(0x2 * x17) * x17);\n\t{ u64 x38 = (x27 + (x37 << 0x4));\n\t{ u64 x39 = (x38 + (x37 << 0x1));\n\t{ u64 x40 = (x39 + x37);\n\t{ u64 x41 = (x26 + (x36 << 0x4));\n\t{ u64 x42 = (x41 + (x36 << 0x1));\n\t{ u64 x43 = (x42 + x36);\n\t{ u64 x44 = (x25 + (x35 << 0x4));\n\t{ u64 x45 = (x44 + (x35 << 0x1));\n\t{ u64 x46 = (x45 + x35);\n\t{ u64 x47 = (x24 + (x34 << 0x4));\n\t{ u64 x48 = (x47 + (x34 << 0x1));\n\t{ u64 x49 = (x48 + x34);\n\t{ u64 x50 = (x23 + (x33 << 0x4));\n\t{ u64 x51 = (x50 + (x33 << 0x1));\n\t{ u64 x52 = (x51 + x33);\n\t{ u64 x53 = (x22 + (x32 << 0x4));\n\t{ u64 x54 = (x53 + (x32 << 0x1));\n\t{ u64 x55 = (x54 + x32);\n\t{ u64 x56 = (x21 + (x31 << 0x4));\n\t{ u64 x57 = (x56 + (x31 << 0x1));\n\t{ u64 x58 = (x57 + x31);\n\t{ u64 x59 = (x20 + (x30 << 0x4));\n\t{ u64 x60 = (x59 + (x30 << 0x1));\n\t{ u64 x61 = (x60 + x30);\n\t{ u64 x62 = (x19 + (x29 << 0x4));\n\t{ u64 x63 = (x62 + (x29 << 0x1));\n\t{ u64 x64 = (x63 + x29);\n\t{ u64 x65 = (x64 >> 0x1a);\n\t{ u32 x66 = ((u32)x64 & 0x3ffffff);\n\t{ u64 x67 = (x65 + x61);\n\t{ u64 x68 = (x67 >> 0x19);\n\t{ u32 x69 = ((u32)x67 & 0x1ffffff);\n\t{ u64 x70 = (x68 + x58);\n\t{ u64 x71 = (x70 >> 0x1a);\n\t{ u32 x72 = ((u32)x70 & 0x3ffffff);\n\t{ u64 x73 = (x71 + x55);\n\t{ u64 x74 = (x73 >> 0x19);\n\t{ u32 x75 = ((u32)x73 & 0x1ffffff);\n\t{ u64 x76 = (x74 + x52);\n\t{ u64 x77 = (x76 >> 0x1a);\n\t{ u32 x78 = ((u32)x76 & 0x3ffffff);\n\t{ u64 x79 = (x77 + x49);\n\t{ u64 x80 = (x79 >> 0x19);\n\t{ u32 x81 = ((u32)x79 & 0x1ffffff);\n\t{ u64 x82 = (x80 + x46);\n\t{ u64 x83 = (x82 >> 0x1a);\n\t{ u32 x84 = ((u32)x82 & 0x3ffffff);\n\t{ u64 x85 = (x83 + x43);\n\t{ u64 x86 = (x85 >> 0x19);\n\t{ u32 x87 = ((u32)x85 & 0x1ffffff);\n\t{ u64 x88 = (x86 + x40);\n\t{ u64 x89 = (x88 >> 0x1a);\n\t{ u32 x90 = ((u32)x88 & 0x3ffffff);\n\t{ u64 x91 = (x89 + x28);\n\t{ u64 x92 = (x91 >> 0x19);\n\t{ u32 x93 = ((u32)x91 & 0x1ffffff);\n\t{ u64 x94 = (x66 + (0x13 * x92));\n\t{ u32 x95 = (u32) (x94 >> 0x1a);\n\t{ u32 x96 = ((u32)x94 & 0x3ffffff);\n\t{ u32 x97 = (x95 + x69);\n\t{ u32 x98 = (x97 >> 0x19);\n\t{ u32 x99 = (x97 & 0x1ffffff);\n\tout[0] = x96;\n\tout[1] = x99;\n\tout[2] = (x98 + x72);\n\tout[3] = x75;\n\tout[4] = x78;\n\tout[5] = x81;\n\tout[6] = x84;\n\tout[7] = x87;\n\tout[8] = x90;\n\tout[9] = x93;\n\t}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n}\n\nstatic __always_inline void fe_sq_tl(fe *h, const fe_loose *f)\n{\n\tfe_sqr_impl(h->v, f->v);\n}\n\nstatic __always_inline void fe_sq_tt(fe *h, const fe *f)\n{\n\tfe_sqr_impl(h->v, f->v);\n}\n\nstatic __always_inline void fe_loose_invert(fe *out, const fe_loose *z)\n{\n\tfe t0;\n\tfe t1;\n\tfe t2;\n\tfe t3;\n\tint i;\n\n\tfe_sq_tl(&t0, z);\n\tfe_sq_tt(&t1, &t0);\n\tfor (i = 1; i < 2; ++i)\n\t\tfe_sq_tt(&t1, &t1);\n\tfe_mul_tlt(&t1, z, &t1);\n\tfe_mul_ttt(&t0, &t0, &t1);\n\tfe_sq_tt(&t2, &t0);\n\tfe_mul_ttt(&t1, &t1, &t2);\n\tfe_sq_tt(&t2, &t1);\n\tfor (i = 1; i < 5; ++i)\n\t\tfe_sq_tt(&t2, &t2);\n\tfe_mul_ttt(&t1, &t2, &t1);\n\tfe_sq_tt(&t2, &t1);\n\tfor (i = 1; i < 10; ++i)\n\t\tfe_sq_tt(&t2, &t2);\n\tfe_mul_ttt(&t2, &t2, &t1);\n\tfe_sq_tt(&t3, &t2);\n\tfor (i = 1; i < 20; ++i)\n\t\tfe_sq_tt(&t3, &t3);\n\tfe_mul_ttt(&t2, &t3, &t2);\n\tfe_sq_tt(&t2, &t2);\n\tfor (i = 1; i < 10; ++i)\n\t\tfe_sq_tt(&t2, &t2);\n\tfe_mul_ttt(&t1, &t2, &t1);\n\tfe_sq_tt(&t2, &t1);\n\tfor (i = 1; i < 50; ++i)\n\t\tfe_sq_tt(&t2, &t2);\n\tfe_mul_ttt(&t2, &t2, &t1);\n\tfe_sq_tt(&t3, &t2);\n\tfor (i = 1; i < 100; ++i)\n\t\tfe_sq_tt(&t3, &t3);\n\tfe_mul_ttt(&t2, &t3, &t2);\n\tfe_sq_tt(&t2, &t2);\n\tfor (i = 1; i < 50; ++i)\n\t\tfe_sq_tt(&t2, &t2);\n\tfe_mul_ttt(&t1, &t2, &t1);\n\tfe_sq_tt(&t1, &t1);\n\tfor (i = 1; i < 5; ++i)\n\t\tfe_sq_tt(&t1, &t1);\n\tfe_mul_ttt(out, &t1, &t0);\n}\n\nstatic __always_inline void fe_invert(fe *out, const fe *z)\n{\n\tfe_loose l;\n\tfe_copy_lt(&l, z);\n\tfe_loose_invert(out, &l);\n}\n\n/* Replace (f,g) with (g,f) if b == 1;\n * replace (f,g) with (f,g) if b == 0.\n *\n * Preconditions: b in {0,1}\n */\nstatic __always_inline void fe_cswap(fe *f, fe *g, unsigned int b)\n{\n\tunsigned i;\n\tb = 0 - b;\n\tfor (i = 0; i < 10; i++) {\n\t\tu32 x = f->v[i] ^ g->v[i];\n\t\tx &= b;\n\t\tf->v[i] ^= x;\n\t\tg->v[i] ^= x;\n\t}\n}\n\n/* NOTE: based on fiat-crypto fe_mul, edited for in2=121666, 0, 0.*/\nstatic __always_inline void fe_mul_121666_impl(u32 out[10], const u32 in1[10])\n{\n\t{ const u32 x20 = in1[9];\n\t{ const u32 x21 = in1[8];\n\t{ const u32 x19 = in1[7];\n\t{ const u32 x17 = in1[6];\n\t{ const u32 x15 = in1[5];\n\t{ const u32 x13 = in1[4];\n\t{ const u32 x11 = in1[3];\n\t{ const u32 x9 = in1[2];\n\t{ const u32 x7 = in1[1];\n\t{ const u32 x5 = in1[0];\n\t{ const u32 x38 = 0;\n\t{ const u32 x39 = 0;\n\t{ const u32 x37 = 0;\n\t{ const u32 x35 = 0;\n\t{ const u32 x33 = 0;\n\t{ const u32 x31 = 0;\n\t{ const u32 x29 = 0;\n\t{ const u32 x27 = 0;\n\t{ const u32 x25 = 0;\n\t{ const u32 x23 = 121666;\n\t{ u64 x40 = ((u64)x23 * x5);\n\t{ u64 x41 = (((u64)x23 * x7) + ((u64)x25 * x5));\n\t{ u64 x42 = ((((u64)(0x2 * x25) * x7) + ((u64)x23 * x9)) + ((u64)x27 * x5));\n\t{ u64 x43 = (((((u64)x25 * x9) + ((u64)x27 * x7)) + ((u64)x23 * x11)) + ((u64)x29 * x5));\n\t{ u64 x44 = (((((u64)x27 * x9) + (0x2 * (((u64)x25 * x11) + ((u64)x29 * x7)))) + ((u64)x23 * x13)) + ((u64)x31 * x5));\n\t{ u64 x45 = (((((((u64)x27 * x11) + ((u64)x29 * x9)) + ((u64)x25 * x13)) + ((u64)x31 * x7)) + ((u64)x23 * x15)) + ((u64)x33 * x5));\n\t{ u64 x46 = (((((0x2 * ((((u64)x29 * x11) + ((u64)x25 * x15)) + ((u64)x33 * x7))) + ((u64)x27 * x13)) + ((u64)x31 * x9)) + ((u64)x23 * x17)) + ((u64)x35 * x5));\n\t{ u64 x47 = (((((((((u64)x29 * x13) + ((u64)x31 * x11)) + ((u64)x27 * x15)) + ((u64)x33 * x9)) + ((u64)x25 * x17)) + ((u64)x35 * x7)) + ((u64)x23 * x19)) + ((u64)x37 * x5));\n\t{ u64 x48 = (((((((u64)x31 * x13) + (0x2 * (((((u64)x29 * x15) + ((u64)x33 * x11)) + ((u64)x25 * x19)) + ((u64)x37 * x7)))) + ((u64)x27 * x17)) + ((u64)x35 * x9)) + ((u64)x23 * x21)) + ((u64)x39 * x5));\n\t{ u64 x49 = (((((((((((u64)x31 * x15) + ((u64)x33 * x13)) + ((u64)x29 * x17)) + ((u64)x35 * x11)) + ((u64)x27 * x19)) + ((u64)x37 * x9)) + ((u64)x25 * x21)) + ((u64)x39 * x7)) + ((u64)x23 * x20)) + ((u64)x38 * x5));\n\t{ u64 x50 = (((((0x2 * ((((((u64)x33 * x15) + ((u64)x29 * x19)) + ((u64)x37 * x11)) + ((u64)x25 * x20)) + ((u64)x38 * x7))) + ((u64)x31 * x17)) + ((u64)x35 * x13)) + ((u64)x27 * x21)) + ((u64)x39 * x9));\n\t{ u64 x51 = (((((((((u64)x33 * x17) + ((u64)x35 * x15)) + ((u64)x31 * x19)) + ((u64)x37 * x13)) + ((u64)x29 * x21)) + ((u64)x39 * x11)) + ((u64)x27 * x20)) + ((u64)x38 * x9));\n\t{ u64 x52 = (((((u64)x35 * x17) + (0x2 * (((((u64)x33 * x19) + ((u64)x37 * x15)) + ((u64)x29 * x20)) + ((u64)x38 * x11)))) + ((u64)x31 * x21)) + ((u64)x39 * x13));\n\t{ u64 x53 = (((((((u64)x35 * x19) + ((u64)x37 * x17)) + ((u64)x33 * x21)) + ((u64)x39 * x15)) + ((u64)x31 * x20)) + ((u64)x38 * x13));\n\t{ u64 x54 = (((0x2 * ((((u64)x37 * x19) + ((u64)x33 * x20)) + ((u64)x38 * x15))) + ((u64)x35 * x21)) + ((u64)x39 * x17));\n\t{ u64 x55 = (((((u64)x37 * x21) + ((u64)x39 * x19)) + ((u64)x35 * x20)) + ((u64)x38 * x17));\n\t{ u64 x56 = (((u64)x39 * x21) + (0x2 * (((u64)x37 * x20) + ((u64)x38 * x19))));\n\t{ u64 x57 = (((u64)x39 * x20) + ((u64)x38 * x21));\n\t{ u64 x58 = ((u64)(0x2 * x38) * x20);\n\t{ u64 x59 = (x48 + (x58 << 0x4));\n\t{ u64 x60 = (x59 + (x58 << 0x1));\n\t{ u64 x61 = (x60 + x58);\n\t{ u64 x62 = (x47 + (x57 << 0x4));\n\t{ u64 x63 = (x62 + (x57 << 0x1));\n\t{ u64 x64 = (x63 + x57);\n\t{ u64 x65 = (x46 + (x56 << 0x4));\n\t{ u64 x66 = (x65 + (x56 << 0x1));\n\t{ u64 x67 = (x66 + x56);\n\t{ u64 x68 = (x45 + (x55 << 0x4));\n\t{ u64 x69 = (x68 + (x55 << 0x1));\n\t{ u64 x70 = (x69 + x55);\n\t{ u64 x71 = (x44 + (x54 << 0x4));\n\t{ u64 x72 = (x71 + (x54 << 0x1));\n\t{ u64 x73 = (x72 + x54);\n\t{ u64 x74 = (x43 + (x53 << 0x4));\n\t{ u64 x75 = (x74 + (x53 << 0x1));\n\t{ u64 x76 = (x75 + x53);\n\t{ u64 x77 = (x42 + (x52 << 0x4));\n\t{ u64 x78 = (x77 + (x52 << 0x1));\n\t{ u64 x79 = (x78 + x52);\n\t{ u64 x80 = (x41 + (x51 << 0x4));\n\t{ u64 x81 = (x80 + (x51 << 0x1));\n\t{ u64 x82 = (x81 + x51);\n\t{ u64 x83 = (x40 + (x50 << 0x4));\n\t{ u64 x84 = (x83 + (x50 << 0x1));\n\t{ u64 x85 = (x84 + x50);\n\t{ u64 x86 = (x85 >> 0x1a);\n\t{ u32 x87 = ((u32)x85 & 0x3ffffff);\n\t{ u64 x88 = (x86 + x82);\n\t{ u64 x89 = (x88 >> 0x19);\n\t{ u32 x90 = ((u32)x88 & 0x1ffffff);\n\t{ u64 x91 = (x89 + x79);\n\t{ u64 x92 = (x91 >> 0x1a);\n\t{ u32 x93 = ((u32)x91 & 0x3ffffff);\n\t{ u64 x94 = (x92 + x76);\n\t{ u64 x95 = (x94 >> 0x19);\n\t{ u32 x96 = ((u32)x94 & 0x1ffffff);\n\t{ u64 x97 = (x95 + x73);\n\t{ u64 x98 = (x97 >> 0x1a);\n\t{ u32 x99 = ((u32)x97 & 0x3ffffff);\n\t{ u64 x100 = (x98 + x70);\n\t{ u64 x101 = (x100 >> 0x19);\n\t{ u32 x102 = ((u32)x100 & 0x1ffffff);\n\t{ u64 x103 = (x101 + x67);\n\t{ u64 x104 = (x103 >> 0x1a);\n\t{ u32 x105 = ((u32)x103 & 0x3ffffff);\n\t{ u64 x106 = (x104 + x64);\n\t{ u64 x107 = (x106 >> 0x19);\n\t{ u32 x108 = ((u32)x106 & 0x1ffffff);\n\t{ u64 x109 = (x107 + x61);\n\t{ u64 x110 = (x109 >> 0x1a);\n\t{ u32 x111 = ((u32)x109 & 0x3ffffff);\n\t{ u64 x112 = (x110 + x49);\n\t{ u64 x113 = (x112 >> 0x19);\n\t{ u32 x114 = ((u32)x112 & 0x1ffffff);\n\t{ u64 x115 = (x87 + (0x13 * x113));\n\t{ u32 x116 = (u32) (x115 >> 0x1a);\n\t{ u32 x117 = ((u32)x115 & 0x3ffffff);\n\t{ u32 x118 = (x116 + x90);\n\t{ u32 x119 = (x118 >> 0x19);\n\t{ u32 x120 = (x118 & 0x1ffffff);\n\tout[0] = x117;\n\tout[1] = x120;\n\tout[2] = (x119 + x93);\n\tout[3] = x96;\n\tout[4] = x99;\n\tout[5] = x102;\n\tout[6] = x105;\n\tout[7] = x108;\n\tout[8] = x111;\n\tout[9] = x114;\n\t}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n}\n\nstatic __always_inline void fe_mul121666(fe *h, const fe_loose *f)\n{\n\tfe_mul_121666_impl(h->v, f->v);\n}\n\nstatic void curve25519_generic(u8 out[CURVE25519_KEY_SIZE],\n\t\t\t       const u8 scalar[CURVE25519_KEY_SIZE],\n\t\t\t       const u8 point[CURVE25519_KEY_SIZE])\n{\n\tfe x1, x2, z2, x3, z3;\n\tfe_loose x2l, z2l, x3l;\n\tunsigned swap = 0;\n\tint pos;\n\tu8 e[32];\n\n\tmemcpy(e, scalar, 32);\n\tcurve25519_clamp_secret(e);\n\n\t/* The following implementation was transcribed to Coq and proven to\n\t * correspond to unary scalar multiplication in affine coordinates given\n\t * that x1 != 0 is the x coordinate of some point on the curve. It was\n\t * also checked in Coq that doing a ladderstep with x1 = x3 = 0 gives\n\t * z2' = z3' = 0, and z2 = z3 = 0 gives z2' = z3' = 0. The statement was\n\t * quantified over the underlying field, so it applies to Curve25519\n\t * itself and the quadratic twist of Curve25519. It was not proven in\n\t * Coq that prime-field arithmetic correctly simulates extension-field\n\t * arithmetic on prime-field values. The decoding of the byte array\n\t * representation of e was not considered.\n\t *\n\t * Specification of Montgomery curves in affine coordinates:\n\t * <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Spec/MontgomeryCurve.v#L27>\n\t *\n\t * Proof that these form a group that is isomorphic to a Weierstrass\n\t * curve:\n\t * <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/AffineProofs.v#L35>\n\t *\n\t * Coq transcription and correctness proof of the loop\n\t * (where scalarbits=255):\n\t * <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/XZ.v#L118>\n\t * <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/XZProofs.v#L278>\n\t * preconditions: 0 <= e < 2^255 (not necessarily e < order),\n\t * fe_invert(0) = 0\n\t */\n\tfe_frombytes(&x1, point);\n\tfe_1(&x2);\n\tfe_0(&z2);\n\tfe_copy(&x3, &x1);\n\tfe_1(&z3);\n\n\tfor (pos = 254; pos >= 0; --pos) {\n\t\tfe tmp0, tmp1;\n\t\tfe_loose tmp0l, tmp1l;\n\t\t/* loop invariant as of right before the test, for the case\n\t\t * where x1 != 0:\n\t\t *   pos >= -1; if z2 = 0 then x2 is nonzero; if z3 = 0 then x3\n\t\t *   is nonzero\n\t\t *   let r := e >> (pos+1) in the following equalities of\n\t\t *   projective points:\n\t\t *   to_xz (r*P)     === if swap then (x3, z3) else (x2, z2)\n\t\t *   to_xz ((r+1)*P) === if swap then (x2, z2) else (x3, z3)\n\t\t *   x1 is the nonzero x coordinate of the nonzero\n\t\t *   point (r*P-(r+1)*P)\n\t\t */\n\t\tunsigned b = 1 & (e[pos / 8] >> (pos & 7));\n\t\tswap ^= b;\n\t\tfe_cswap(&x2, &x3, swap);\n\t\tfe_cswap(&z2, &z3, swap);\n\t\tswap = b;\n\t\t/* Coq transcription of ladderstep formula (called from\n\t\t * transcribed loop):\n\t\t * <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/XZ.v#L89>\n\t\t * <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/XZProofs.v#L131>\n\t\t * x1 != 0 <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/XZProofs.v#L217>\n\t\t * x1  = 0 <https://github.com/mit-plv/fiat-crypto/blob/2456d821825521f7e03e65882cc3521795b0320f/src/Curves/Montgomery/XZProofs.v#L147>\n\t\t */\n\t\tfe_sub(&tmp0l, &x3, &z3);\n\t\tfe_sub(&tmp1l, &x2, &z2);\n\t\tfe_add(&x2l, &x2, &z2);\n\t\tfe_add(&z2l, &x3, &z3);\n\t\tfe_mul_tll(&z3, &tmp0l, &x2l);\n\t\tfe_mul_tll(&z2, &z2l, &tmp1l);\n\t\tfe_sq_tl(&tmp0, &tmp1l);\n\t\tfe_sq_tl(&tmp1, &x2l);\n\t\tfe_add(&x3l, &z3, &z2);\n\t\tfe_sub(&z2l, &z3, &z2);\n\t\tfe_mul_ttt(&x2, &tmp1, &tmp0);\n\t\tfe_sub(&tmp1l, &tmp1, &tmp0);\n\t\tfe_sq_tl(&z2, &z2l);\n\t\tfe_mul121666(&z3, &tmp1l);\n\t\tfe_sq_tl(&x3, &x3l);\n\t\tfe_add(&tmp0l, &tmp0, &z3);\n\t\tfe_mul_ttt(&z3, &x1, &z2);\n\t\tfe_mul_tll(&z2, &tmp1l, &tmp0l);\n\t}\n\t/* here pos=-1, so r=e, so to_xz (e*P) === if swap then (x3, z3)\n\t * else (x2, z2)\n\t */\n\tfe_cswap(&x2, &x3, swap);\n\tfe_cswap(&z2, &z3, swap);\n\n\tfe_invert(&z2, &z2);\n\tfe_mul_ttt(&x2, &x2, &z2);\n\tfe_tobytes(out, &x2);\n\n\tmemzero_explicit(&x1, sizeof(x1));\n\tmemzero_explicit(&x2, sizeof(x2));\n\tmemzero_explicit(&z2, sizeof(z2));\n\tmemzero_explicit(&x3, sizeof(x3));\n\tmemzero_explicit(&z3, sizeof(z3));\n\tmemzero_explicit(&x2l, sizeof(x2l));\n\tmemzero_explicit(&z2l, sizeof(z2l));\n\tmemzero_explicit(&x3l, sizeof(x3l));\n\tmemzero_explicit(&e, sizeof(e));\n}\n\n# Spark\n### Sparklines for Your Shell\n\nHere's a graph of your productivity gains after using `spark`: \u2581\u2582\u2583\u2585\u2587\n\n## Installation\n\nSimply run `make` and `sudo make install`. The `DESTDIR` controls prefix, which is `/usr/local` by default.\n\n## Usage\n\nJust run `spark` and pass it a space deliminated list of numbers. It's designed to be used in conjunction with other\nscripts that can output in that format.\n\n    $ spark 0 30 55 80 33 150\n    \u2581\u2582\u2584\u2585\u2583\u2588\n\nIf no arguments are passed, it will read from stdin a set of numbers delimited by any character except 0 through 9, - (dash), . (period), e, and E.\n\n    $ echo \"7,6, 5, 4 3 2 1\" | spark\n    \u2588\u2587\u2586\u2585\u2584\u2583\u2582\n\nIt's pretty resilient on the input it will take, which should make shell scripting with it easier:\n\n    $ echo \"12,1 6 8*3,1i5i2(4 % 7 =3\" | spark\n    \u2588\u2582\u2585\u2586\u2583\u2582\u2584\u2582\u2583\u2585\u2583\n\nInvoke help with `spark -h`.\n\n## Examples\n\nMagnitude of earthquakes over 1.0 in the last 24 hours:\n\n    $ curl -s http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M1.txt | cut -d, -f9 | spark\n    \u2581\u2582\u2582\u2582\u2581\u2582\u2581\u2581\u2581\u2582\u2581\u2584\u2581\u2582\u2582\u2582\u2583\u2581\u2582\u2582\u2582\u2583\u2583\u2582\u2582\u2582\u2582\u2581\u2581\u2581\u2581\u2581\u2582\u2581\u2582\u2586\u2583\u2582\u2582\u2582\u2582\u2581\u2585\u2582\u2582\u2582\u2586\u2582\u2581\u2582\u2582\u2582\u2582\u2581\u2581\u2582\u2583\u2582\u2583\u2581\u2581\u2581\u2581\u2585\u2582\u2583\u2582\u2584\u2581\u2583\u2581\u2582\u2581\u2582\u2581\u2585\u2581\u2581\u2582\u2585\u2581\u2582\u2581\u2582\u2581\u2581\u2581\u2582\u2581\u2581\u2581\u2581\u2581\u2581\u2583\u2581\u2582\n\nNumber of commits in a git repo per active day:\n\n    $ git log --pretty=format:%ai --reverse | cut -d' ' -f1 | uniq -c | awk '{print $1}' | spark\n    \u2581\u2582\u2584\u2583\u2583\u2582\u2583\u2583\u2584\u2584\u2584\u2583\u2581\u2582\u2581\u2581\u2584\u2583\u2588\u2583\u2582\u2582\u2585\u2584\u2584\u2583\u2582\u2584\u2583\u2587\u2584\u2582\u2584\u2581\u2581\u2582\u2585\u2582\u2582\u2581\u2582\u2581\u2582\u2582\u2584\u2585\u2583\u2582\u2583\u2582\u2582\u2582\u2582\u2584\u2582\u2582\u2581\u2584\u2582\u2581\u2582\u2582\u2583\u2582\u2582\u2582\u2581\u2582\u2582\u2582\u2584\u2582\u2583\u2583\u2586\u2585\u2582\u2582\u2584\u2585\u2583\u2581\u2582\u2581\u2581\u2582\u2581\u2582\u2582\u2584\u2581\u2581\u2582\u2583\u2582\u2582\u2584\n\nCharacters per line in spark.c:\n\n    $ awk '{print length($0)}' spark.c | grep -Ev '^0$' | spark\n    \u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2583\u2581\u2588\u2586\u2586\u2582\u2581\u2582\u2582\u2583\u2583\u2582\u2582\u2584\u2582\u2582\u2582\u2581\u2583\u2583\u2583\u2582\u2583\u2582\u2581\u2582\u2582\u2582\u2582\u2582\u2582\u2584\u2582\u2582\u2582\u2581\u2582\u2582\u2582\u2587\u2582\u2582\u2582\u2582\u2582\u2581\u2582\u2582\u2583\u2582\u2585\u2582\u2583\u2582\u2581\u2581\u2583\u2583\u2583\u2583\u2583\u2582\u2581\u2582\u2581\u2581\u2583\u2582\u2582\u2583\u2583\u2582\u2582\u2587\u2581\u2582\u2582\u2582\u2581\n\n\n#include <stdio.h>\n#include <cv.h>\n#include <highgui.h>\n \nint main(int argc, char **argv)\n{\n\tCvCapture *capture = 0;\n\tIplImage *frame = 0;\n\tIplImage *small = 0;\n\tint key = 0;\n\tcapture = cvCreateCameraCapture(-1);\n\tif (!capture) {\n\t\tfprintf(stderr, \"Webcam no bueno.\\n\");\n\t\treturn 1;\n\t}\n\tcvNamedWindow(\"Jason's Wonderful OpenCV Test\", CV_WINDOW_AUTOSIZE);\t\n\tCvMemStorage* storage = cvCreateMemStorage(0);\n\tCvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*)cvLoad(\"/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml\");\n\tstatic CvScalar colors[] = {{{0, 255, 255}}, {{0, 128, 255}}, {{0, 255, 255}}, {{255, 0, 255}}};\n\t\n\twhile (key != 'q') {\n\t\tframe = cvQueryFrame(capture);\n\t\tif (!frame)\n\t\t\tbreak;\n\n\t\tsmall = cvCreateImage(cvSize(frame->width / 2, frame->height / 2), IPL_DEPTH_8U, 3);\n\t\tcvPyrDown(frame, small, CV_GAUSSIAN_5x5);\n\t\tcvClearMemStorage(storage);\n\t\tCvSeq* objects = cvHaarDetectObjects(small, cascade, storage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(small->width / 8, small->height / 8));\n\t\tcvReleaseImage(&small);\n\t\tCvRect* r;\n\t\tfor (int i = 0; i < (objects ? objects->total : 0); ++i) {\n\t\t\tr = (CvRect*)cvGetSeqElem(objects, i);\n\t\t\tcvEllipse(frame, cvPoint(r->x * 2 + r->width, r->y * 2 + r->height), cvSize(r->width, r->height), 0, 0, 360, colors[i % 8], 2);\n\t\t}\n\t\tcvShowImage(\"Jason's Wonderful OpenCV Test\", frame);\n\t\tkey = cvWaitKey(1);\n\t}\n\tcvDestroyWindow(\"Jason's Wonderful OpenCV Test\");\n\tcvReleaseCapture(&capture);\n\treturn 0;\n}\n\n# Server Execute Phantom\n\nThis renders pages according to the [AJAX crawl specification](https://developers.google.com/webmasters/ajax-crawling/).\n\n## Nginx Configuration\n\n    location / {\n            include uwsgi_params;\n            uwsgi_param HTTP_X_SE_ORIGINAL_URL $scheme://$host$request_uri;\n            if ($args ~* _escaped_fragment_) {\n                    uwsgi_pass unix:/var/run/uwsgi-apps/server-execute-phantom.socket;\n            }\n            alias /var/www;\n    }\n\n/* zip.h -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n        ---------------------------------------------------------------------------\n\n        Changes\n\n        See header of zip.h\n\n*/\n\n#ifndef _zip12_H\n#define _zip12_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//#define HAVE_BZIP2\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagzipFile__ { int unused; } zipFile__;\ntypedef zipFile__ *zipFile;\n#else\ntypedef voidp zipFile;\n#endif\n\n#define ZIP_OK                          (0)\n#define ZIP_EOF                         (0)\n#define ZIP_ERRNO                       (Z_ERRNO)\n#define ZIP_PARAMERROR                  (-102)\n#define ZIP_BADZIPFILE                  (-103)\n#define ZIP_INTERNALERROR               (-104)\n\n#ifndef DEF_MEM_LEVEL\n#  if MAX_MEM_LEVEL >= 8\n#    define DEF_MEM_LEVEL 8\n#  else\n#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#  endif\n#endif\n/* default memLevel */\n\n/* tm_zip contain date/time info */\ntypedef struct tm_zip_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_zip;\n\ntypedef struct\n{\n    tm_zip      tmz_date;       /* date in understandable format           */\n    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */\n/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */\n\n    uLong       internal_fa;    /* internal file attributes        2 bytes */\n    uLong       external_fa;    /* external file attributes        4 bytes */\n} zip_fileinfo;\n\ntypedef const char* zipcharpc;\n\n\n#define APPEND_STATUS_CREATE        (0)\n#define APPEND_STATUS_CREATEAFTER   (1)\n#define APPEND_STATUS_ADDINZIP      (2)\n\nextern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));\nextern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));\n/*\n  Create a zipfile.\n     pathname contain on Windows XP a filename like \"c:\\\\zlib\\\\zlib113.zip\" or on\n       an Unix computer \"zlib/zlib113.zip\".\n     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip\n       will be created at the end of the file.\n         (useful if the file contain a self extractor code)\n     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will\n       add files in existing zip (be sure you don't add file that doesn't exist)\n     If the zipfile cannot be opened, the return value is NULL.\n     Else, the return value is a zipFile Handle, usable with other function\n       of this zip package.\n*/\n\n/* Note : there is no delete function into a zipfile.\n   If you want delete file into a zipfile, you must open a zipfile, and create another\n   Of couse, you can use RAW reading and writing to copy the file you did not want delte\n*/\n\nextern zipFile ZEXPORT zipOpen2 OF((const char *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc_def* pzlib_filefunc_def));\n\nextern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc64_def* pzlib_filefunc_def));\n\nextern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level));\n\nextern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level,\n                       int zip64));\n\n/*\n  Open a file in the ZIP for writing.\n  filename : the filename in zip (if NULL, '-' without quote will be used\n  *zipfi contain supplemental information\n  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local\n    contains the extrafield data the the local header\n  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global\n    contains the extrafield data the the local header\n  if comment != NULL, comment contain the comment string\n  method contain the compression method (0 for store, Z_DEFLATED for deflate)\n  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)\n  zip64 is set to 1 if a zip64 extended information block should be added to the local file header.\n                    this MUST be '1' if the uncompressed size is >= 0xffffffff.\n\n*/\n\n\nextern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw));\n\n\nextern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int zip64));\n/*\n  Same than zipOpenNewFileInZip, except if raw=1, we write raw file\n */\n\nextern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting));\n\nextern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            int zip64\n                                            ));\n\n/*\n  Same than zipOpenNewFileInZip2, except\n    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2\n    password : crypting password (NULL for no crypting)\n    crcForCrypting : crc of file to compress (needed for crypting)\n */\n\nextern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase\n                                            ));\n\n\nextern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase,\n                                            int zip64\n                                            ));\n/*\n  Same than zipOpenNewFileInZip4, except\n    versionMadeBy : value for Version made by field\n    flag : value for flag field (compression level info will be added)\n */\n\n\nextern int ZEXPORT zipWriteInFileInZip OF((zipFile file,\n                       const void* buf,\n                       unsigned len));\n/*\n  Write data in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZip OF((zipFile file));\n/*\n  Close the current file in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,\n                                            uLong uncompressed_size,\n                                            uLong crc32));\n\nextern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,\n                                            ZPOS64_T uncompressed_size,\n                                            uLong crc32));\n\n/*\n  Close the current file in the zipfile, for file opened with\n    parameter raw=1 in zipOpenNewFileInZip2\n  uncompressed_size and crc32 are value for the uncompressed size\n*/\n\nextern int ZEXPORT zipClose OF((zipFile file,\n                const char* global_comment));\n/*\n  Close the zipfile\n*/\n\n\nextern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));\n/*\n  zipRemoveExtraInfoBlock -  Added by Mathias Svensson\n\n  Remove extra information block from a extra information data for the local file header or central directory header\n\n  It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.\n\n  0x0001 is the signature header for the ZIP64 extra information blocks\n\n  usage.\n                        Remove ZIP64 Extra information from a central director extra field data\n              zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);\n\n                        Remove ZIP64 Extra information from a Local File Header extra field data\n        zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);\n*/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _zip64_H */\n\n<app>\n\t<id>com.zx2c4.anyclip</id>\n\t<name>AnyClip</name>\n\t<version>1.0</version>\n\t<description>Watch scenes from your favorite movies</description>\n\t<thumb>http://anyclip.zx2c4.com/icon.png</thumb>\n\t<repositoryid>com.zx2c4</repositoryid>\n\t<repository>http://anyclip.zx2c4.com/</repository>\n\t<media>video</media>\n\t<author>Jason A. Donenfeld</author>\n\t<copyright>Jason A. Donenfeld</copyright>\n\t<email>Jason@zx2c4.com</email>\n\t<type>skin</type>\n\t<startWindow>14000</startWindow>\n\t<platform>all</platform>\n\t<minversion>0.9.5</minversion>\n</app>\n\n$(BINARY): $(wildcard  *.go) go.mod\n\tgo build -o $@ -v\n\ndeploy: $(BINARY)\n\trsync --progress -i $^ \"$(SERVER):/var/www/gosvc/\"\n\tssh \"$(SERVER)\" 'systemctl enable gosvc@$^.socket && systemctl start gosvc@$^.socket && systemctl restart gosvc@$^.service'\n\nclean:\n\trm -f $(BINARY)\n\n.PHONY: deploy clean\n\n# OpenRG Image Parser\n\nOpenRG has a custom image file format, with headers and compression and config files. This utility extracts files from flat OpenRG images. It uses `mmap`'d IO to be fast, and validates checksums. It's also a decent piece of reference code for doing other things with OpenRG files.\n\n### Usage\n\n\t$ make\n\tcc -march=native -O3 -std=c99 -pipe -fomit-frame-pointer  -lz  image-parser.c   -o image-parser\n\t\n\t$ ./image-parser /dev/mtdblock0\n\t==== rg_conf (Valid Checksum) ====\n\tLength: 12130 bytes\n\tDecompressed Length: 121178 bytes\n\tSaving to: 0x01030000-rg_conf\n\t\n\t==== rg_conf (Valid Checksum) ====\n\tLength: 13120 bytes\n\tDecompressed Length: 132110 bytes\n\tSaving to: 0x01090000-rg_conf\n\n\n"}
