#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*/ printf(char *, int, int, char *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int q_dequeue(int, void **);
void *consumer(void *data) {
  char *str;
  int i, id;
  int qid = (int)data;
  for (i = 0; i < 5; i++) {
    id = q_dequeue(qid, (void **)&str);
    printf("Queue:%d, Id:%d, Data:%s\n", qid, id, str);
  }
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<consumer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    1187 <consumer+0x57>
mov    -0x24(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1050 <q_dequeue@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <consumer+0x1a>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consumer>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1050 <q_dequeue@plt>
mov    0x8(%rsp),%rcx
lea    0xeab(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <q_dequeue@plt>
mov    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <q_dequeue@plt>
mov    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <q_dequeue@plt>
mov    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <q_dequeue@plt>
mov    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <pthread_exit@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Queue:%d, Id:%d, Data:%s\0A\00"
define i8* @consumer(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = ptrtoint i8* %8 to i32
store i32 %9, i32* %7
store i32 0, i32* %5
br label %10
10: ; preds = %20, %1
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %7
%15 = call i32 @q_dequeue(i32 %14, i8** %4)
store i32 %15, i32* %6
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i8* %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %10
23: ; preds = %10
%24 = call i32 @pthread_exit(i32* null)
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str = [26 x i8] c"Queue:%d, Id:%d, Data:%s\0A\00"
define noalias i8* @consumer(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = ptrtoint i8* %0 to i64
%5 = trunc i64 %4 to i32
%6 = call i32 @q_dequeue(i32 %5, i8** %2)
%7 = load i8*, i8** %2
%8 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6, i8* %7)
%9 = call i32 @q_dequeue(i32 %5, i8** %2)
%10 = load i8*, i8** %2
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %9, i8* %10)
%12 = call i32 @q_dequeue(i32 %5, i8** %2)
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %12, i8* %13)
%15 = call i32 @q_dequeue(i32 %5, i8** %2)
%16 = load i8*, i8** %2
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %15, i8* %16)
%18 = call i32 @q_dequeue(i32 %5, i8** %2)
%19 = load i8*, i8** %2
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %18, i8* %19)
%21 = call i32 @pthread_exit(i32* null)
ret i8* undef
}