// File: /workspace/github_c_makefile_star2_O3/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 0x266c
callq 0x526c
cmpl $0x2, %ebp
jne 0x27b9
movq 0x8(%rbx), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x28dc
testl %eax, %eax
jne 0x27be
leaq 0x99a3(%rip), %rdi      # 0xc03a
callq 0x4268
testq %rax, %rax
je 0x27d1
movq %rax, %rbx
leaq 0x99bf(%rip), %rax      # 0xc06e
leaq 0x20(%rsp), %r8
movq %rax, (%r8)
leaq 0x99b4(%rip), %r12      # 0xc072
movq %r12, 0x8(%r8)
leaq 0x99b6(%rip), %r13      # 0xc07f
movq %r13, 0x10(%r8)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r8)
movq $0x6, 0x28(%r8)
leaq 0x99a3(%rip), %rax      # 0xc087
movq %rax, 0x30(%r8)
leaq 0xc(%rsp), %r14
movl $0x0, (%r14)
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x11f(%rip), %r15       # 0x2824
leaq 0x9982(%rip), %rcx      # 0xc08e
movq %rbx, %rdi
xorl %r9d, %r9d
pushq %r14
pushq %r15
callq 0x5530
addq $0x10, %rsp
movq %r14, %rdi
callq 0x2e6d
testl %eax, %eax
jne 0x27a6
leaq 0x38(%rsp), %rax
leaq 0x9975(%rip), %rcx      # 0xc0ac
movq %rcx, -0x18(%rax)
movq %r12, -0x10(%rax)
movq %r13, -0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x9928(%rip), %rcx      # 0xc08e
leaq 0x20(%rsp), %r8
movl $0x6, %r9d
movq %rbx, %rdi
pushq %r14
pushq %r15
callq 0x5530
addq $0x10, %rsp
movq %r14, %rdi
callq 0x2e6d
testl %eax, %eax
jne 0x27a6
movq %rbx, %rdi
callq 0x497a
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 0x27eb
leaq 0x98e1(%rip), %rdi      # 0xc098
jmp 0x27e2
callq 0x2420
callq 0x2090
cmpl $0x0, (%rax)
jne 0x27f7
leaq 0x9852(%rip), %rdi      # 0xc021
jmp 0x27e2
callq 0x2090
cmpl $0x0, (%rax)
jne 0x2803
leaq 0x9876(%rip), %rdi      # 0xc058
xorl %eax, %eax
callq 0x540b
jmp 0x281a
movq %rax, %rbx
leaq 0x98a3(%rip), %rdi      # 0xc098
jmp 0x280d
movq %rax, %rbx
leaq 0x9820(%rip), %rdi      # 0xc021
jmp 0x280d
movq %rax, %rbx
leaq 0x984b(%rip), %rdi      # 0xc058
xorl %eax, %eax
callq 0x52ec
movl $0x0, (%rbx)
movl $0x1, %edi
callq 0x2380