// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/perftests/s3_put/main.c
// Function: main
int
main(int argc, char * argv[])
{
	struct sock_addr ** sas;
	int s;
	struct wire_requestqueue * Q;
	struct stat sb;
	FILE * f;
	uint8_t * buf;
	struct put_state C;

	WARNP_INIT;

	/* Check number of arguments. */
	if (argc != 5) {
		fprintf(stderr, "usage: s3_put %s %s %s %s\n", "<socketname>",
		    "<file>", "<bucket>", "<object>");
		exit(1);
	}

	/* Stat file. */
	if (stat(argv[2], &sb)) {
		warnp("stat(%s)", argv[2]);
		exit(1);
	}
	if (!S_ISREG(sb.st_mode) ||
	    sb.st_size > (off_t)PROTO_S3_MAXLEN ||
	    sb.st_size > (off_t)SIZE_MAX ||
	    sb.st_size < (off_t)0 ||
	    sb.st_size == 0) {
		warn0("Bad file: %s", argv[2]);
		exit(1);
	}
	if ((buf = malloc((size_t)sb.st_size)) == NULL) {
		warnp("malloc");
		exit(1);
	}

	/* Resolve the socket address and connect. */
	if ((sas = sock_resolve(argv[1])) == NULL) {
		warnp("Error resolving socket address: %s", argv[1]);
		exit(1);
	}
	if (sas[0] == NULL) {
		warn0("No addresses found for %s", argv[1]);
		exit(1);
	}
	if ((s = sock_connect(sas)) == -1)
		exit(1);

	/* Create a request queue. */
	if ((Q = wire_requestqueue_init(s)) == NULL) {
		warnp("Cannot create packet write queue");
		exit(1);
	}

	/* Read file. */
	if ((f = fopen(argv[2], "r")) == NULL) {
		warnp("fopen(%s)", argv[2]);
		exit(1);
	}
	if (fread(buf, (size_t)sb.st_size, 1, f) != 1) {
		warnp("fread(%s)", argv[2]);
		exit(1);
	}
	if (fclose(f)) {
		warnp("fclose(%s)", argv[2]);
		exit(1);
	}

	/* Send request. */
	C.done = 0;
	if (proto_s3_request_put(Q, argv[3], argv[4], (size_t)sb.st_size, buf,
	    callback_done, &C)) {
		warnp("proto_s3_request_put");
		exit(1);
	}
	if (events_spin(&C.done)) {
		warnp("events_spin");
		exit(1);
	}

	/* Free the request queue. */
	wire_requestqueue_destroy(Q);
	wire_requestqueue_free(Q);

	/* Free socket addresses. */
	sock_addr_freelist(sas);

	/* Success! */
	exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x248f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x66f0
jmp 0x2491
cmpl $0x5, -0x8(%rbp)
je 0x24d5
movq 0x10b5a(%rip), %rax     # 0x12ff8
movq (%rax), %rdi
leaq 0xbb5c(%rip), %rsi      # 0xe004
leaq 0xbb70(%rip), %rdx      # 0xe01f
leaq 0xbb76(%rip), %rcx      # 0xe02c
leaq 0xbb76(%rip), %r8       # 0xe033
leaq 0xbb78(%rip), %r9       # 0xe03c
movb $0x0, %al
callq 0x21e0
movl $0x1, %edi
callq 0x22f0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x21f0
cmpl $0x0, %eax
je 0x253f
jmp 0x24f0
callq 0x20a0
cmpl $0x0, (%rax)
je 0x251d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xbb3c(%rip), %rdi      # 0xe045
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2533
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xbb19(%rip), %rdi      # 0xe045
movb $0x0, %al
callq 0x6a00
jmp 0x2535
movl $0x1, %edi
callq 0x22f0
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x257d
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, -0x88(%rbp)
jg 0x257d
cmpq $-0x1, -0x88(%rbp)
jg 0x257d
cmpq $0x0, -0x88(%rbp)
jl 0x257d
cmpq $0x0, -0x88(%rbp)
jne 0x25aa
jmp 0x257f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xbac0(%rip), %rdi      # 0xe04e
movb $0x0, %al
callq 0x6a00
callq 0x20a0
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x22f0
movq -0x88(%rbp), %rdi
callq 0x2220
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
jne 0x2604
jmp 0x25c5
callq 0x20a0
cmpl $0x0, (%rax)
je 0x25ea
leaq 0xba85(%rip), %rdi      # 0xe05b
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x25f8
leaq 0xba6a(%rip), %rdi      # 0xe05b
movb $0x0, %al
callq 0x6a00
jmp 0x25fa
movl $0x1, %edi
callq 0x22f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x4b40
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x266c
jmp 0x261d
callq 0x20a0
cmpl $0x0, (%rax)
je 0x264a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xba2c(%rip), %rdi      # 0xe062
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2660
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xba09(%rip), %rdi      # 0xe062
movb $0x0, %al
callq 0x6a00
jmp 0x2662
movl $0x1, %edi
callq 0x22f0
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x26a3
jmp 0x2678
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xb9fe(%rip), %rdi      # 0xe085
movb $0x0, %al
callq 0x6a00
callq 0x20a0
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x22f0
movq -0x18(%rbp), %rdi
callq 0x5a10
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
jne 0x26be
movl $0x1, %edi
callq 0x22f0
movl -0x1c(%rbp), %edi
callq 0x7e10
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x2711
jmp 0x26d2
callq 0x20a0
cmpl $0x0, (%rax)
je 0x26f7
leaq 0xb9bc(%rip), %rdi      # 0xe09f
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2705
leaq 0xb9a1(%rip), %rdi      # 0xe09f
movb $0x0, %al
callq 0x6a00
jmp 0x2707
movl $0x1, %edi
callq 0x22f0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0xcb31(%rip), %rsi      # 0xf251
callq 0x22b0
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
jne 0x2783
jmp 0x2734
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2761
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xb973(%rip), %rdi      # 0xe0c0
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2777
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xb950(%rip), %rdi      # 0xe0c0
movb $0x0, %al
callq 0x6a00
jmp 0x2779
movl $0x1, %edi
callq 0x22f0
movq -0xc8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0xc0(%rbp), %rcx
movl $0x1, %edx
callq 0x20c0
cmpq $0x1, %rax
je 0x27f9
jmp 0x27aa
callq 0x20a0
cmpl $0x0, (%rax)
je 0x27d7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xb907(%rip), %rdi      # 0xe0ca
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x27ed
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xb8e4(%rip), %rdi      # 0xe0ca
movb $0x0, %al
callq 0x6a00
jmp 0x27ef
movl $0x1, %edi
callq 0x22f0
movq -0xc0(%rbp), %rdi
callq 0x2110
cmpl $0x0, %eax
je 0x285b
jmp 0x280c
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2839
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xb8af(%rip), %rdi      # 0xe0d4
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x284f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0xb88c(%rip), %rdi      # 0xe0d4
movb $0x0, %al
callq 0x6a00
jmp 0x2851
movl $0x1, %edi
callq 0x22f0
movl $0x0, -0xd0(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x88(%rbp), %rcx
movq -0xc8(%rbp), %r8
leaq 0xd2(%rip), %r9         # 0x2960
leaq -0xd0(%rbp), %rax
movq %rax, (%rsp)
callq 0x6c40
cmpl $0x0, %eax
je 0x28e4
jmp 0x28a5
callq 0x20a0
cmpl $0x0, (%rax)
je 0x28ca
leaq 0xb829(%rip), %rdi      # 0xe0df
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x28d8
leaq 0xb80e(%rip), %rdi      # 0xe0df
movb $0x0, %al
callq 0x6a00
jmp 0x28da
movl $0x1, %edi
callq 0x22f0
leaq -0xd0(%rbp), %rdi
callq 0x2c40
cmpl $0x0, %eax
je 0x2936
jmp 0x28f7
callq 0x20a0
cmpl $0x0, (%rax)
je 0x291c
leaq 0xb7ec(%rip), %rdi      # 0xe0f4
movb $0x0, %al
callq 0x67b0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x292a
leaq 0xb7d1(%rip), %rdi      # 0xe0f4
movb $0x0, %al
callq 0x6a00
jmp 0x292c
movl $0x1, %edi
callq 0x22f0
movq -0x28(%rbp), %rdi
callq 0x83e0
movq -0x28(%rbp), %rdi
callq 0x8420
movq -0x18(%rbp), %rdi
callq 0x5770
xorl %edi, %edi
callq 0x22f0
nopl (%rax,%rax)