// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/aws/aws_sign.c
// Function: aws_sign_dynamodb_headers
int
aws_sign_dynamodb_headers(const char * key_id, const char * key_secret,
    const char * region, const char * op,
    const uint8_t * body, size_t bodylen,
    char ** x_amz_content_sha256, char ** x_amz_date, char ** authorization)
{
	time_t t_now;
	struct tm r_result;
	char date[9];
	char datetime[17];
	uint8_t hbuf[32];
	char content_sha256[65];
	char * canonical_request;
	char sigbuf[65];

	/* Get the current time. */
	if (time(&t_now) == (time_t)(-1)) {
		warnp("time");
		goto err0;
	}

	/* Construct date string <yyyymmdd>. */
	if (strftime(date, 9, "%Y%m%d", gmtime_r(&t_now, &r_result)) == 0) {
		warnp("strftime");
		goto err0;
	}

	/* Construct date-and-time string <yyyymmddThhmmssZ>. */
	if (strftime(datetime, 17, "%Y%m%dT%H%M%SZ",
	    gmtime_r(&t_now, &r_result)) == 0) {
		warnp("strftime");
		goto err0;
	}

	/* Compute the hexified SHA256 of the payload. */
	SHA256_Buf(body, body ? bodylen : 0, hbuf);
	hexify(hbuf, content_sha256, 32);

	/* Construct Canonical Request. */
	if (asprintf(&canonical_request,
	    "POST\n"
	    "/\n"
	    "\n"
	    "host:dynamodb.%s.amazonaws.com\n"
	    "x-amz-content-sha256:%s\n"
	    "x-amz-date:%s\n"
	    "x-amz-target:DynamoDB_20120810.%s\n"
	    "\n"
	    "host;x-amz-content-sha256;x-amz-date;x-amz-target\n"
	    "%s",
	    region, content_sha256, datetime, op, content_sha256) == -1)
		goto err0;

	/* Compute request signature. */
	if (aws_sign(key_secret, date, datetime, region,
	    "dynamodb", canonical_request, sigbuf))
		goto err1;

	/* Construct Authorization header. */
	if (asprintf(authorization,
	    "AWS4-HMAC-SHA256 "
	    "Credential=%s/%s/%s/dynamodb/aws4_request,"
	    "SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-target,"
	    "Signature=%s",
	    key_id, date, region, sigbuf) == -1)
		goto err1;

	/* Duplicate X-Amz-Content-SHA256 and X-Amz-Date headers. */
	if ((*x_amz_content_sha256 = strdup(content_sha256)) == NULL)
		goto err2;
	if ((*x_amz_date = strdup(datetime)) == NULL)
		goto err3;

	/* Free string allocated by asprintf. */
	free(canonical_request);

	/* Success! */
	return (0);

err3:
	free(*x_amz_content_sha256);
err2:
	free(*authorization);
err1:
	free(canonical_request);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3360
cmpq $-0x1, %rax
jne 0x139da
jmp 0x139a0
callq 0x3040
cmpl $0x0, (%rax)
je 0x139c5
leaq 0xb13c(%rip), %rdi      # 0x1eaed
movb $0x0, %al
callq 0x66e0
callq 0x3040
movl $0x0, (%rax)
jmp 0x139d3
leaq 0xb121(%rip), %rdi      # 0x1eaed
movb $0x0, %al
callq 0x6930
jmp 0x139d5
jmp 0x13c42
leaq -0x81(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3670
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movl $0x9, %esi
leaq 0xc521(%rip), %rdx      # 0x1ff2c
callq 0x32b0
cmpq $0x0, %rax
jne 0x13a52
jmp 0x13a18
callq 0x3040
cmpl $0x0, (%rax)
je 0x13a3d
leaq 0xb0c0(%rip), %rdi      # 0x1eae9
movb $0x0, %al
callq 0x66e0
callq 0x3040
movl $0x0, (%rax)
jmp 0x13a4b
leaq 0xb0a5(%rip), %rdi      # 0x1eae9
movb $0x0, %al
callq 0x6930
jmp 0x13a4d
jmp 0x13c42
leaq -0xa0(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3670
movq -0x170(%rbp), %rdi
movq %rax, %rcx
movl $0x11, %esi
leaq 0xc4b0(%rip), %rdx      # 0x1ff33
callq 0x32b0
cmpq $0x0, %rax
jne 0x13aca
jmp 0x13a90
callq 0x3040
cmpl $0x0, (%rax)
je 0x13ab5
leaq 0xb048(%rip), %rdi      # 0x1eae9
movb $0x0, %al
callq 0x66e0
callq 0x3040
movl $0x0, (%rax)
jmp 0x13ac3
leaq 0xb02d(%rip), %rdi      # 0x1eae9
movb $0x0, %al
callq 0x6930
jmp 0x13ac5
jmp 0x13c42
movq -0x30(%rbp), %rax
movq %rax, -0x178(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x13ae9
movq -0x38(%rbp), %rax
movq %rax, -0x180(%rbp)
jmp 0x13af4
xorl %eax, %eax
movq %rax, -0x180(%rbp)
jmp 0x13af4
movq -0x178(%rbp), %rdi
movq -0x180(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x15790
leaq -0xc0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movl $0x20, %edx
callq 0x15160
movq -0x20(%rbp), %rdx
leaq -0x110(%rbp), %rcx
leaq -0xa0(%rbp), %r8
movq -0x28(%rbp), %r9
leaq -0x110(%rbp), %rax
leaq -0x118(%rbp), %rdi
leaq 0xc724(%rip), %rsi      # 0x20275
movq %rax, (%rsp)
movb $0x0, %al
callq 0x15020
cmpl $-0x1, %eax
jne 0x13b66
jmp 0x13c42
movq -0x18(%rbp), %rdi
leaq -0x81(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x118(%rbp), %r9
leaq -0x160(%rbp), %rax
leaq 0xc789(%rip), %r8       # 0x2031a
movq %rax, (%rsp)
callq 0x13170
cmpl $0x0, %eax
je 0x13ba4
jmp 0x13c36
movq 0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq -0x81(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq -0x160(%rbp), %r9
leaq 0xc75e(%rip), %rsi      # 0x20323
movb $0x0, %al
callq 0x15020
cmpl $-0x1, %eax
jne 0x13bd3
jmp 0x13c36
leaq -0x110(%rbp), %rdi
callq 0x35f0
movq 0x10(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x13bee
jmp 0x13c2a
leaq -0xa0(%rbp), %rdi
callq 0x35f0
movq 0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x13c09
jmp 0x13c1e
movq -0x118(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
jmp 0x13c49
movq 0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3460
movq 0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x3460
movq -0x118(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop