#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 */
struct mq_attr {
  int /*<<< orphan*/ mq_curmsgs;
  int /*<<< orphan*/ mq_msgsize;
  int /*<<< orphan*/ mq_maxmsg;
  int /*<<< orphan*/ mq_flags;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_attribute(struct mq_attr *attr) {
  if (attr) {
    printf("--------------------\n");
    printf("mq_flags: 0x%lx\n", attr->mq_flags);
    printf("mq_maxmsg: 0x%lx\n", attr->mq_maxmsg);
    printf("mq_msgsize: 0x%lx\n", attr->mq_msgsize);
    printf("mq_curmsgs: 0x%lx\n", attr->mq_curmsgs);
    printf("--------------------\n");
  }
}


x86 assembly (clang, -O0):
<dump_attribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1196 <dump_attribute+0x86>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_attribute>:
test   %rdi,%rdi
je     118d <dump_attribute+0x6d>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xf16(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0xc(%rbx),%esi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
%struct.mq_attr = type { i32, i32, i32, i32 }
@.str = [22 x i8] c"--------------------\0A\00"
@.str.1 = [17 x i8] c"mq_flags: 0x%lx\0A\00"
@.str.2 = [18 x i8] c"mq_maxmsg: 0x%lx\0A\00"
@.str.3 = [19 x i8] c"mq_msgsize: 0x%lx\0A\00"
@.str.4 = [19 x i8] c"mq_curmsgs: 0x%lx\0A\00"
define void @dump_attribute(%struct.mq_attr* %0) {
%2 = alloca %struct.mq_attr*
store %struct.mq_attr* %0, %struct.mq_attr** %2
%3 = load %struct.mq_attr*, %struct.mq_attr** %2
%4 = icmp ne %struct.mq_attr* %3, null
br i1 %4, label %5, label %24
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = load %struct.mq_attr*, %struct.mq_attr** %2
%8 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %7, i32 0, i32 3
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load %struct.mq_attr*, %struct.mq_attr** %2
%12 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %11, i32 0, i32 2
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load %struct.mq_attr*, %struct.mq_attr** %2
%16 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load %struct.mq_attr*, %struct.mq_attr** %2
%20 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %5, %1
ret void
}

LLVM IR (-O2):
%struct.mq_attr = type { i32, i32, i32, i32 }
@.str.1 = [17 x i8] c"mq_flags: 0x%lx\0A\00"
@.str.2 = [18 x i8] c"mq_maxmsg: 0x%lx\0A\00"
@.str.3 = [19 x i8] c"mq_msgsize: 0x%lx\0A\00"
@.str.4 = [19 x i8] c"mq_curmsgs: 0x%lx\0A\00"
@str.5 = [21 x i8] c"--------------------\00"
define void @dump_attribute(%struct.mq_attr* %0) {
%2 = icmp eq %struct.mq_attr* %0, null
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%5 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %0, i64 0, i32 3
%6 = load i32, i32* %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %0, i64 0, i32 2
%9 = load i32, i32* %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %0, i64 0, i32 1
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %0, i64 0, i32 0
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %18
18: ; preds = %3, %1
ret void
}