#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*/ consume(int);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ product();
int pthread_self();
int /*<<< orphan*/ show_time();
void *start_thread(void *arg) {
  int tp = 0;
  if (NULL != arg && 0 == *(int *)arg) {
    tp = 1;
  }
  free(arg);
  if (0 == tp) {
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("this is a [%s]", "consumer");
      printf("\n");
    } while (0);
    consume(pthread_self() % 5);
  } else {
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("this is a [%s]", "producter");
      printf("\n");
    } while (0);
    product();
  }
  return NULL;
}


x86 assembly (clang, -O0):
<start_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
je     1194 <start_thread+0x34>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%eax
jne    1194 <start_thread+0x34>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
jne    120a <start_thread+0xaa>
jmp    11ad <start_thread+0x4d>
mov    $0x0,%al
call   1050 <show_time@plt>
mov    $0x0,%al
call   1080 <pthread_self@plt>
movslq %eax,%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <pthread_self@plt>
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1060 <consume@plt>
jmp    1258 <start_thread+0xf8>
jmp    120f <start_thread+0xaf>
mov    $0x0,%al
call   1050 <show_time@plt>
mov    $0x0,%al
call   1080 <pthread_self@plt>
movslq %eax,%rsi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd5(%rip),%rdi
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <product@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_thread>:
push   %rbx
test   %rdi,%rdi
je     11c8 <start_thread+0x58>
mov    (%rdi),%ebx
call   1030 <free@plt>
test   %ebx,%ebx
jne    11cf <start_thread+0x5f>
xor    %eax,%eax
call   1060 <show_time@plt>
xor    %eax,%eax
call   1090 <pthread_self@plt>
movslq %eax,%rsi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
lea    0xe74(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1080 <product@plt>
jmp    1235 <start_thread+0xc5>
xor    %edi,%edi
call   1030 <free@plt>
xor    %eax,%eax
call   1060 <show_time@plt>
xor    %eax,%eax
call   1090 <pthread_self@plt>
movslq %eax,%rsi
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe15(%rip),%rdi
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1090 <pthread_self@plt>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
call   1070 <consume@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c" -- [%lu]\00"
@.str.1 = [15 x i8] c"this is a [%s]\00"
@.str.2 = [9 x i8] c"consumer\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [10 x i8] c"producter\00"
define i8* @start_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = icmp ne i8* null, %4
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = icmp eq i32 0, %9
br i1 %10, label %11, label %12
11: ; preds = %6
store i32 1, i32* %3
br label %12
12: ; preds = %11, %6, %1
%13 = load i8*, i8** %2
%14 = call i32 @free(i8* %13)
%15 = load i32, i32* %3
%16 = icmp eq i32 0, %15
br i1 %16, label %17, label %29
17: ; preds = %12
br label %18
18: ; preds = %17
%19 = call i32 (...) @show_time()
%20 = call i32 (...) @pthread_self()
%21 = sext i32 %20 to i64
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %18
%26 = call i32 (...) @pthread_self()
%27 = srem i32 %26, 5
%28 = call i32 @consume(i32 %27)
br label %39
29: ; preds = %12
br label %30
30: ; preds = %29
%31 = call i32 (...) @show_time()
%32 = call i32 (...) @pthread_self()
%33 = sext i32 %32 to i64
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %30
%38 = call i32 (...) @product()
br label %39
39: ; preds = %37, %25
ret i8* null
}

LLVM IR (-O2):
@.str = [10 x i8] c" -- [%lu]\00"
@.str.1 = [15 x i8] c"this is a [%s]\00"
@.str.2 = [9 x i8] c"consumer\00"
@.str.4 = [10 x i8] c"producter\00"
define noalias i8* @start_thread(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
%7 = tail call i32 @free(i8* %0)
br i1 %6, label %20, label %10
8: ; preds = %1
%9 = tail call i32 @free(i8* null)
br label %10
10: ; preds = %8, %3
%11 = tail call i32 (...) @show_time()
%12 = tail call i32 (...) @pthread_self()
%13 = sext i32 %12 to i64
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 (...) @pthread_self()
%18 = srem i32 %17, 5
%19 = tail call i32 @consume(i32 %18)
br label %28
20: ; preds = %3
%21 = tail call i32 (...) @show_time()
%22 = tail call i32 (...) @pthread_self()
%23 = sext i32 %22 to i64
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %23)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%26 = tail call i32 @putchar(i32 10)
%27 = tail call i32 (...) @product()
br label %28
28: ; preds = %20, %10
ret i8* null
}