#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*/ free(int *);
scalar_t__ malloc(int);
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ producer_consumer(int *, int, int *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  float d;
  int i, n, size, nt;
  int *buff;
  int *vec;
  scanf("%d %d %d", &nt, &n, &size);
  buff = (int *)malloc(size * sizeof(int));
  vec = (int *)malloc(n * sizeof(int));
  for (i = 0; i < n; i++)
    scanf("%d", &vec[i]);
  start = omp_get_wtime();
  producer_consumer(buff, size, vec, n);
  end = omp_get_wtime();
  printf("%lf\n", end - start);
  free(buff);
  free(vec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1080 <scanf@plt>
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11f4 <main+0x94>
mov    -0x48(%rbp),%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11bd <main+0x5d>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1060 <producer_consumer@plt>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xdd9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xe8c(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
cmpl   $0x0,0x8(%rsp)
jle    11df <main+0x7f>
lea    0xe50(%rip),%r12
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     11c0 <main+0x60>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    %r14,%rdi
mov    %r15,%rdx
call   1060 <producer_consumer@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
subsd  0x10(%rsp),%xmm0
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca float
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %12, i32* %10, i32* %11)
%16 = load i32, i32* %11
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i32*
store i32* %21, i32** %13
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i32*
store i32* %27, i32** %14
store i32 0, i32* %9
br label %28
28: ; preds = %38, %2
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i32*, i32** %14
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %36)
br label %38
38: ; preds = %32
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %28
41: ; preds = %28
%42 = call double (...) @omp_get_wtime()
store double %42, double* %6
%43 = load i32*, i32** %13
%44 = load i32, i32* %11
%45 = load i32*, i32** %14
%46 = load i32, i32* %10
%47 = call i32 @producer_consumer(i32* %43, i32 %44, i32* %45, i32 %46)
%48 = call double (...) @omp_get_wtime()
store double %48, double* %7
%49 = load double, double* %7
%50 = load double, double* %6
%51 = fsub double %49, %50
%52 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %51)
%53 = load i32*, i32** %13
%54 = call i32 @free(i32* %53)
%55 = load i32*, i32** %14
%56 = call i32 @free(i32* %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %3, i32* %4)
%10 = load i32, i32* %4
%11 = shl i32 %10, 2
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* %3
%15 = shl i32 %14, 2
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %2, %20
%21 = phi i64 [ %24, %20 ], [ 0, %2 ]
%22 = getelementptr inbounds i32, i32* %17, i64 %21
%23 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %21, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %20, label %28
28: ; preds = %20, %2
%29 = call double (...) @omp_get_wtime()
%30 = load i32, i32* %4
%31 = load i32, i32* %3
%32 = call i32 @producer_consumer(i32* %13, i32 %30, i32* %17, i32 %31)
%33 = call double (...) @omp_get_wtime()
%34 = fsub double %33, %29
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %34)
%36 = call i32 @free(i32* %13)
%37 = call i32 @free(i32* %17)
ret i32 0
}