LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/mniip[P]sandbox/path.cpp
// Function: read_link(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool read_link(std::string path, std::string &out)
{
	int fd = open(path.c_str(), O_PATH | O_NOFOLLOW);
	if(fd < 0)
		return false;
	struct stat stat;
	if(fstat(fd, &stat))
	{
		close(fd);
		return false;
	}
	if((stat.st_mode & S_IFMT) != S_IFLNK)
	{
		close(fd);
		return false;
	}
	size_t size = stat.st_size;
	if(!size)
		size++;
	char *buf = (char *)malloc(size + 1);
	ssize_t sz;
	while(1)
	{
		sz = readlinkat(fd, "", buf, size + 1);
		if(sz < 0)
		{
			close(fd);
			free(buf);
			return false;
		}
		if(sz > size)
		{
			size *= 2;
			buf = (char *)realloc(buf, size + 1);
		}
		else
			break;
	}
	close(fd);
	out.assign(buf, sz);
	free(buf);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movq (%rdi), %rdi
xorl %r14d, %r14d
movl $0x220000, %esi         # imm = 0x220000
xorl %eax, %eax
callq 0x42f0
testl %eax, %eax
js 0x9198
movl %eax, %ebp
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x4720
testl %eax, %eax
jne 0x918e
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x918e
movq 0x38(%rsp), %r13
cmpq $0x1, %r13
adcq $0x0, %r13
leaq 0x1(%r13), %rdi
callq 0x4530
movq %rax, %r14
leaq 0x340b(%rip), %r15      # 0xc563
leaq 0x1(%r13), %rcx
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x40d0
testq %rax, %rax
js 0x91ad
movq %rax, %r12
cmpq %r13, %rax
jbe 0x91be
leaq 0x1(,%r13,2), %rsi
addq %r13, %r13
movq %r14, %rdi
callq 0x4710
movq %rax, %r14
jmp 0x9158
movl %ebp, %edi
callq 0x4800
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %edi
callq 0x4800
movq %r14, %rdi
callq 0x44a0
jmp 0x9195
movl %ebp, %edi
callq 0x4800
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x4550
movq %r14, %rdi
callq 0x44a0
movb $0x1, %r14b
jmp 0x9198
// File: /workspace/github_cpp_makefile_star2_O2/mniip[P]sandbox/wakeup.cpp
// Function: feed_data(int, int, bool, bool)
void feed_data(int from, int to, bool track, bool closeeof)
{
	const size_t BLOCK_SIZE = 4096;
	char buffer[BLOCK_SIZE];
	ssize_t bytes_read;
	while(0 < (bytes_read = read(from, buffer, BLOCK_SIZE)))
	{
		size_t done = 0;
		while(done < bytes_read)
		{
			ssize_t bytes_wrote = write(to, buffer + done, bytes_read - done);
			if(bytes_wrote <= 0)
			{
				printf("[Write error]\n");
				exit(0);
			}
			done += bytes_wrote;
			if(track)
				written += bytes_wrote;
		}
	}
	if(bytes_read < 0 && errno != EAGAIN)
	{
		printf("[Read error]\n");
		exit(0);
	}
	if(closeeof)
	{
		close_input = true;
		if(startup_over)
			close(to);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movl %ecx, 0xc(%rsp)
movl %edx, %r14d
movl %esi, %ebx
movl %edi, %r15d
leaq 0x10(%rsp), %r12
movl $0x1000, %edx           # imm = 0x1000
movl %r15d, %edi
movq %r12, %rsi
callq 0x45f0
testq %rax, %rax
jle 0x9884
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdx
subq %rbp, %rdx
jbe 0x983e
leaq (%rsp,%rbp), %rsi
addq $0x10, %rsi
movl %ebx, %edi
callq 0x41a0
testq %rax, %rax
jle 0x98d1
addq %rax, %rbp
testb %r14b, %r14b
je 0x9858
addl %eax, 0x8c2a(%rip)      # 0x124ac
jmp 0x9858
jns 0x9890
callq 0x4050
cmpl $0xb, (%rax)
jne 0x98e4
cmpb $0x0, 0xc(%rsp)
je 0x98bf
movb $0x1, 0x8c12(%rip)      # 0x124b0
cmpb $0x1, 0x8c03(%rip)      # 0x124a8
jne 0x98bf
movl %ebx, %edi
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4800
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3086(%rip), %rdi      # 0xc95e
callq 0x4660
xorl %edi, %edi
callq 0x44b0
leaq 0x3066(%rip), %rdi      # 0xc951
jmp 0x98d8
// File: /workspace/github_cpp_makefile_star2_O2/mniip[P]sandbox/wakeup.cpp
// Function: try_connect()
void try_connect()
{
	int server = socket(AF_UNIX, SOCK_STREAM, 0);
	if(server < 0)
		panic_errno("socket");
	
	struct sockaddr_un addr;
	memset(&addr, 0, sizeof addr);
	addr.sun_family = AF_UNIX;
	strncpy(addr.sun_path, (conf_sockdir + "/socket_" + ident).c_str(), sizeof addr.sun_path - 1);
	if(connect(server, (struct sockaddr *)&addr, sizeof addr))
	{
		unlink((conf_sockdir + "/socket_" + ident).c_str());
		return;
	}

	std::thread feed_in(feed_data, fileno(stdin), server, false, !conf_wakeup);
	feed_data(server, fileno(stdout), false, false);
	exit(0);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
pushq $0x1
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x4100
movl %eax, %ebx
movl %eax, 0x4(%rsp)
testl %eax, %eax
jns 0x9e0b
leaq 0x2b1e(%rip), %rsi      # 0xc906
leaq 0x48(%rsp), %rdi
leaq 0x6a(%rsp), %rdx
callq 0x5422
leaq 0x48(%rsp), %rdi
callq 0x8e3a
leaq 0x48(%rsp), %rdi
callq 0x4828
andw $0x0, 0xd6(%rsp)
movw $0x1, 0x6a(%rsp)
leaq 0x87b6(%rip), %rsi      # 0x125d8
leaq 0x2ae4(%rip), %rdx      # 0xc90d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x8a05
movq 0x8643(%rip), %rdx      # 0x12480
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x9084
leaq 0x6c(%rsp), %rdi
leaq 0x28(%rsp), %r14
movq (%r14), %rsi
pushq $0x6b
popq %rdx
callq 0x4240
movq %r14, %rdi
callq 0x4828
leaq 0x8(%rsp), %rdi
callq 0x4828
leaq 0x6a(%rsp), %rsi
pushq $0x6e
popq %rdx
movl %ebx, %edi
callq 0x4380
testl %eax, %eax
je 0x9edd
leaq 0x874d(%rip), %rsi      # 0x125d8
leaq 0x2a7b(%rip), %rdx      # 0xc90d
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x8a05
movq 0x85da(%rip), %rdx      # 0x12480
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x9084
leaq 0x28(%rsp), %rbx
movq (%rbx), %rdi
callq 0x4210
movq %rbx, %rdi
callq 0x4828
leaq 0x8(%rsp), %rdi
callq 0x4828
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
movq 0x80dc(%rip), %rax      # 0x11fc0
movq (%rax), %rdi
callq 0x4450
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x3(%rsp), %r8
movb $0x0, (%r8)
leaq 0x86f5(%rip), %rax      # 0x125f8
movb (%rax), %al
xorb $0x1, %al
leaq 0x2(%rsp), %r9
movb %al, (%r9)
leaq -0x6fa(%rip), %rsi      # 0x981c
leaq 0x28(%rsp), %rdi
leaq 0x4(%rsp), %rbx
movq %rbx, %rcx
callq 0x55cc
movl (%rbx), %ebx
movq 0x806f(%rip), %rax      # 0x11fa0
movq (%rax), %rdi
callq 0x4450
movl %ebx, %edi
movl %eax, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x981c
xorl %edi, %edi
callq 0x44b0
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x9f75
movq %rax, %rbx
jmp 0x9f7a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xa35e
jmp 0x9f7a
jmp 0x9f6d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4828
movq %rbx, %rdi
callq 0x4770
// File: /workspace/github_cpp_makefile_star2_O2/mniip[P]sandbox/wakeup.cpp
// Function: check_startup()
void check_startup()
{
	if(!startup_over)
	{
		int buffer;
		if(ioctl(in_pipe[1], FIONREAD, &buffer))
			panic_errno("FIONREAD");
		if(buffer - written < 0)
		{
			if(close_input)
				close(in_pipe[1]);
			startup_over = true;
			set_timer();
		}
	}
}

// Assembly:
pushq %rbx
subq $0x30, %rsp
cmpb $0x0, 0x8240(%rip)      # 0x124a8
jne 0xa2dc
movl 0x821c(%rip), %edi      # 0x1248c
leaq 0xc(%rsp), %rdx
movl $0x541b, %esi           # imm = 0x541B
xorl %eax, %eax
callq 0x45c0
testl %eax, %eax
je 0xa2b0
leaq 0x26bc(%rip), %rsi      # 0xc948
leaq 0x10(%rsp), %rbx
leaq 0xb(%rsp), %rdx
movq %rbx, %rdi
callq 0x5422
movq %rbx, %rdi
callq 0x8e3a
leaq 0x10(%rsp), %rdi
callq 0x4828
movl 0xc(%rsp), %eax
cmpl 0x81f2(%rip), %eax      # 0x124ac
jge 0xa2dc
cmpb $0x1, 0x81ed(%rip)      # 0x124b0
jne 0xa2d0
movl 0x81c1(%rip), %edi      # 0x1248c
callq 0x4800
movb $0x1, 0x81d1(%rip)      # 0x124a8
callq 0x993b
addq $0x30, %rsp
popq %rbx
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4828
movq %rbx, %rdi
callq 0x4770
nop
// File: /workspace/github_cpp_makefile_star2_O2/simap[P]ecctools/make_keys.cpp
// Function: printHex(unsigned char*, int)
void printHex(uint8_t * data, int len) {
  int i;
  printf("{\n\t");
  for(i=0; i<len-1; ++i) {
    printf("0x%02X, ", data[i]);
    if ((i+1) % 11 == 0)
      printf("\n\t");
  }
  printf("0x%02X};\n", data[i]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x3df1(%rip), %rdi      # 0x5004
xorl %eax, %eax
callq 0x1030
cmpl $0x2, %ebp
pushq $0x1
popq %r13
cmovgel %ebp, %r13d
decl %r13d
pushq $0x1
popq %r14
pushq $0xb
popq %rbp
xorl %r12d, %r12d
movq %r14, %rax
xorl %edx, %edx
divq %rbp
cmpq %r12, %r13
je 0x1274
imulq $0xb, %rax, %r15
decq %r15
movzbl (%rbx,%r12), %esi
leaq 0x3db6(%rip), %rdi      # 0x5008
xorl %eax, %eax
callq 0x1030
cmpl %r12d, %r15d
jne 0x126c
leaq 0x3da0(%rip), %rdi      # 0x5005
xorl %eax, %eax
callq 0x1030
incq %r14
incq %r12
jmp 0x1232
movzbl (%rbx,%r13), %esi
leaq 0x3d91(%rip), %rdi      # 0x5011
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030
// File: /workspace/github_cpp_makefile_star2_O2/simap[P]ecctools/make_keys.cpp
// Function: main
int main(int argc, char ** argv) {
  if (argc < 2) {
    fprintf(stderr, "Need a key name\n");
    return -1;
  }

  if (uECC_get_rng() == NULL) {
    fprintf(stderr, "Compiled without a random number generator!\n");
    return -1;
  }

  const struct uECC_Curve_t * curve = uECC_secp256k1();
  uint8_t private1[32];
  uint8_t public1[64];
  
  uECC_make_key(public1, private1, curve);


  char tmp[100];
  FILE * fp;

  sprintf(tmp, "%s.pub", argv[1]);
  fp = fopen (tmp, "wb");
  fwrite(public1, 64, 1, fp);
  fclose(fp);

  sprintf(tmp, "%s.key", argv[1]);
  fp = fopen (tmp, "wb");
  fwrite(private1, 32, 1, fp);
  fclose(fp);


  printf("const unsigned char private_key[] = ");
  printHex(private1, 32);

  printf("const unsigned char public_key[] = ");
  printHex(public1, 64);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
cmpl $0x1, %edi
jle 0x13ac
movq %rsi, %r12
callq 0x13ec
testq %rax, %rax
je 0x13c1
callq 0x1429
leaq 0x20(%rsp), %r15
movq %rsp, %rsi
movq %r15, %rdi
movq %rax, %rdx
callq 0x1431
movq 0x8(%r12), %rdx
leaq 0x3d75(%rip), %rsi      # 0x5059
leaq 0x60(%rsp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x3d66(%rip), %rbp      # 0x5060
movq %r13, %rdi
movq %rbp, %rsi
callq 0x10c0
movq %rax, %r14
pushq $0x40
popq %rsi
pushq $0x1
popq %rbx
movq %r15, %rdi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x10e0
movq %r14, %rdi
callq 0x10a0
movq 0x8(%r12), %rdx
leaq 0x3d33(%rip), %rsi      # 0x5063
movq %r13, %rdi
xorl %eax, %eax
callq 0x1040
movq %r13, %rdi
movq %rbp, %rsi
callq 0x10c0
movq %rax, %r14
pushq $0x20
popq %rsi
movq %rsp, %r15
movq %r15, %rdi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x10e0
movq %r14, %rdi
callq 0x10a0
leaq 0x3cff(%rip), %rdi      # 0x506a
xorl %eax, %eax
callq 0x1030
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x11fc
leaq 0x3d0b(%rip), %rdi      # 0x508f
xorl %eax, %eax
callq 0x1030
pushq $0x40
popq %rsi
leaq 0x20(%rsp), %rdi
callq 0x11fc
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6c2d(%rip), %rax      # 0x7fe0
movq (%rax), %rcx
leaq 0x3c5e(%rip), %rdi      # 0x501b
pushq $0x10
jmp 0x13d4
movq 0x6c18(%rip), %rax      # 0x7fe0
movq (%rax), %rcx
leaq 0x3c5a(%rip), %rdi      # 0x502c
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
callq 0x10e0
pushq $-0x1
popq %rax
jmp 0x139a
nop
// File: /workspace/github_cpp_makefile_star2_O2/eecs280staff[P]unit_test_framework/test/char_array.cpp
// Function: string_eq()
TEST(string_eq) {
    char arr[] = "spam";
    ASSERT_SEQUENCE_EQUAL("spam", "spam");
    ASSERT_SEQUENCE_EQUAL("spam", arr);
    ASSERT_SEQUENCE_EQUAL("spam", string("spam"));
    ASSERT_EQUAL("spam", string("spam"));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
leaq 0x30(%rsp), %rbx
movb $0x0, 0x4(%rbx)
movl $0x6d617073, (%rbx)     # imm = 0x6D617073
leaq 0x29d0(%rip), %r14      # 0x50a9
leaq 0x29ce(%rip), %rcx      # 0x50ae
pushq $0xb
popq %rdx
movq %r14, %rdi
movq %r14, %rsi
callq 0x3090
leaq 0x29df(%rip), %rcx      # 0x50d4
pushq $0xc
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x322a
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r14, %rsi
callq 0x294e
leaq 0x298d(%rip), %rdi      # 0x50a9
leaq 0x29d4(%rip), %rcx      # 0x50f7
leaq 0x10(%rsp), %rsi
pushq $0xd
popq %rdx
callq 0x33c4
leaq 0x10(%rsp), %rdi
callq 0x20c0
leaq 0x2968(%rip), %rsi      # 0x50a9
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x294e
leaq 0x2952(%rip), %rdi      # 0x50a9
leaq 0x29c7(%rip), %rcx      # 0x5125
leaq 0x10(%rsp), %rsi
pushq $0xe
popq %rdx
callq 0x3676
leaq 0x10(%rsp), %rdi
callq 0x20c0
addq $0x38, %rsp
popq %rbx
popq %r14
retq
jmp 0x2781
jmp 0x2790
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20c0
jmp 0x2793
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2300
// File: /workspace/github_cpp_makefile_star2_O2/eecs280staff[P]unit_test_framework/./unit_test_framework.hpp
// Function: void unit_test_framework::Assertions::assert_equal<char const (&) [5], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>(char const (&) [5], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&&, int, char const*)
static void assert_equal(First&& first, Second&& second,
                             int line_number,
                             const char* assertion_text) {
      if (safe_equals<First, Second>::equals(first, second)) {
        return;
      }
      std::ostringstream reason;
      Diagnostic::print(reason, first);
      reason << " != ";
      Diagnostic::print(reason, second);
      throw TestFailure(reason.str(), line_number, assertion_text);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
callq 0x381d
testb %al, %al
je 0x36a9
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0x2240
movq %r12, %rdi
movq %r15, %rsi
callq 0x378e
leaq 0x1a82(%rip), %rsi      # 0x514a
leaq 0x28(%rsp), %rdi
callq 0x21c0
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x21a0
pushq $0x30
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0x30(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x22b0
movq %r14, %rcx
addq $0x10, %rcx
movq %rcx, (%r14)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
jne 0x3719
movups (%rax), %xmm0
movups %xmm0, (%rcx)
jmp 0x3725
movq %rdx, (%r14)
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%r14)
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%r14)
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movl %ebp, 0x20(%r14)
movq %rbx, 0x28(%r14)
leaq 0x5603(%rip), %rsi      # 0x8d50
leaq 0x44(%rip), %rdx        # 0x3798
movq %r14, %rdi
callq 0x22e0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20c0
jmp 0x377b
movq %rax, %rbx
movq %r14, %rdi
callq 0x2150
jmp 0x377b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2300
nop
// File: /workspace/github_cpp_makefile_star2_O2/eecs280staff[P]unit_test_framework/./unit_test_framework.hpp
// Function: std::ostream& unit_test_framework::Diagnostic::print_helper<5ul>(std::ostream&, char const (&) [5ul], int, int)
static std::ostream& print_helper(std::ostream& os, const char (&arr)[N],
                                      int, int) {
      for (std::size_t i = 0; i < N; ++i) {
        if (!arr[i]) {
          return os << arr;
        }
      }
      return print_sequence_helper(os, arr);
    }

// Assembly:
xorl %eax, %eax
cmpq $0x5, %rax
je 0x37c2
cmpb $0x0, (%rsi,%rax)
leaq 0x1(%rax), %rax
jne 0x37a8
jmp 0x21c0
nop
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Audio.hpp
// Function: playFromSource(void*, void*, unsigned int, double, unsigned int, void*)
int playFromSource(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData)
{
    double * buffer = (double *) outputBuffer;
    AudioSource& source = *(AudioSource*)userData;

    if (status)
    {
        std::cerr << "Stream underflow detected!" << std::endl;
    }
    
    return source.fillBuffer(buffer, nBufferFrames);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %r8, %r14
movl %edx, %ebx
movq %rdi, %r15
testl %ecx, %ecx
je 0x2378
movq 0x2c84(%rip), %rdi      # 0x4fe8
leaq 0xce5(%rip), %rsi       # 0x3050
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq (%r14), %rax
movq (%rax), %rax
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
popq %rbx
popq %r14
popq %r15
jmpq *%rax
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Midi.hpp
// Function: process_midi(double, std::vector<unsigned char, std::allocator<unsigned char>>*, void*)
void process_midi(double deltatime, std::vector<unsigned char> * message_ptr, void * userData)
{
    if (userData == nullptr)
    {
        return;
    }
    MidiListener& listener = *(MidiListener *) userData;
    
    std::vector<unsigned char>& message = *message_ptr;
    if (message.size() != 3) {
        std::cout << "WARNING: Encountered malformed MIDI message." << std::endl;
        return;
    }

    unsigned char note = message[1];
    unsigned char velocity = message[2];

    if ((message[0] & 0xF0) == 0x80)
    {
        // Note Off
        listener.noteOff(note);
    }

    if ((message[0] & 0xF0) == 0x90)
    {
        // Note On
        listener.noteOn(note, velocity);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x23f3
movq %rdi, %r14
movq (%rdi), %rcx
movq 0x8(%rdi), %rax
subq %rcx, %rax
cmpq $0x3, %rax
jne 0x23fe
movq %rsi, %rbx
movb (%rcx), %al
movb 0x2(%rcx), %r15b
movl %eax, %edx
andb $-0x10, %dl
negb %dl
movzbl 0x1(%rcx), %ebp
jno 0x23d2
movq (%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
callq *0x8(%rax)
movq (%r14), %rax
movb (%rax), %al
andb $-0x10, %al
cmpb $-0x70, %al
jne 0x23f3
movq (%rbx), %rax
movq (%rax), %rax
movzbl %r15b, %edx
movq %rbx, %rdi
movl %ebp, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x2bb3(%rip), %rdi      # 0x4fb8
leaq 0xc5f(%rip), %rsi       # 0x306b
callq 0x2170
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x20b0
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/main.cpp
// Function: main
int main()
{
    MidiIn midi;
    SimpleSynth synth;
    AudioPlayer player;

    AudioSettings audioSettings;
    audioSettings.bufferFrames = 64;
    player.setAudioSettings(audioSettings);

    Envelope envelope;
    envelope.amplitude = 1;
    envelope.sustain = .5;
    envelope.attack = 0.1;
    envelope.decay = 0.6;
    envelope.release = 2;
    synth.setEnvelope(envelope);
    
    player.setAudioSource(&synth);
    midi.setMidiListener(&synth);
    
    midi.connect_interactive();
    player.play();

    cout << "Have fun playing some music!." << endl;
    cout << "Press [enter] to exit." << endl;

    cin.get();

    return 0;
}

// Assembly:
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
leaq 0x8(%rsp), %rdi
callq 0x2552
leaq 0x50(%rsp), %rdi
callq 0x25b2
leaq 0x20(%rsp), %rdi
callq 0x260a
movabsq $0x4000005622, %rax     # imm = 0x4000005622
leaq 0x44(%rsp), %rsi
movq %rax, (%rsi)
movl $0x1, 0x8(%rsi)
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x269c
movaps 0xb9a(%rip), %xmm0      # 0x3010
leaq 0x50(%rsp), %rsi
movups %xmm0, 0x98(%rsi)
movaps 0xb97(%rip), %xmm0      # 0x3020
movups %xmm0, 0xa8(%rsi)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0xb8(%rsi)
movq %rbx, %rdi
callq 0x26d0
leaq 0x60(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x26fa
leaq 0x8(%rsp), %rdi
callq 0x270e
leaq 0x20(%rsp), %rdi
callq 0x2882
movq 0x2ae5(%rip), %rdi      # 0x4fb8
leaq 0xbbe(%rip), %rsi       # 0x3098
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq 0x2aca(%rip), %rdi      # 0x4fb8
leaq 0xbc1(%rip), %rsi       # 0x30b6
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq 0x2ac7(%rip), %rdi      # 0x4fd0
callq 0x2190
leaq 0x20(%rsp), %rdi
callq 0x2948
leaq 0x8(%rsp), %rdi
callq 0x2120
xorl %eax, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
retq
movq %rax, %rbx
jmp 0x253f
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2948
leaq 0x8(%rsp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Audio.hpp
// Function: AudioPlayer::AudioPlayer()
AudioPlayer()
    {
        if ( dac.getDeviceCount() < 1 ) {
            throw std::runtime_error("No audio devices found.");
        }

        RtAudio::StreamParameters parameters;
        parameters.deviceId = dac.getDefaultOutputDevice();
        parameters.nChannels = 1;
        parameters.firstChannel = 0;


    }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %esi, %esi
callq 0x2180
movabsq $0x10000005622, %rax    # imm = 0x10000005622
movq %rax, 0x8(%rbx)
movl $0x1, 0x10(%rbx)
andq $0x0, 0x18(%rbx)
movq %rbx, %rdi
callq 0x2cc4
testl %eax, %eax
je 0x264c
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2cd8
pushq $0x10
popq %rdi
callq 0x20c0
movq %rax, %r14
leaq 0xaad(%rip), %rsi       # 0x310b
movq %rax, %rdi
callq 0x2070
movq 0x2983(%rip), %rsi      # 0x4ff0
movq 0x2934(%rip), %rdx      # 0x4fa8
movq %r14, %rdi
callq 0x21d0
movq %rax, %r15
jmp 0x268c
movq %rax, %r15
movq %r14, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x20e0
movq %r15, %rdi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Midi.hpp
// Function: MidiIn::connect_interactive()
void connect_interactive()
    {
        unsigned int portc = midi_in.getPortCount();
        if (portc == 0)
        {
            throw std::runtime_error("No midi devices found.");
        }
        else if (portc == 1)
        {
            connect(0);
        }
        else 
        {
            std::cout << "Please select a midi device: " << std::endl;
            for (int i=0; i < portc; ++i)
            {
                std::cout << " (" << i << ") " << midi_in.getPortName(i) << std::endl;
            }
            int port=-1;
            while(port < 0 || port >= portc) 
            {
                std::cin >> port;
                std::cin.get();			
            }
            connect(port);          
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
cmpl $0x1, %eax
je 0x27c7
movl %eax, %ebp
testl %eax, %eax
je 0x2830
movq 0x2875(%rip), %rdi      # 0x4fb8
leaq 0x9f0(%rip), %rsi       # 0x313a
callq 0x2170
movq %rax, %rdi
callq 0x20b0
xorl %r15d, %r15d
leaq 0x9fa(%rip), %r13       # 0x315b
leaq 0x8(%rsp), %r14
cmpl %r15d, %ebp
je 0x27df
movq 0x2846(%rip), %rdi      # 0x4fb8
leaq 0x9df(%rip), %rsi       # 0x3158
callq 0x2170
movq %rax, %rdi
movl %r15d, %esi
callq 0x21e0
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %rax, %r12
movq 0x8(%rbx), %rsi
movq (%rsi), %rax
movq %r14, %rdi
movl %r15d, %edx
callq *0x38(%rax)
movq %r12, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x20a0
incl %r15d
jmp 0x2766
movq %rbx, %rdi
xorl %esi, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d0a
leaq 0x8(%rsp), %r14
orl $-0x1, (%r14)
pushq $-0x1
popq %rsi
movq 0x27de(%rip), %r15      # 0x4fd0
testl %esi, %esi
setns %al
cmpl %ebp, %esi
setb %cl
testb %cl, %al
jne 0x2819
movq %r15, %rdi
movq %r14, %rsi
callq 0x20d0
movq %r15, %rdi
callq 0x2190
movl 0x8(%rsp), %esi
jmp 0x27f2
movq %rbx, %rdi
callq 0x2d0a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20c0
movq %rax, %rbx
leaq 0x8e1(%rip), %rsi       # 0x3123
movq %rax, %rdi
callq 0x2070
movq 0x279f(%rip), %rsi      # 0x4ff0
movq 0x2750(%rip), %rdx      # 0x4fa8
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2100
jmp 0x287a
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Audio.hpp
// Function: AudioPlayer::play()
void play()
    {
        if (source == nullptr) {
            throw std::logic_error("There is no source to play from.");
        }
        source->injectAudioSettings(&settins);

        if (!dac.isStreamOpen()) 
        {
            RtAudio::StreamParameters parameters;
            parameters.deviceId = dac.getDefaultOutputDevice();
            parameters.nChannels = settins.nrChannels;
            parameters.firstChannel = 0;
            dac.openStream(&parameters, NULL, RTAUDIO_FLOAT64, settins.sampleRate, &(settins.bufferFrames), &playFromSource, (void *)source );
        }

        dac.startStream();

    }

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq 0x18(%rdi), %rax
testq %rax, %rax
je 0x2904
movq %rdi, %rbx
leaq 0x8(%rdi), %rcx
movq %rcx, 0x8(%rax)
movq (%rdi), %rdi
cmpl $-0x32, 0x1bc(%rdi)
jne 0x28f6
movq %rbx, %rdi
callq 0x2cd8
leaq 0x2c(%rsp), %rsi
movl %eax, (%rsi)
movl 0x10(%rbx), %eax
movl %eax, 0x4(%rsi)
andl $0x0, 0x8(%rsi)
movl 0x8(%rbx), %r8d
leaq 0xc(%rbx), %r9
movq 0x18(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
leaq -0x596(%rip), %rax      # 0x234c
movq %rax, (%rsp)
pushq $0x20
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2060
movq (%rbx), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
addq $0x38, %rsp
popq %rbx
popq %r14
retq
pushq $0x10
popq %rdi
callq 0x20c0
movq %rax, %rbx
leaq 0x855(%rip), %rsi       # 0x316b
movq %rax, %rdi
callq 0x21b0
movq 0x26a3(%rip), %rsi      # 0x4fc8
movq 0x2684(%rip), %rdx      # 0x4fb0
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Synth.hpp
// Function: SimpleSynth::fillBuffer(double*, unsigned int)
int fillBuffer(double * buffer, unsigned int nBufferFrames)
        {
            for (int i=0; i < nBufferFrames; ++i) 
            {
                buffer[i] = 0;

                unsigned int t = time_code + i;

                for (int n=0; n<max_concurrency; ++n)
                {
                    Note& note = notes[n];
                    double volume = (double)note.velocity / 256 * getEnvelopeVolume(note, synth, t);
                    double frequency = pow(2, (double)(note.note - 69) / 12) * 441;
                    double a = volume * sin((double)t / audio_settings->sampleRate * frequency * 2 * M_PI);
                    buffer[i] += a;
                }

            }
    
            time_code += nBufferFrames;
            return 0;
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x1c(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x98(%rdi), %r12
movl %edx, 0xc(%rsp)
movl %edx, %eax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
cmpq 0x10(%rsp), %rbx
je 0x2b59
andq $0x0, (%r15,%rbx,8)
movl 0x18(%r14), %r13d
addl %ebx, %r13d
cvtsi2sd %r13, %xmm0
mulsd 0x57f(%rip), %xmm0      # 0x3038
movsd %xmm0, 0x20(%rsp)
xorl %ebp, %ebp
cmpq $0x78, %rbp
je 0x2b51
movq 0x18(%rsp), %rax
leaq (%rax,%rbp), %rsi
movzbl 0x25(%r14,%rbp), %eax
cvtsi2sd %eax, %xmm0
mulsd 0x55a(%rip), %xmm0      # 0x3040
movsd %xmm0, (%rsp)
movq %r14, %rdi
movq %r12, %rdx
movl %r13d, %ecx
callq 0x2c14
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movzbl 0x24(%r14,%rbp), %eax
addl $-0x45, %eax
cvtsi2sd %eax, %xmm0
mulsd 0x530(%rip), %xmm0      # 0x3048
callq 0x2160
movq 0x8(%r14), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
mulsd 0x20(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x2030
mulsd (%rsp), %xmm0
addsd (%r15,%rbx,8), %xmm0
movsd %xmm0, (%r15,%rbx,8)
addq $0xc, %rbp
jmp 0x2ac1
incq %rbx
jmp 0x2a95
movl 0xc(%rsp), %eax
addl %eax, 0x18(%r14)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Synth.hpp
// Function: SimpleSynth::noteOn(unsigned char, unsigned char)
void noteOn(unsigned char note, unsigned char velocity)
        {
            std::size_t oldest_note = 0;
            for (std::size_t i=1; i<max_concurrency; ++i) 
            {
                if (notes[oldest_note].pressed != notes[i].pressed) 
                {
                    if (!notes[i].pressed) {
                        oldest_note = i;
                    }
                }
                else if(notes[oldest_note].last_event_time_code > notes[i].last_event_time_code) 
                {
                    oldest_note = i;
                }
            }
            
            notes[oldest_note].last_event_time_code = time_code;
            notes[oldest_note].note = note;
            notes[oldest_note].velocity = velocity;
            notes[oldest_note].pressed = true;

        }

// Assembly:
leaq 0x1c(%rdi), %rax
leaq 0x2c(%rdi), %rcx
pushq $0x1
popq %r8
xorl %r9d, %r9d
cmpq $0xa, %r8
je 0x2bbc
imulq $0xc, %r9, %r10
movb -0x4(%rcx), %r11b
cmpb %r11b, (%rax,%r10)
jne 0x2bac
addq %rax, %r10
movl 0x4(%r10), %r11d
movq %r8, %r10
cmpl (%rcx), %r11d
ja 0x2ba7
movq %r9, %r10
movq %r10, %r9
jmp 0x2bb3
testb %r11b, %r11b
cmoveq %r8, %r9
incq %r8
addq $0xc, %rcx
jmp 0x2b81
movl 0x18(%rdi), %ecx
imulq $0xc, %r9, %rdi
movl %ecx, 0x4(%rax,%rdi)
movb %sil, 0x8(%rax,%rdi)
movb %dl, 0x9(%rax,%rdi)
movb $0x1, (%rax,%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Synth.hpp
// Function: SimpleSynth::noteOff(unsigned char)
void noteOff(unsigned char note) 
        {
            for (std::size_t i=0; i<max_concurrency; ++i) 
            {
                if (notes[i].note == note && notes[i].pressed)
                {
                    notes[i].last_event_time_code = time_code;
                    notes[i].pressed = false;
                }
            }	
        }

// Assembly:
movl 0x18(%rdi), %eax
xorl %ecx, %ecx
cmpq $0x78, %rcx
je 0x2bfe
cmpb %sil, 0x24(%rdi,%rcx)
jne 0x2bf8
cmpb $0x1, 0x1c(%rdi,%rcx)
jne 0x2bf8
movl %eax, 0x20(%rdi,%rcx)
movb $0x0, 0x1c(%rdi,%rcx)
addq $0xc, %rcx
jmp 0x2bdb
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/./Synth.hpp
// Function: SimpleSynth::getEnvelopeVolume(SimpleSynth::Note const&, Envelope const&, unsigned int)
double getEnvelopeVolume(const Note& note, const Envelope& env, unsigned int t)
    {
        unsigned int time_since_last_event = t - note.last_event_time_code;
        if (note.pressed) 
        {
            unsigned int attack_time = env.attack * audio_settings->sampleRate;
            unsigned int decay_time = env.decay * audio_settings->sampleRate;
            
            if (time_since_last_event <= attack_time)
            {
                // attack
                double pos = (double)time_since_last_event / attack_time;
                return pos * env.amplitude;
            }

            time_since_last_event -= attack_time;
            if (time_since_last_event <= decay_time)
            {
                // decay
                double pos = (double)time_since_last_event / decay_time;
                return (1 - pos) * env.amplitude + pos * env.sustain;
            }

            // sustain
            return env.sustain;
            
        }
        else 
        {
            unsigned int release_time = env.release * audio_settings->sampleRate;
            if (time_since_last_event <= release_time) 
            {
                // release
                double pos = (double)time_since_last_event / release_time;
                return (double)(1 - pos) * env.sustain;
            }
            
            // off
            return 0;
            
        }
    }

// Assembly:
movq 0x8(%rdi), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
subl 0x4(%rsi), %ecx
cmpb $0x1, (%rsi)
jne 0x2c4f
movsd 0x8(%rdx), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rsi
movl %ecx, %eax
subl %esi, %eax
jbe 0x2c85
mulsd 0x10(%rdx), %xmm0
cvttsd2si %xmm0, %rcx
cmpl %ecx, %eax
jbe 0x2c9c
movsd 0x18(%rdx), %xmm0
retq
mulsd 0x20(%rdx), %xmm0
cvttsd2si %xmm0, %rax
xorpd %xmm0, %xmm0
cmpl %eax, %ecx
ja 0x2c84
movl %ecx, %ecx
cvtsi2sd %rcx, %xmm1
movl %eax, %eax
cvtsi2sd %rax, %xmm0
divsd %xmm0, %xmm1
movsd 0x3b5(%rip), %xmm0      # 0x3030
subsd %xmm1, %xmm0
mulsd 0x18(%rdx), %xmm0
retq
movl %ecx, %eax
cvtsi2sd %rax, %xmm0
movl %esi, %eax
cvtsi2sd %rax, %xmm1
mulsd (%rdx), %xmm0
divsd %xmm1, %xmm0
retq
movl %eax, %eax
cvtsi2sd %rax, %xmm1
movl %ecx, %eax
cvtsi2sd %rax, %xmm2
movsd (%rdx), %xmm3
movsd 0x18(%rdx), %xmm0
subsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
divsd %xmm2, %xmm0
addsd %xmm3, %xmm0
retq
// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH01_GettingStarted/examples/item_io.cc
// Function: main
int main()
{
    Sales_item book;

    // read ISBN, number of copies sold, and sales price
    while(std::cin >> book) {
        // write ISBN, number of copies sold, total revenue, and average price
        std::cout << book << std::endl;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andl $0x0, 0x10(%rax)
andq $0x0, 0x18(%rax)
movq 0x2ba2(%rip), %rbx      # 0x3fe0
leaq -0x48(%rbp), %r14
movq 0x2b87(%rip), %r15      # 0x3fd0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x129c
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x1477
movq %r15, %rdi
movq %r14, %rsi
callq 0x1333
movq %r15, %rdi
callq 0x1040
jmp 0x1449
leaq -0x48(%rbp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1100
nop
// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH02_VariablesAndBasicTypes/examples/ref-ex.cc
// Function: main
int main()
{
	int i = 0, &ri = i;  // ri is a reference to i
	// ri is just another name for i; 
	// this statement prints the value of i twice
	std::cout << i << " " << ri << std::endl;

	i = 5; // changing i is reflected through ri as well
	std::cout << i << " " << ri << std::endl;

	ri = 10; // assigning to ri actually assigns to i
	std::cout << i << " " << ri << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x2e0b(%rip), %rbx      # 0x3fd8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0xe26(%rip), %r14       # 0x2004
movq %rax, %rdi
movq %r14, %rsi
callq 0x1050
movq %rax, %rdi
xorl %esi, %esi
callq 0x1070
movq %rax, %rdi
callq 0x1030
pushq $0x5
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1070
movq %rax, %rdi
movq %r14, %rsi
callq 0x1050
movq %rax, %rdi
movl %r15d, %esi
callq 0x1070
movq %rax, %rdi
callq 0x1030
pushq $0xa
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1070
movq %rax, %rdi
movq %r14, %rsi
callq 0x1050
movq %rax, %rdi
movl %r15d, %esi
callq 0x1070
movq %rax, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: split_input(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
std::vector<std::string> split_input(std::string file, int maps){
  int word_count = count_words(file);
  //if there are more maps than words return an error
  if(maps > word_count){
    std::cout << "More maps than there are words! You gave " << maps << " maps but there are only " << word_count << " words!" << "\n" << std::endl;
    exit(EXIT_FAILURE);
  }

  std::cout << "Total words: " << word_count << std::endl;
  std::vector<std::string> ary = map_words_to_array(file, maps, word_count);
  //print for error checking
  //for (std::vector<std::string>::const_iterator i = ary.begin(); i != ary.end(); i++){
  //  std::cout << *i << '\n';
  //}
  //
  return ary;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r14d
movq %rsi, %r12
movq %rdi, %r15
leaq -0x68(%rbp), %r13
movq %r13, %rdi
callq 0x3370
movq %r13, %rdi
callq 0x524b
movl %eax, %ebx
leaq -0x68(%rbp), %rdi
callq 0x3120
movq 0x1aad5(%rip), %rdi     # 0x1efc8
cmpl %r14d, %ebx
jl 0x4550
leaq 0xdc83(%rip), %rsi      # 0x12182
callq 0x32b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x34d0
movq %rax, %rdi
callq 0x3150
leaq -0x48(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x3370
movq %r15, %rdi
movq %r13, %rsi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x53ec
leaq -0x48(%rbp), %rdi
callq 0x3120
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdbdf(%rip), %rsi      # 0x12136
callq 0x32b0
movq %rax, %rdi
movl %r14d, %esi
callq 0x34d0
leaq 0xdbf2(%rip), %rsi      # 0x12160
movq %rax, %rdi
callq 0x32b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x34d0
leaq 0xdbf3(%rip), %rsi      # 0x1217a
movq %rax, %rdi
callq 0x32b0
leaq 0xda8a(%rip), %rsi      # 0x12020
movq %rax, %rdi
callq 0x32b0
movq %rax, %rdi
callq 0x3150
pushq $0x1
popq %rdi
callq 0x3310
jmp 0x45b0
movq %rax, %rbx
movq %r13, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x34e0
// File: /workspace/github_cpp_makefile_star2_O2/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: map_threads(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, int, ThreadData*)
void map_threads(std::vector<std::string> array, int maps, ThreadData thread_data[]){
  pthread_t threads[maps];
  int iret;
  for(int i = 0; i < maps; i++){
    //std::cout << "Creating thread: " << std::endl;
    thread_data[i].id = i;
    thread_data[i].line_array= array[i];

    iret = pthread_create(&threads[i], NULL, map_function_thread, (void*) &thread_data[i]);
    if (iret != 0) {
			std::cout << "Error: Creating thread: " << iret << std::endl;
			exit(EXIT_FAILURE);
		}
  }
  for (int i = 0; i < maps; i++) {
		iret = pthread_join(threads[i], NULL);
		if (iret) {
			std::cout << "Error: Joining thread: " << iret << std::endl;
			exit(EXIT_FAILURE);
		}
		/*
		std::map<std::string, int> testMap = thread_data[i].counter;
		for(auto it = testMap.begin(); it != testMap.end(); it++){
		  std::cout << it->first << " " << it->second << std::endl;
		} */
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rdi, -0x38(%rbp)
movl %esi, %eax
movq %rsp, %r13
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %r13
movq %r13, %rsp
xorl %r15d, %r15d
testl %esi, %esi
cmovlel %r15d, %esi
movq %rsi, -0x40(%rbp)
movq %r13, -0x30(%rbp)
xorl %ebx, %ebx
movq -0x40(%rbp), %r12
cmpq %rbx, %r12
je 0x4669
movl %ebx, (%r14)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r15, %rsi
leaq 0x8(%r14), %rdi
callq 0x3180
movq %r13, %rdi
xorl %esi, %esi
leaq 0x77c(%rip), %rdx       # 0x4dac
movq %r14, %rcx
callq 0x3500
incq %rbx
addq $0x8, %r13
addq $0x58, %r14
addq $0x20, %r15
testl %eax, %eax
je 0x4605
movl %eax, %r12d
movq 0x1a973(%rip), %rdi     # 0x1efc8
leaq 0xdaa9(%rip), %rsi      # 0x12105
callq 0x32b0
movq %rax, %rdi
movl %r12d, %esi
jmp 0x46a2
xorl %ebx, %ebx
movq -0x30(%rbp), %r15
cmpq %rbx, %r12
je 0x46b7
movq (%r15,%rbx,8), %rdi
xorl %esi, %esi
callq 0x3270
incq %rbx
testl %eax, %eax
je 0x466f
movl %eax, %r14d
movq 0x1a938(%rip), %rdi     # 0x1efc8
leaq 0xda87(%rip), %rsi      # 0x1211e
callq 0x32b0
movq %rax, %rdi
movl %r14d, %esi
callq 0x34d0
movq %rax, %rdi
callq 0x3150
pushq $0x1
popq %rdi
callq 0x3310
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: sortPrint(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void sortPrint(std::map<std::string, int> result, std::string path) {
  std::ofstream outputFile;
  outputFile.open (path);
  std::map<int, int> convert; // convert all strings to int for sorting purposes
  for(auto it = result.begin(); it != result.end(); it++){
      int stringToInt = std::stoi(it->first);
      convert[stringToInt] = it->second;
  }

  //numbers are already sorted
  for(auto it = convert.begin(); it != convert.end(); it++){
      //if there are dupes print all the dupes
      for(int i = 0; i < it->second; i++){
	outputFile << it->first << "\n";
      }
  }
  outputFile.close();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x260(%rbp), %r15
movq %r15, %rdi
callq 0x34b0
pushq $0x10
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3140
leaq -0x58(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0x18(%rbx), %r14
addq $0x8, %rbx
leaq -0x60(%rbp), %r12
leaq -0x2c(%rbp), %r13
cmpq %rbx, %r14
je 0x4bec
leaq 0x20(%r14), %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x5efb
movl %eax, -0x2c(%rbp)
movl 0x40(%r14), %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x6666
movl %r15d, (%rax)
movq %r14, %rdi
callq 0x31e0
movq %rax, %r14
jmp 0x4bb7
movq -0x48(%rbp), %r15
leaq -0x260(%rbp), %rbx
leaq 0xd422(%rip), %r14      # 0x12020
leaq -0x58(%rbp), %r13
cmpq %r13, %r15
je 0x4c39
xorl %r12d, %r12d
cmpl 0x24(%r15), %r12d
jge 0x4c2c
movl 0x20(%r15), %esi
movq %rbx, %rdi
callq 0x34d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32b0
incl %r12d
jmp 0x4c0a
movq %r15, %rdi
callq 0x31e0
movq %rax, %r15
jmp 0x4c02
leaq -0x260(%rbp), %rdi
callq 0x3390
leaq -0x60(%rbp), %rdi
callq 0x6dd2
leaq -0x260(%rbp), %rdi
callq 0x33f0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4c75
movq %rax, %rbx
jmp 0x4c81
jmp 0x4c75
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x6dd2
leaq -0x260(%rbp), %rdi
callq 0x33f0
movq %rbx, %rdi
callq 0x34e0
// File: /workspace/github_cpp_makefile_star2_O2/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: map_proc(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, int, ProcData*)
void map_proc(std::vector<std::string> array, int maps, ProcData proc_data[]){
	std::string sIdentifier;
	pid_t pids[maps];
	pid_t pid;

  //Remove if parent
  shared_memory_object::remove("shared_memory");
	// create a new SHM object and allocate space
	//managed_shared_memory managed_shm(open_or_create, "my_shm", 1024);

  //shared_memory_object shm_obj(create_only, "shared_memory", read_write);
  //shm_obj.truncate(SHAREDMEMSIZE);

  managed_shared_memory segment(create_only,"shared_memory", SHAREDMEMSIZE);
	int status;
  int shm_size = SHAREDMEMSIZE/maps; //size of shared memory each process arguments
  //TODO maybe? handle remainder from division
	for(int i = 0; i < maps; i++){
		if ((pids[i] = fork()) < 0){
			std::cerr << "Error forking" << std::endl;
			exit(EXIT_FAILURE);
		}
		else if (pids[i] == 0){
			sIdentifier = "Child Process:";
			
    

      //map part of shared memory for each process
      //mapped_region region(shm_obj, read_write, shm_size/i, shm_size - shm_size/i);
			//mapped_region region(shm_obj, read_write, shm_size*i, shm_size);

			proc_data[i].id = i;
			proc_data[i].line_array = array[i];
			map_function_proc((void*) &proc_data[i]);
			
			exit(0); //exit cleanly
		}
		else if (pids[i] > 0){
			sIdentifier = "Parent Process:";
			pid = wait(&status);
			red_proc();
			shared_memory_object::remove("shared_memory");

			printf("Child process %ld exited with status 0x%x. \n", long(pid), status);
			
		}
	}


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
movq %rsp, %r12
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xd4c9(%rip), %rdi      # 0x12190
callq 0x63d2
leaq -0x24(%rbp), %r8
movl $0x1a4, (%r8)           # imm = 0x1A4
leaq 0xd4b2(%rip), %rsi      # 0x12190
leaq -0x70(%rbp), %rdi
movl $0xa0000, %edx          # imm = 0xA0000
xorl %ecx, %ecx
callq 0x6432
testl %r15d, %r15d
jg 0x4d15
leaq -0x70(%rbp), %rdi
callq 0x6482
movq %r12, %rsp
leaq -0x48(%rbp), %rdi
callq 0x3120
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x3080
testl %eax, %eax
jns 0x4d41
movq 0x1a2cb(%rip), %rdi     # 0x1eff0
leaq 0xd472(%rip), %rsi      # 0x1219e
callq 0x32b0
movq %rax, %rdi
callq 0x3150
pushq $0x1
popq %rdi
callq 0x3310
jne 0x4d6a
leaq 0xd462(%rip), %rsi      # 0x121ac
leaq -0x48(%rbp), %rdi
callq 0x3560
andl $0x0, (%rbx)
movq (%r14), %rsi
leaq 0x8(%rbx), %rdi
callq 0x3180
movq %rbx, %rdi
callq 0x5751
leaq 0xd44a(%rip), %rsi      # 0x121bb
leaq -0x48(%rbp), %rdi
callq 0x3560
leaq -0x24(%rbp), %rdi
callq 0x3330
callq 0x5a22
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x6482
jmp 0x4d9b
jmp 0x4d98
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x34e0
// File: /workspace/github_cpp_makefile_star2_O2/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: map_function_thread(void*)
void *map_function_thread(void* thread) {
	struct ThreadData *curr_thread_data;
	curr_thread_data = (struct ThreadData *) thread;

	std::vector<std::string> words = split_string_by_space(curr_thread_data->line_array);
	std::map<std::string, int> counterMap;

	for(int i = 0; i < words.size(); i++){
	  if(counterMap.count(words[i])){
	    counterMap[words[i]] = counterMap[words[i]] + 1;
	  } else {
	    counterMap[words[i]] = 1;
	  }
	}

	//test output
	curr_thread_data->counter = counterMap;
	std::map<std::string, int> testMap = curr_thread_data->counter;
	for(auto it = testMap.begin(); it != testMap.end(); it++){
	  //std::cout << it->first << " " << it->second << std::endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq -0x60(%rbp), %r14
movq %r14, %rdi
callq 0x3370
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x518a
leaq -0x60(%rbp), %rdi
callq 0x3120
leaq -0x88(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorl %r15d, %r15d
leaq -0x90(%rbp), %r14
xorl %r12d, %r12d
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0x4e75
addq %r15, %rsi
movq %r14, %rdi
callq 0x6210
movq -0x40(%rbp), %rsi
addq %r15, %rsi
testq %rax, %rax
je 0x4e5e
movq %r14, %rdi
callq 0x6234
movl (%rax), %r13d
movq -0x40(%rbp), %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x6234
incl %r13d
movl %r13d, (%rax)
jmp 0x4e6c
movq %r14, %rdi
callq 0x6234
movl $0x1, (%rax)
incq %r12
addq $0x20, %r15
jmp 0x4e11
addq $0x28, %rbx
leaq -0x90(%rbp), %rsi
movq %rbx, %rdi
callq 0x6af4
leaq -0xc0(%rbp), %rdi
movq %rbx, %rsi
callq 0x67b2
jmp 0x4e9b
jmp 0x4e9b
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x6adc
leaq -0x40(%rbp), %rdi
callq 0x5fd4
jmp 0x4ec1
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x34e0