#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 ipc_perm {
  int uid;
  int gid;
  int cuid;
  int cgid;
  int mode;
};
struct msqid_ds {
  scalar_t__ msg_ctime;
  scalar_t__ msg_rtime;
  scalar_t__ msg_stime;
  int /*<<< orphan*/ msg_lrpid;
  int /*<<< orphan*/ msg_lspid;
  scalar_t__ msg_qnum;
  scalar_t__ msg_qbytes;
  scalar_t__ msg_cbytes;
  struct ipc_perm msg_perm;
};

/* Variables and functions */
int /*<<< orphan*/ IPC_STAT;
char *ctime(scalar_t__ *);
char *gettext(char *);
int msgctl(int, int /*<<< orphan*/, struct msqid_ds *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
void print_msg(int msqid) {
  struct msqid_ds buf;
  struct ipc_perm *ipcp = &buf.msg_perm;
  if (msgctl(msqid, IPC_STAT, &buf) == -1) {
    perror("msgctl ");
    return;
  }
  printf(gettext("\nMessage Queue msqid=%d\n"), msqid);
  printf(gettext("uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"), ipcp->uid,
         ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode);
  printf(gettext("cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n"),
         (long)buf.msg_cbytes, (long)buf.msg_qbytes, (long)buf.msg_qnum,
         buf.msg_lspid, buf.msg_lrpid);
  printf(gettext("send_time=%-26.24s\n"),
         buf.msg_stime ? ctime(&buf.msg_stime) : gettext("Not set"));
  printf(gettext("rcv_time=%-26.24s\n"),
         buf.msg_rtime ? ctime(&buf.msg_rtime) : gettext("Not set"));
  printf(gettext("change_time=%-26.24s\n"),
         buf.msg_ctime ? ctime(&buf.msg_ctime) : gettext("Not set"));
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<print_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x58(%rbp),%rax
add    $0x38,%rax
mov    %rax,-0x60(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
lea    -0x58(%rbp),%rdx
call   1060 <msgctl@plt>
cmp    $0xffffffff,%eax
jne    1199 <print_msg+0x49>
lea    0xe71(%rip),%rdi
call   1070 <perror@plt>
jmp    131f <print_msg+0x1cf>
lea    0xe68(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
mov    -0x4(%rbp),%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe68(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
mov    -0x60(%rbp),%rax
mov    (%rax),%esi
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x60(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x60(%rbp),%rax
mov    0x10(%rax),%r9d
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe56(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x3c(%rbp),%r8d
mov    -0x40(%rbp),%r9d
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe5e(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1247 <print_msg+0xf7>
lea    -0x58(%rbp),%rdi
add    $0x10,%rdi
call   1030 <ctime@plt>
mov    %rax,-0x70(%rbp)
jmp    1257 <print_msg+0x107>
lea    0xe41(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1297 <print_msg+0x147>
lea    -0x58(%rbp),%rdi
add    $0x8,%rdi
call   1030 <ctime@plt>
mov    %rax,-0x80(%rbp)
jmp    12a7 <print_msg+0x157>
lea    0xdf1(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xded(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     12e9 <print_msg+0x199>
lea    -0x58(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x90(%rbp)
jmp    12fc <print_msg+0x1ac>
lea    0xd9f(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x90(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_msg>:
push   %rbx
sub    $0x50,%rsp
mov    %edi,%ebx
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1070 <msgctl@plt>
cmp    $0xffffffff,%eax
je     12b5 <print_msg+0x155>
lea    0xe80(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe81(%rip),%rdi
call   1050 <gettext@plt>
mov    0x38(%rsp),%esi
mov    0x3c(%rsp),%edx
mov    0x40(%rsp),%ecx
mov    0x44(%rsp),%r8d
mov    0x48(%rsp),%r9d
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1050 <gettext@plt>
mov    0x30(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    0x18(%rsp),%r9d
mov    0x1c(%rsp),%r8d
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe80(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rbx
cmpq   $0x0,0x10(%rsp)
je     1217 <print_msg+0xb7>
lea    0x10(%rsp),%rdi
call   1040 <ctime@plt>
jmp    1223 <print_msg+0xc3>
lea    0xe71(%rip),%rdi
call   1050 <gettext@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe60(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rbx
cmpq   $0x0,0x8(%rsp)
je     1253 <print_msg+0xf3>
lea    0x8(%rsp),%rdi
call   1040 <ctime@plt>
jmp    125f <print_msg+0xff>
lea    0xe35(%rip),%rdi
call   1050 <gettext@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe37(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rbx
cmpq   $0x0,(%rsp)
je     128c <print_msg+0x12c>
mov    %rsp,%rdi
call   1040 <ctime@plt>
jmp    1298 <print_msg+0x138>
lea    0xdfc(%rip),%rdi
call   1050 <gettext@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x50,%rsp
pop    %rbx
ret
lea    0xd44(%rip),%rdi
call   1080 <perror@plt>
jmp    12af <print_msg+0x14f>

LLVM IR (-O0):
%struct.msqid_ds = type { i64, i64, i64, i32, i32, i64, i64, i64, %struct.ipc_perm }
%struct.ipc_perm = type { i32, i32, i32, i32, i32 }
@IPC_STAT = global i32 0
@.str = [8 x i8] c"msgctl \00"
@.str.1 = [25 x i8] c"\0AMessage Queue msqid=%d\0A\00"
@.str.2 = [40 x i8] c"uid=%d\09gid=%d\09cuid=%d\09cgid=%d\09mode=%#o\0A\00"
@.str.3 = [50 x i8] c"cbytes=%ld\09qbytes=%ld\09qnum=%ld\09lspid=%d\09lrpid=%d\0A\00"
@.str.4 = [20 x i8] c"send_time=%-26.24s\0A\00"
@.str.5 = [8 x i8] c"Not set\00"
@.str.6 = [19 x i8] c"rcv_time=%-26.24s\0A\00"
@.str.7 = [22 x i8] c"change_time=%-26.24s\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @print_msg(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.msqid_ds
%4 = alloca %struct.ipc_perm*
store i32 %0, i32* %2
%5 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 8
store %struct.ipc_perm* %5, %struct.ipc_perm** %4
%6 = load i32, i32* %2
%7 = load i32, i32* @IPC_STAT
%8 = call i32 @msgctl(i32 %6, i32 %7, %struct.msqid_ds* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %82
12: ; preds = %1
%13 = call i8* @gettext(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* %13, i32 %14)
%16 = call i8* @gettext(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%17 = load %struct.ipc_perm*, %struct.ipc_perm** %4
%18 = getelementptr inbounds %struct.ipc_perm, %struct.ipc_perm* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load %struct.ipc_perm*, %struct.ipc_perm** %4
%21 = getelementptr inbounds %struct.ipc_perm, %struct.ipc_perm* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load %struct.ipc_perm*, %struct.ipc_perm** %4
%24 = getelementptr inbounds %struct.ipc_perm, %struct.ipc_perm* %23, i32 0, i32 2
%25 = load i32, i32* %24
%26 = load %struct.ipc_perm*, %struct.ipc_perm** %4
%27 = getelementptr inbounds %struct.ipc_perm, %struct.ipc_perm* %26, i32 0, i32 3
%28 = load i32, i32* %27
%29 = load %struct.ipc_perm*, %struct.ipc_perm** %4
%30 = getelementptr inbounds %struct.ipc_perm, %struct.ipc_perm* %29, i32 0, i32 4
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* %16, i32 %19, i32 %22, i32 %25, i32 %28, i32 %31)
%33 = call i8* @gettext(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%34 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 7
%35 = load i64, i64* %34
%36 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 6
%37 = load i64, i64* %36
%38 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 5
%39 = load i64, i64* %38
%40 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 4
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 3
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* %33, i64 %35, i64 %37, i64 %39, i32 %41, i32 %43)
%45 = call i8* @gettext(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%46 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 2
%47 = load i64, i64* %46
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %12
%50 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 2
%51 = call i8* @ctime(i64* %50)
br label %54
52: ; preds = %12
%53 = call i8* @gettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = phi i8* [ %51, %49 ], [ %53, %52 ]
%56 = call i32 (i8*, ...) @printf(i8* %45, i8* %55)
%57 = call i8* @gettext(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%58 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 1
%59 = load i64, i64* %58
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %54
%62 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 1
%63 = call i8* @ctime(i64* %62)
br label %66
64: ; preds = %54
%65 = call i8* @gettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %61
%67 = phi i8* [ %63, %61 ], [ %65, %64 ]
%68 = call i32 (i8*, ...) @printf(i8* %57, i8* %67)
%69 = call i8* @gettext(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%70 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 0
%71 = load i64, i64* %70
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 0
%75 = call i8* @ctime(i64* %74)
br label %78
76: ; preds = %66
%77 = call i8* @gettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %78
78: ; preds = %76, %73
%79 = phi i8* [ %75, %73 ], [ %77, %76 ]
%80 = call i32 (i8*, ...) @printf(i8* %69, i8* %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %82
82: ; preds = %78, %10
ret void
}

LLVM IR (-O2):
%struct.msqid_ds = type { i64, i64, i64, i32, i32, i64, i64, i64, %struct.ipc_perm }
%struct.ipc_perm = type { i32, i32, i32, i32, i32 }
@IPC_STAT = global i32 0
@.str = [8 x i8] c"msgctl \00"
@.str.1 = [25 x i8] c"\0AMessage Queue msqid=%d\0A\00"
@.str.2 = [40 x i8] c"uid=%d\09gid=%d\09cuid=%d\09cgid=%d\09mode=%#o\0A\00"
@.str.3 = [50 x i8] c"cbytes=%ld\09qbytes=%ld\09qnum=%ld\09lspid=%d\09lrpid=%d\0A\00"
@.str.4 = [20 x i8] c"send_time=%-26.24s\0A\00"
@.str.5 = [8 x i8] c"Not set\00"
@.str.6 = [19 x i8] c"rcv_time=%-26.24s\0A\00"
@.str.7 = [22 x i8] c"change_time=%-26.24s\0A\00"
define void @print_msg(i32 %0) {
%2 = alloca %struct.msqid_ds
%3 = bitcast %struct.msqid_ds* %2 to i8*
%4 = load i32, i32* @IPC_STAT
%5 = call i32 @msgctl(i32 %0, i32 %4, %struct.msqid_ds* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %70
9: ; preds = %1
%10 = call i8* @gettext(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10, i32 %0)
%12 = call i8* @gettext(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 8, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 8, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 8, i32 2
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 8, i32 3
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 8, i32 4
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %12, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22)
%24 = call i8* @gettext(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%25 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 7
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 6
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 5
%30 = load i64, i64* %29
%31 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 4
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 3
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, i64 %26, i64 %28, i64 %30, i32 %32, i32 %34)
%36 = call i8* @gettext(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%37 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 2
%38 = load i64, i64* %37
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %9
%41 = call i8* @ctime(i64* %37)
br label %44
42: ; preds = %9
%43 = call i8* @gettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
%45 = phi i8* [ %41, %40 ], [ %43, %42 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %36, i8* %45)
%47 = call i8* @gettext(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%48 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 1
%49 = load i64, i64* %48
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %44
%52 = call i8* @ctime(i64* %48)
br label %55
53: ; preds = %44
%54 = call i8* @gettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
%56 = phi i8* [ %52, %51 ], [ %54, %53 ]
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %47, i8* %56)
%58 = call i8* @gettext(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%59 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %2, i64 0, i32 0
%60 = load i64, i64* %59
%61 = icmp eq i64 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %55
%63 = call i8* @ctime(i64* %59)
br label %66
64: ; preds = %55
%65 = call i8* @gettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %62
%67 = phi i8* [ %63, %62 ], [ %65, %64 ]
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %58, i8* %67)
%69 = call i32 @putchar(i32 10)
br label %70
70: ; preds = %66, %7
ret void
}