// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/perftests/dynamodb_sign/main.c
// Function: main
int
main(int argc, char * argv[])
{
	char * key_id;
	char * key_secret;
	char * s;
	char * x_amz_content_sha256;
	char * x_amz_date;
	char * authorization;

	WARNP_INIT;

	/* Check number of arguments. */
	if (argc != 4) {
		fprintf(stderr, "usage: dynamodb_sign %s %s %s\n",
		    "<keyfile>", "<region>", "<table>");
		exit(1);
	}

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

	/* Construct DynamoDB request. */
	if (asprintf(&s, "{ \"TableName\": \"%s\" }", argv[3]) == -1) {
		warnp("asprintf");
		exit(1);
	}

	/* Sign request. */
	if (aws_sign_dynamodb_headers(key_id, key_secret, argv[2],
	    "DescribeTable", (uint8_t *)s, strlen(s), &x_amz_content_sha256,
	    &x_amz_date, &authorization)) {
		warnp("Failure signing DynamoDB request");
		exit(1);
	}

	/* Output request. */
	printf("POST / HTTP/1.1\r\n"
	    "Host: dynamodb.%s.amazonaws.com\r\n"
	    "X-Amz-Date: %s\r\n"
	    "X-Amz-Content-SHA256: %s\r\n"
	    "X-Amz-Target: DynamoDB_20120810.%s\r\n"
	    "Authorization: %s\r\n"
	    "Content-Length: %zu\r\n"
	    "Content-Type: application/x-amz-json-1.0\r\n"
	    "Connection: close\r\n"
	    "\r\n"
	    "%s",
	    argv[2], x_amz_date, x_amz_content_sha256, "DescribeTable",
	    authorization, strlen(s), s);

	/* Clean up keys. */
	free(key_id);
	insecure_memzero(key_secret, strlen(key_secret));
	free(key_secret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x147c
callq 0x2590
cmpl $0x4, %ebp
jne 0x15aa
movq 0x8(%rbx), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x1628
testl %eax, %eax
jne 0x15af
movq 0x18(%rbx), %rdx
leaq 0x3bac(%rip), %rsi      # 0x5057
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x2384
cmpl $-0x1, %eax
je 0x15c2
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %r15
movq 0x10(%rbx), %r12
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x10a0
subq $0x8, %rsp
leaq 0x28(%rsp), %r10
leaq 0x30(%rsp), %r11
leaq 0x38(%rsp), %rbp
leaq 0x3b81(%rip), %rcx      # 0x5076
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %r8
movq %rax, %r9
pushq %r10
pushq %r11
pushq %rbp
callq 0x2141
addq $0x20, %rsp
testl %eax, %eax
jne 0x15d5
movq 0x10(%rbx), %rbx
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %r15
movq 0x20(%rsp), %r12
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x10a0
movq %rax, %r10
leaq 0x3b61(%rip), %rdi      # 0x50a5
leaq 0x3b2b(%rip), %r8       # 0x5076
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r13
pushq %r10
callq 0x10c0
addq $0x10, %rsp
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x10a0
leaq 0x6bc4(%rip), %rcx      # 0x8148
movq (%rcx), %rcx
movq %rbx, %rdi
movq %rax, %rsi
callq *%rcx
movq 0x8(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1220
callq 0x1060
cmpl $0x0, (%rax)
jne 0x15ef
leaq 0x3a7e(%rip), %rdi      # 0x503e
jmp 0x15e6
callq 0x1060
cmpl $0x0, (%rax)
jne 0x15fb
leaq 0x3a9a(%rip), %rdi      # 0x506d
jmp 0x15e6
callq 0x1060
cmpl $0x0, (%rax)
jne 0x1607
leaq 0x3a9e(%rip), %rdi      # 0x5084
xorl %eax, %eax
callq 0x272f
jmp 0x161e
movq %rax, %rbx
leaq 0x3a45(%rip), %rdi      # 0x503e
jmp 0x1611
movq %rax, %rbx
leaq 0x3a68(%rip), %rdi      # 0x506d
jmp 0x1611
movq %rax, %rbx
leaq 0x3a73(%rip), %rdi      # 0x5084
xorl %eax, %eax
callq 0x2610
movl $0x0, (%rbx)
movl $0x1, %edi
callq 0x11d0