// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/perftests/s3/main.c
// Function: main
int
main(int argc, char * argv[])
{
	char * key_id;
	char * key_secret;
	struct s3_request R;
	struct sock_addr ** sas;
	int done;

	WARNP_INIT;

	/* Sanity-check. */
	if (argc != 2) {
		fprintf(stderr, "usage: test_s3 %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("s3.us-west-2.amazonaws.com:80")) == NULL) {
		warnp("Cannot resolve S3 DNS");
		exit(1);
	}

	/* Construct PUT request. */
	R.method = "PUT";
	R.bucket = "kivaloo-test";
	R.path = "/nelson";
	R.nheaders = 0;
	R.headers = NULL;
	R.bodylen = strlen("ha-ha\n");
	R.body = (const uint8_t *)"ha-ha\n";

	/* Send PUT request. */
	done = 0;
	(void)s3_request(sas, key_id, key_secret, "us-west-2",
	    &R, 0, donereq, &done);

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

	/* Convert the PUT into a GET. */
	R.method = "GET";
	R.bucket = "kivaloo-test";
	R.path = "/nelson";
	R.nheaders = 0;
	R.headers = NULL;
	R.bodylen = 0;
	R.body = NULL;

	/* Send PUT request. */
	done = 0;
	(void)s3_request(sas, key_id, key_secret, "us-west-2",
	    &R, 6, 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! */
	return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x253c
callq 0x4cbc
cmpl $0x2, %ebp
jne 0x267d
movq 0x8(%rbx), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x27a8
testl %eax, %eax
jne 0x269e
leaq 0x8ad3(%rip), %rdi      # 0xb03a
callq 0x3e44
testq %rax, %rax
je 0x26b1
movq %rax, %rbx
leaq 0x8aef(%rip), %rax      # 0xb06e
leaq 0x20(%rsp), %r8
movq %rax, (%r8)
leaq 0x8ae4(%rip), %r12      # 0xb072
movq %r12, 0x8(%r8)
leaq 0x8ae6(%rip), %r13      # 0xb07f
movq %r13, 0x10(%r8)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r8)
movq $0x6, 0x28(%r8)
leaq 0xc(%rsp), %r14
andl $0x0, (%r14)
leaq 0x8aca(%rip), %rax      # 0xb087
movq %rax, 0x30(%r8)
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x12d(%rip), %r15       # 0x26ff
leaq 0x8ab5(%rip), %rcx      # 0xb08e
movq %rbx, %rdi
xorl %r9d, %r9d
pushq %r14
pushq %r15
callq 0x504c
popq %rcx
popq %rdx
movq %r14, %rdi
callq 0x2d57
testl %eax, %eax
jne 0x266a
leaq 0x38(%rsp), %rax
leaq 0x8aaa(%rip), %rcx      # 0xb0ac
movq %rcx, -0x18(%rax)
movq %r12, -0x10(%rax)
movq %r13, -0x8(%rax)
andl $0x0, 0xc(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x8a60(%rip), %rcx      # 0xb08e
leaq 0x20(%rsp), %r8
pushq $0x6
popq %r9
movq %rbx, %rdi
pushq %r14
pushq %r15
callq 0x504c
popq %rcx
popq %rdx
movq %r14, %rdi
callq 0x2d57
testl %eax, %eax
jne 0x266a
movq %rbx, %rdi
callq 0x4443
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2090
cmpl $0x0, (%rax)
jne 0x26cb
leaq 0x8a1d(%rip), %rdi      # 0xb098
jmp 0x26c2
movq 0xe974(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x8976(%rip), %rsi      # 0xb004
leaq 0x8982(%rip), %rdx      # 0xb017
xorl %eax, %eax
callq 0x2250
jmp 0x26f7
callq 0x2090
cmpl $0x0, (%rax)
jne 0x26d7
leaq 0x8972(%rip), %rdi      # 0xb021
jmp 0x26c2
callq 0x2090
cmpl $0x0, (%rax)
jne 0x26e3
leaq 0x8996(%rip), %rdi      # 0xb058
xorl %eax, %eax
callq 0x4ec8
jmp 0x26f7
movq %rax, %rbx
leaq 0x89c3(%rip), %rdi      # 0xb098
jmp 0x26ed
movq %rax, %rbx
leaq 0x8940(%rip), %rdi      # 0xb021
jmp 0x26ed
movq %rax, %rbx
leaq 0x896b(%rip), %rdi      # 0xb058
xorl %eax, %eax
callq 0x4d39
andl $0x0, (%rbx)
pushq $0x1
popq %rdi
callq 0x2390