This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define i64 @test_phi_loop(i32 %n) { | |
entry: | |
br label %loop | |
loop: | |
%counter = phi i32 [ %n, %entry ], [ %counter.dec, %loop ] | |
%elem = phi { i64, i64 } [ { i64 0, i64 1 }, %entry ], [ %updated, %loop ] | |
%prev = extractvalue { i64, i64 } %elem, 0 | |
%curr = extractvalue { i64, i64 } %elem, 1 | |
%next = add i64 %prev, %curr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define void @test_phi_diamond({ i8, i16, i32 }* %a.ptr, { i8, i16, i32 }* %b.ptr, i1 %selector, { i8, i16, i32 }* %dst) { | |
entry: | |
br i1 %selector, label %store.a, label %store.b | |
store.a: | |
%a = load { i8, i16, i32 }, { i8, i16, i32 }* %a.ptr | |
br label %join | |
store.b: | |
%b = load { i8, i16, i32 }, { i8, i16, i32 }* %b.ptr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory> | |
struct A { | |
virtual void foo() const { | |
std::cout << "virtual A::foo()'s called" << std::endl; | |
} | |
}; | |
struct B { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <iostream> | |
#include <vector> | |
#include <set> | |
using namespace std; | |
typedef int RingElement; | |
struct Vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = []; | |
for (var i = 0; i < 30000; i++) { | |
arr.push(Math.round(Math.random() * 1.0e9).toString()); | |
} | |
Array.prototype.diff = function(a) { | |
return this.filter(function(i) { return !(a.indexOf(i) > -1); }); | |
}; | |
for (var i = 0; i < 20; ++i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = []; | |
for (var i = 0, l = 100*1000; i < l; i++) { | |
arr.push(Math.round(Math.random() * l)) | |
} | |
Array.prototype.diff = function(a) { | |
return this.filter(function(i) {return !(a.indexOf(i) > -1);}); | |
}; | |
for (var i = 0; i < 10; ++i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.CODE | |
CpuidTestBit MACRO REG, BITNUM | |
mov r8, rbx | |
mov rax, 1 | |
cpuid | |
xor rax, rax | |
bt REG, BITNUM | |
setc al | |
mov rbx, r8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define NUMTOSTR_DEF_IMPL_FOR(type) \ | |
const char *numtostr_impl_for_##type(type num, const char *format) \ | |
{ \ | |
static char buf[64]; \ | |
sprintf(buf, format, num); \ | |
return buf; \ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let discriminant a b c = | |
b * b - 4 * a * c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
long long fib_00(int n) { | |
if (n < 3) | |
return 1; | |
return fib_00(n - 1) + fib_00(n - 2); | |
} | |
long long fib_01(int n) { | |
if (n < 3) |