#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 */
typedef int /*<<< orphan*/ pthread_t;
typedef int /*<<< orphan*/ mqd_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int mq_receive(int /*<<< orphan*/, char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ pthread_detach(int /*<<< orphan*/);
int /*<<< orphan*/ pthread_self();
int /*<<< orphan*/ sleep(int);
void *deal_data(void *arg) {
  mqd_t mqd = *((mqd_t *)arg);
  char buff[200];
  pthread_t thread;
  thread = pthread_self();
  pthread_detach(thread);
  sleep(3);
  if ((mq_receive(mqd, buff, 200, NULL)) == -1) {
    perror("mq_receive");
    exit(1);
  }
  printf("data:%s\n", buff);
  return (void *)1;
}


x86 assembly (clang, -O0):
<deal_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%edi
call   1040 <pthread_detach@plt>
mov    $0x3,%edi
call   1090 <sleep@plt>
mov    -0xc(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    $0xc8,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <mq_receive@plt>
cmp    $0xffffffff,%eax
jne    11e1 <deal_data+0x71>
lea    0xe2e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deal_data>:
push   %rbx
sub    $0xd0,%rsp
mov    (%rdi),%ebx
xor    %eax,%eax
call   1050 <pthread_self@plt>
mov    %eax,%edi
call   1040 <pthread_detach@plt>
mov    $0x3,%edi
call   1090 <sleep@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0xc8,%edx
xor    %ecx,%ecx
call   1060 <mq_receive@plt>
cmp    $0xffffffff,%eax
je     11c5 <deal_data+0x55>
lea    0xe5c(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0xd0,%rsp
pop    %rbx
ret
lea    0xe34(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"mq_receive\00"
@.str.1 = [9 x i8] c"data:%s\0A\00"
define i8* @deal_data(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [200 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %3
%9 = call i32 (...) @pthread_self()
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = call i32 @pthread_detach(i32 %10)
%12 = call i32 @sleep(i32 3)
%13 = load i32, i32* %3
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%15 = call i32 @mq_receive(i32 %13, i8* %14, i32 200, i32* null)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %1
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %21)
ret i8* inttoptr (i64 1 to i8*)
}

LLVM IR (-O2):
@.str = [11 x i8] c"mq_receive\00"
@.str.1 = [9 x i8] c"data:%s\0A\00"
define i8* @deal_data(i8* nocapture %0) {
%2 = alloca [200 x i8]
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%6 = tail call i32 (...) @pthread_self()
%7 = tail call i32 @pthread_detach(i32 %6)
%8 = tail call i32 @sleep(i32 3)
%9 = call i32 @mq_receive(i32 %4, i8* %5, i32 200, i32* null)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret i8* inttoptr (i64 1 to i8*)
}