#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 msqid_ds {
  int msg_qbytes;
};

/* Variables and functions */
int IPC_CREAT;
int /*<<< orphan*/ IPC_SET;
int /*<<< orphan*/ IPC_STAT;
int /*<<< orphan*/ msgctl(int, int /*<<< orphan*/, struct msqid_ds *);
int msgget(int, int);
int init_newtracelogmsq() {
  int msqid;
  struct msqid_ds buf;
  msqid = msgget(3333, IPC_CREAT | 0664);
  if (msqid < 0)
    return -1;
  msgctl(msqid, IPC_STAT, &buf);
  buf.msg_qbytes = 50 * 1024;
  msgctl(msqid, IPC_SET, &buf);
  return msqid;
}


x86 assembly (clang, -O0):
<init_newtracelogmsq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
or     $0x1b4,%esi
mov    $0xd05,%edi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    115a <init_newtracelogmsq+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <init_newtracelogmsq+0x71>
mov    -0x8(%rbp),%edi
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <msgctl@plt>
movl   $0xc800,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <msgctl@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_newtracelogmsq>:
push   %r14
push   %rbx
push   %rax
mov    0x2ea5(%rip),%rax
mov    $0x1b4,%esi
or     (%rax),%esi
mov    $0xd05,%edi
call   1030 <msgget@plt>
test   %eax,%eax
js     1174 <init_newtracelogmsq+0x54>
mov    %eax,%ebx
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rdx
call   1040 <msgctl@plt>
movl   $0xc800,(%rsp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1040 <msgctl@plt>
jmp    1179 <init_newtracelogmsq+0x59>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.msqid_ds = type { i32 }
@IPC_CREAT = global i32 0
@IPC_STAT = global i32 0
@IPC_SET = global i32 0
define i32 @init_newtracelogmsq() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.msqid_ds
%4 = load i32, i32* @IPC_CREAT
%5 = or i32 %4, 436
%6 = call i32 @msgget(i32 3333, i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %19
10: ; preds = %0
%11 = load i32, i32* %2
%12 = load i32, i32* @IPC_STAT
%13 = call i32 @msgctl(i32 %11, i32 %12, %struct.msqid_ds* %3)
%14 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 0
store i32 51200, i32* %14
%15 = load i32, i32* %2
%16 = load i32, i32* @IPC_SET
%17 = call i32 @msgctl(i32 %15, i32 %16, %struct.msqid_ds* %3)
%18 = load i32, i32* %2
store i32 %18, i32* %1
br label %19
19: ; preds = %10, %9
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
%struct.msqid_ds = type { i32 }
@IPC_CREAT = global i32 0
@IPC_STAT = global i32 0
@IPC_SET = global i32 0
define i32 @init_newtracelogmsq() {
%1 = alloca %struct.msqid_ds
%2 = bitcast %struct.msqid_ds* %1 to i8*
%3 = load i32, i32* @IPC_CREAT
%4 = or i32 %3, 436
%5 = tail call i32 @msgget(i32 3333, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = load i32, i32* @IPC_STAT
%9 = call i32 @msgctl(i32 %5, i32 %8, %struct.msqid_ds* %1)
%10 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %1, i64 0, i32 0
store i32 51200, i32* %10
%11 = load i32, i32* @IPC_SET
%12 = call i32 @msgctl(i32 %5, i32 %11, %struct.msqid_ds* %1)
br label %13
13: ; preds = %0, %7
%14 = phi i32 [ %5, %7 ], [ -1, %0 ]
ret i32 %14
}