#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ clear_tid();
scalar_t__ m_write(char *, int);
char *malloc(scalar_t__);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
scalar_t__ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void *productor(void *UNUSED) {
  char *s = "123456789ABCDEF0";
  char *data = malloc(strlen(s) + 1);
  sprintf(data, "%s", s);
  int write_length = 15;
  srand(time(NULL));
  while (write_length > 0) {
    int len = rand() % (17 / 2);
    len = write_length % (17 / 2);
    len++;
    if (0 == m_write(data, len)) {
    } else {
    }
    write_length--;
  }
  clear_tid();
}


x86 assembly (clang, -O0):
<productor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe6d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe52(%rip),%rsi
call   1080 <sprintf@plt>
movl   $0xf,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1240 <productor+0xc0>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1090 <m_write@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    122d <productor+0xad>
jmp    1232 <productor+0xb2>
jmp    1232 <productor+0xb2>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11db <productor+0x5b>
mov    $0x0,%al
call   1070 <clear_tid@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<productor>:
push   %rbx
mov    $0x11,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movups 0xe8b(%rip),%xmm0
movups %xmm0,(%rax)
movb   $0x0,0x10(%rax)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <m_write@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <clear_tid@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"123456789ABCDEF0\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @productor(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = add nsw i64 %9, 1
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 15, i32* %6
%15 = call i32 @time(i32* null)
%16 = call i32 @srand(i32 %15)
br label %17
17: ; preds = %33, %1
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 8
store i32 %22, i32* %7
%23 = load i32, i32* %6
%24 = srem i32 %23, 8
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = call i64 @m_write(i8* %27, i32 %28)
%30 = icmp eq i64 0, %29
br i1 %30, label %31, label %32
31: ; preds = %20
br label %33
32: ; preds = %20
br label %33
33: ; preds = %32, %31
%34 = load i32, i32* %6
%35 = add nsw i32 %34, -1
store i32 %35, i32* %6
br label %17
36: ; preds = %17
%37 = call i32 (...) @clear_tid()
%38 = load i8*, i8** %2
ret i8* %38
}

LLVM IR (-O2):
@.str = [17 x i8] c"123456789ABCDEF0\00"
define noalias i8* @productor(i8* nocapture readnone %0) {
%2 = tail call dereferenceable_or_null(17) i8* @malloc(i64 17)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(17) %2, i8* align 1 dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 17, i1 false)
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = tail call i64 @m_write(i8* %2, i32 8)
%7 = tail call i32 (...) @rand()
%8 = tail call i64 @m_write(i8* %2, i32 7)
%9 = tail call i32 (...) @rand()
%10 = tail call i64 @m_write(i8* %2, i32 6)
%11 = tail call i32 (...) @rand()
%12 = tail call i64 @m_write(i8* %2, i32 5)
%13 = tail call i32 (...) @rand()
%14 = tail call i64 @m_write(i8* %2, i32 4)
%15 = tail call i32 (...) @rand()
%16 = tail call i64 @m_write(i8* %2, i32 3)
%17 = tail call i32 (...) @rand()
%18 = tail call i64 @m_write(i8* %2, i32 2)
%19 = tail call i32 (...) @rand()
%20 = tail call i64 @m_write(i8* %2, i32 1)
%21 = tail call i32 (...) @rand()
%22 = tail call i64 @m_write(i8* %2, i32 8)
%23 = tail call i32 (...) @rand()
%24 = tail call i64 @m_write(i8* %2, i32 7)
%25 = tail call i32 (...) @rand()
%26 = tail call i64 @m_write(i8* %2, i32 6)
%27 = tail call i32 (...) @rand()
%28 = tail call i64 @m_write(i8* %2, i32 5)
%29 = tail call i32 (...) @rand()
%30 = tail call i64 @m_write(i8* %2, i32 4)
%31 = tail call i32 (...) @rand()
%32 = tail call i64 @m_write(i8* %2, i32 3)
%33 = tail call i32 (...) @rand()
%34 = tail call i64 @m_write(i8* %2, i32 2)
%35 = tail call i32 (...) @clear_tid()
ret i8* undef
}