// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/chargenx.c
// Function: doit
static int doit()
{
	char doubleline[(END_CHAR - START_CHAR) * 2 + 1];
	int i;
	char *buf = NULL;
	int bufsz = 0;
	char *line = NULL;

	for (i=0; i<(END_CHAR - START_CHAR) * 2; i++) {
		doubleline[i] = (i % (END_CHAR - START_CHAR)) + START_CHAR;
	}
	doubleline[i] = '\0';

	if (*args->id) {
		int id_len = strlen(args->id);
		bufsz = id_len + 1 + LINE_LENGTH + 1;
		buf = malloc(bufsz);
		assert(buf);
		strcpy(buf, args->id);
		buf[id_len] = ' ';
		line = buf + id_len + 1;
	} else {
		bufsz = LINE_LENGTH + 1;
		buf = malloc(bufsz);
		assert(buf);
		line = buf;
	}

	if (args->lines) {
		int fd = STDOUT_FILENO;
		long count = 1;
		long n = args->lines;
		long b = args->between_delay;
		long u = args->between_lines;
		int skip = args->reverse_order ? END_CHAR - START_CHAR - 1 : 1;

		DEBUG("before main loop");

		i = args->start_char - START_CHAR;
		for (;;) {
			if (got_SIGUSR1) {
				got_SIGUSR1 = 0;
				DEBUG("got SIGUSR1");
				if (*args->out_file) {
					DEBUG("re-opening [%s]", args->out_file);
					if (reopen_stdout()) return -1;
					DEBUG("stdout successfully redirected to [%s]", args->out_file);
				}
			}

			memcpy(line, doubleline + i, LINE_LENGTH);
			line[LINE_LENGTH] = '\n';

			assert(write_exact(fd, buf, bufsz) == bufsz);

			i = (i + skip) % (END_CHAR - START_CHAR);
			if (!--n) break;

			if (u) {
				if (count % u == 0) usleep(1);
			} else if (b) usleep(b);

			if (got_SIGTERM) {
				got_SIGTERM = 0;
				DEBUG("got SIGTERM");
				break;
			}

			if (got_SIGHUP) {
				got_SIGHUP = 0;
				DEBUG("got SIGHUP");
				i = 0;
			}

			count++;
		}

		DEBUG("after main loop");
	}

	/* cleanup
	 */

	free(buf);
	buf = NULL;
	line = NULL;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq $0x0, -0xe0(%rbp)
movl $0x0, -0xe4(%rbp)
movq $0x0, -0xf0(%rbp)
movl $0x0, -0xd4(%rbp)
cmpl $0xbc, -0xd4(%rbp)
jge 0x40b3
movl -0xd4(%rbp), %eax
movl $0x5e, %ecx
cltd
idivl %ecx
addl $0x21, %edx
movb %dl, %cl
movslq -0xd4(%rbp), %rax
movb %cl, -0xd0(%rbp,%rax)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x4075
movslq -0xd4(%rbp), %rax
movb $0x0, -0xd0(%rbp,%rax)
cmpb $0x0, 0x71bf(%rip)      # 0xb288
je 0x4177
leaq 0x71b2(%rip), %rdi      # 0xb288
callq 0x20e0
movl %eax, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
addl $0x48, %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
movslq -0xe4(%rbp), %rdi
callq 0x21f0
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x4115
jmp 0x4134
leaq 0x4691(%rip), %rdi      # 0x87ad
leaq 0x4139(%rip), %rsi      # 0x825c
movl $0x179, %edx            # imm = 0x179
leaq 0x4682(%rip), %rcx      # 0x87b1
callq 0x2140
movq -0xe0(%rbp), %rdi
leaq 0x7146(%rip), %rsi      # 0xb288
callq 0x20a0
movq -0xe0(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movb $0x20, (%rax,%rcx)
movq -0xe0(%rbp), %rax
movslq -0xf4(%rbp), %rcx
addq %rcx, %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
jmp 0x41cd
movl $0x49, -0xe4(%rbp)
movslq -0xe4(%rbp), %rdi
callq 0x21f0
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x41a0
jmp 0x41bf
leaq 0x4606(%rip), %rdi      # 0x87ad
leaq 0x40ae(%rip), %rsi      # 0x825c
movl $0x180, %edx            # imm = 0x180
leaq 0x45f7(%rip), %rcx      # 0x87b1
callq 0x2140
movq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, 0x70ab(%rip)      # 0xb280
je 0x4493
movl $0x1, -0xf8(%rbp)
movq $0x1, -0x100(%rbp)
movq 0x7089(%rip), %rax      # 0xb280
movq %rax, -0x108(%rbp)
movq 0x7063(%rip), %rax      # 0xb268
movq %rax, -0x110(%rbp)
movq 0x705d(%rip), %rax      # 0xb270
movq %rax, -0x118(%rbp)
movl 0x70d0(%rip), %edx      # 0xb2f0
movl $0x1, %eax
movl $0x5d, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x11c(%rbp)
leaq 0x401f(%rip), %rdi      # 0x825c
movl $0x18c, %esi            # imm = 0x18C
leaq 0x4573(%rip), %rdx      # 0x87bc
movb $0x0, %al
callq 0x7000
movl 0x7096(%rip), %eax      # 0xb2ec
subl $0x21, %eax
movl %eax, -0xd4(%rbp)
movl 0x74d3(%rip), %eax      # 0xb738
cmpl $0x0, %eax
je 0x4309
movl $0x0, 0x74c0(%rip)      # 0xb738
leaq 0x3fdd(%rip), %rdi      # 0x825c
movl $0x192, %esi            # imm = 0x192
leaq 0x4542(%rip), %rdx      # 0x87cd
movb $0x0, %al
callq 0x7000
cmpb $0x0, 0x705b(%rip)      # 0xb2f4
je 0x4307
jmp 0x429d
leaq 0x3fb8(%rip), %rdi      # 0x825c
movl $0x194, %esi            # imm = 0x194
leaq 0x4529(%rip), %rdx      # 0x87d9
leaq 0x6ea9(%rip), %rcx      # 0xb160
addq $0x194, %rcx            # imm = 0x194
movb $0x0, %al
callq 0x7000
callq 0x4540
cmpl $0x0, %eax
je 0x42db
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x44bc
jmp 0x42dd
leaq 0x3f78(%rip), %rdi      # 0x825c
movl $0x196, %esi            # imm = 0x196
leaq 0x3f77(%rip), %rdx      # 0x8267
leaq 0x6e69(%rip), %rcx      # 0xb160
addq $0x194, %rcx            # imm = 0x194
movb $0x0, %al
callq 0x7000
jmp 0x4307
jmp 0x4309
movq -0xf0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movslq -0xd4(%rbp), %rax
addq %rax, %rsi
movl $0x48, %edx
callq 0x21e0
movq -0xf0(%rbp), %rax
movb $0xa, 0x48(%rax)
movl -0xf8(%rbp), %edi
movq -0xe0(%rbp), %rsi
movl -0xe4(%rbp), %edx
callq 0x44d0
cmpl -0xe4(%rbp), %eax
jne 0x4358
jmp 0x4377
leaq 0x448a(%rip), %rdi      # 0x87e9
leaq 0x3ef6(%rip), %rsi      # 0x825c
movl $0x19d, %edx            # imm = 0x19D
leaq 0x443f(%rip), %rcx      # 0x87b1
callq 0x2140
movl -0xd4(%rbp), %eax
addl -0x11c(%rbp), %eax
movl $0x5e, %ecx
cltd
idivl %ecx
movl %edx, -0xd4(%rbp)
movq -0x108(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
jne 0x43ae
jmp 0x4475
cmpq $0x0, -0x118(%rbp)
je 0x43da
movq -0x100(%rbp), %rax
cqto
idivq -0x118(%rbp)
cmpq $0x0, %rdx
jne 0x43d8
movl $0x1, %edi
callq 0x2280
jmp 0x43f4
cmpq $0x0, -0x110(%rbp)
je 0x43f2
movq -0x110(%rbp), %rax
movl %eax, %edi
callq 0x2280
jmp 0x43f4
movl 0x7346(%rip), %eax      # 0xb740
cmpl $0x0, %eax
je 0x4425
movl $0x0, 0x7337(%rip)      # 0xb740
leaq 0x3e4c(%rip), %rdi      # 0x825c
movl $0x1a8, %esi            # imm = 0x1A8
leaq 0x43f2(%rip), %rdx      # 0x880e
movb $0x0, %al
callq 0x7000
jmp 0x4475
movl 0x7311(%rip), %eax      # 0xb73c
cmpl $0x0, %eax
je 0x445e
movl $0x0, 0x7302(%rip)      # 0xb73c
leaq 0x3e1b(%rip), %rdi      # 0x825c
movl $0x1ae, %esi            # imm = 0x1AE
leaq 0x43cd(%rip), %rdx      # 0x881a
movb $0x0, %al
callq 0x7000
movl $0x0, -0xd4(%rbp)
movq -0x100(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x100(%rbp)
jmp 0x425f
jmp 0x4477
leaq 0x3dde(%rip), %rdi      # 0x825c
movl $0x1b5, %esi            # imm = 0x1B5
leaq 0x439b(%rip), %rdx      # 0x8825
movb $0x0, %al
callq 0x7000
jmp 0x4493
movq -0xe0(%rbp), %rdi
callq 0x2040
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xf0(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax,%rax)