// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/perftests/dynamodb_request/main.c
// Function: main
int
main(int argc, char * argv[])
{
	char * key_id;
	char * key_secret;
	struct sock_addr ** sas;
	const char * body;
	int done;

	WARNP_INIT;

	/* Sanity-check. */
	if (argc != 2) {
		fprintf(stderr, "usage: test_dynamodb %s\n", "<keyfile>");
		exit(1);
	}

	/* Read AWS keys. */
	if (aws_readkeys(argv[1], &key_id, &key_secret)) {
		warnp("Failure reading AWS keys");
		exit(1);
	}

	/* Resolve target addresses. */
	if ((sas = sock_resolve("dynamodb.us-east-1.amazonaws.com:443")) == NULL) {
		warnp("Cannot resolve DynamoDB DNS");
		exit(1);
	}

	/* Send DescribeTable request. */
	body = "{ \"TableName\": \"kivaloo-testing\" }";
	done = 0;
	(void)dynamodb_request(sas, key_id, key_secret, "us-east-1",
	    "DescribeTable", (const uint8_t *)body, strlen(body), 1024,
	    donereq, &done);

	/* Wait for request to complete. */
	if (events_spin(&done)) {
		warnp("Error in event loop");
		exit(1);
	}

	/* Send PutItem request. */
	body = "{"
		"\"TableName\": \"kivaloo-testing\","
		"\"ReturnConsumedCapacity\": \"TOTAL\","
		"\"Item\": {"
		    "\"K\": { \"S\": \"key\" },"
		    "\"V\": { \"B\": \"dmFsdWUK\" }"
		"}"
	    "}";
	done = 0;
	(void)dynamodb_request(sas, key_id, key_secret, "us-east-1",
	    "PutItem", (const uint8_t *)body, strlen(body), 1024,
	    donereq, &done);

	/* Wait for request to complete. */
	if (events_spin(&done)) {
		warnp("Error in event loop");
		exit(1);
	}

	/* Send GetItem request. */
	body = "{"
		"\"TableName\": \"kivaloo-testing\","
		"\"ReturnConsumedCapacity\": \"TOTAL\","
		"\"Key\": {"
		    "\"K\": { \"S\": \"key\" }"
		"}"
	    "}";
	done = 0;
	(void)dynamodb_request(sas, key_id, key_secret, "us-east-1",
	    "GetItem", (const uint8_t *)body, strlen(body), 1024,
	    donereq, &done);

	/* Wait for request to complete. */
	if (events_spin(&done)) {
		warnp("Error in event loop");
		exit(1);
	}

	/* Free address structures. */
	sock_addr_freelist(sas);

	/* Success! */
	exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x2798
callq 0x53c0
cmpl $0x2, %ebp
jne 0x27df
movq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2a38
testl %eax, %eax
jne 0x2803
leaq 0xa885(%rip), %rdi      # 0xd040
callq 0x4398
testq %rax, %rax
jne 0x281d
callq 0x2040
cmpl $0x0, (%rax)
jne 0x2942
leaq 0xa88b(%rip), %rdi      # 0xd065
jmp 0x2939
movq 0x107fa(%rip), %rax     # 0x12fe0
movq (%rax), %rdi
leaq 0xa814(%rip), %rsi      # 0xd004
leaq 0xa826(%rip), %rdx      # 0xd01d
xorl %eax, %eax
callq 0x2460
jmp 0x2965
callq 0x2040
cmpl $0x0, (%rax)
jne 0x291c
leaq 0xa80f(%rip), %rdi      # 0xd027
jmp 0x2939
movq %rax, %rbx
leaq 0x4(%rsp), %r14
movl $0x0, (%r14)
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x132(%rip), %r15       # 0x296f
leaq 0xa860(%rip), %rcx      # 0xd0a4
leaq 0xa863(%rip), %r8       # 0xd0ae
leaq 0xa82f(%rip), %r9       # 0xd081
movq %rax, %rdi
pushq %r14
pushq %r15
pushq $0x400                  # imm = 0x400
pushq $0x22
callq 0x575a
addq $0x20, %rsp
movq %r14, %rdi
callq 0x2fd9
testl %eax, %eax
jne 0x2928
movl $0x0, 0x4(%rsp)
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0xa812(%rip), %rcx      # 0xd0a4
leaq 0xa8b1(%rip), %r8       # 0xd14a
leaq 0xa830(%rip), %r9       # 0xd0d0
movq %rbx, %rdi
pushq %r14
pushq %r15
pushq $0x400                  # imm = 0x400
pushq $0x79
callq 0x575a
addq $0x20, %rsp
movq %r14, %rdi
callq 0x2fd9
testl %eax, %eax
jne 0x2928
movl $0x0, 0x4(%rsp)
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0xa7c8(%rip), %rcx      # 0xd0a4
leaq 0xa8cf(%rip), %r8       # 0xd1b2
leaq 0xa868(%rip), %r9       # 0xd152
movq %rbx, %rdi
pushq %r14
pushq %r15
pushq $0x400                  # imm = 0x400
pushq $0x5f
callq 0x575a
addq $0x20, %rsp
movq %r14, %rdi
callq 0x2fd9
testl %eax, %eax
jne 0x2928
movq %rbx, %rdi
callq 0x4aaf
xorl %edi, %edi
callq 0x23b0
movq %rax, %rbx
leaq 0xa701(%rip), %rdi      # 0xd027
jmp 0x2958
callq 0x2040
cmpl $0x0, (%rax)
jne 0x294e
leaq 0xa783(%rip), %rdi      # 0xd0bc
xorl %eax, %eax
callq 0x555f
jmp 0x2965
movq %rax, %rbx
leaq 0xa719(%rip), %rdi      # 0xd065
jmp 0x2958
movq %rax, %rbx
leaq 0xa764(%rip), %rdi      # 0xd0bc
xorl %eax, %eax
callq 0x5440
movl $0x0, (%rbx)
movl $0x1, %edi
callq 0x23b0