// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x133f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2b30
jmp 0x1341
cmpl $0x4, -0x8(%rbp)
je 0x137e
movq 0xccaa(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x9cac(%rip), %rsi      # 0xb004
leaq 0x9cc4(%rip), %rdx      # 0xb023
leaq 0x9cc7(%rip), %rcx      # 0xb02d
leaq 0x9cc9(%rip), %r8       # 0xb036
movb $0x0, %al
callq 0x1150
movl $0x1, %edi
callq 0x11e0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x15c0
cmpl $0x0, %eax
je 0x13d9
jmp 0x139a
callq 0x1060
cmpl $0x0, (%rax)
je 0x13bf
leaq 0x9c93(%rip), %rdi      # 0xb03e
movb $0x0, %al
callq 0x2bf0
callq 0x1060
movl $0x0, (%rax)
jmp 0x13cd
leaq 0x9c78(%rip), %rdi      # 0xb03e
movb $0x0, %al
callq 0x2e40
jmp 0x13cf
movl $0x1, %edi
callq 0x11e0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
leaq -0x28(%rbp), %rdi
leaq 0x9c6b(%rip), %rsi      # 0xb057
movb $0x0, %al
callq 0x27c0
cmpl $-0x1, %eax
jne 0x1439
jmp 0x13fa
callq 0x1060
cmpl $0x0, (%rax)
je 0x141f
leaq 0x9c62(%rip), %rdi      # 0xb06d
movb $0x0, %al
callq 0x2bf0
callq 0x1060
movl $0x0, (%rax)
jmp 0x142d
leaq 0x9c47(%rip), %rdi      # 0xb06d
movb $0x0, %al
callq 0x2e40
jmp 0x142f
movl $0x1, %edi
callq 0x11e0
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
callq 0x10a0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %r8
movq %rax, %r9
leaq 0x9bf6(%rip), %rcx      # 0xb076
leaq -0x30(%rbp), %r11
leaq -0x38(%rbp), %r10
leaq -0x40(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x24c0
cmpl $0x0, %eax
je 0x14e5
jmp 0x14a6
callq 0x1060
cmpl $0x0, (%rax)
je 0x14cb
leaq 0x9bcd(%rip), %rdi      # 0xb084
movb $0x0, %al
callq 0x2bf0
callq 0x1060
movl $0x0, (%rax)
jmp 0x14d9
leaq 0x9bb2(%rip), %rdi      # 0xb084
movb $0x0, %al
callq 0x2e40
jmp 0x14db
movl $0x1, %edi
callq 0x11e0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
callq 0x10a0
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %r9
movq %rax, %r10
movq -0x28(%rbp), %rax
leaq 0x9b6f(%rip), %rdi      # 0xb0a5
leaq 0x9b39(%rip), %r8       # 0xb076
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x10c0
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
callq 0x10a0
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x1590
movq -0x20(%rbp), %rdi
callq 0x1030
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)