// File: /workspace/github_c_makefile_star2_O2/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 0x134c
callq 0x2450
cmpl $0x4, %ebp
jne 0x1478
movq 0x8(%rbx), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x151c
testl %eax, %eax
jne 0x14a7
movq 0x18(%rbx), %rdx
leaq 0x3cdc(%rip), %rsi      # 0x5057
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x2268
cmpl $-0x1, %eax
je 0x14ba
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 0x3cb1(%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 0x2034
addq $0x20, %rsp
testl %eax, %eax
jne 0x14cd
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 0x3c91(%rip), %rdi      # 0x50a5
leaq 0x3c5b(%rip), %r8       # 0x5076
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r13
pushq %r10
callq 0x10c0
popq %rcx
popq %rdx
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x10a0
leaq 0x6d06(%rip), %rcx      # 0x8158
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
movq 0x6b79(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x3b7b(%rip), %rsi      # 0x5004
leaq 0x3b93(%rip), %rdx      # 0x5023
leaq 0x3b96(%rip), %rcx      # 0x502d
leaq 0x3b98(%rip), %r8       # 0x5036
xorl %eax, %eax
callq 0x1150
jmp 0x1513
callq 0x1060
cmpl $0x0, (%rax)
jne 0x14e7
leaq 0x3b86(%rip), %rdi      # 0x503e
jmp 0x14de
callq 0x1060
cmpl $0x0, (%rax)
jne 0x14f3
leaq 0x3ba2(%rip), %rdi      # 0x506d
jmp 0x14de
callq 0x1060
cmpl $0x0, (%rax)
jne 0x14ff
leaq 0x3ba6(%rip), %rdi      # 0x5084
xorl %eax, %eax
callq 0x265c
jmp 0x1513
movq %rax, %rbx
leaq 0x3b4d(%rip), %rdi      # 0x503e
jmp 0x1509
movq %rax, %rbx
leaq 0x3b70(%rip), %rdi      # 0x506d
jmp 0x1509
movq %rax, %rbx
leaq 0x3b7b(%rip), %rdi      # 0x5084
xorl %eax, %eax
callq 0x24cd
andl $0x0, (%rbx)
pushq $0x1
popq %rdi
callq 0x11f0
nop