#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ mode;
};
struct msqid_ds {
  TYPE_1__ msg_perm;
};

/* Variables and functions */
int /*<<< orphan*/ IPC_SET;
int /*<<< orphan*/ IPC_STAT;
int /*<<< orphan*/ msgctl(int, int /*<<< orphan*/, struct msqid_ds *);
int /*<<< orphan*/ sscanf(char *, char *, int /*<<< orphan*/ *);
void change_queue_mode(int qid, char *mode) {
  struct msqid_ds myqueue_ds;
  msgctl(qid, IPC_STAT, &myqueue_ds);
  sscanf(mode, "%ho", &myqueue_ds.msg_perm.mode);
  msgctl(qid, IPC_SET, &myqueue_ds);
}


x86 assembly (clang, -O0):
<change_queue_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e9f(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <msgctl@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rdx
lea    0xead(%rip),%rsi
call   1030 <sscanf@plt>
mov    -0x4(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <msgctl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_queue_mode>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%r14
mov    %r14,%rdx
call   1040 <msgctl@plt>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <sscanf@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1040 <msgctl@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.msqid_ds = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@IPC_STAT = global i32 0
@.str = [4 x i8] c"%ho\00"
@IPC_SET = global i32 0
define void @change_queue_mode(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.msqid_ds
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = load i32, i32* @IPC_STAT
%8 = call i32 @msgctl(i32 %6, i32 %7, %struct.msqid_ds* %5)
%9 = load i8*, i8** %4
%10 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %5, i32 0, i32 0
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
%12 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = load i32, i32* %3
%14 = load i32, i32* @IPC_SET
%15 = call i32 @msgctl(i32 %13, i32 %14, %struct.msqid_ds* %5)
ret void
}

LLVM IR (-O2):
%struct.msqid_ds = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@IPC_STAT = global i32 0
@.str = [4 x i8] c"%ho\00"
@IPC_SET = global i32 0
define void @change_queue_mode(i32 %0, i8* nocapture %1) {
%3 = alloca %struct.msqid_ds
%4 = bitcast %struct.msqid_ds* %3 to i8*
%5 = load i32, i32* @IPC_STAT
%6 = call i32 @msgctl(i32 %0, i32 %5, %struct.msqid_ds* %3)
%7 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i64 0, i32 0, i32 0
%8 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = load i32, i32* @IPC_SET
%10 = call i32 @msgctl(i32 %0, i32 %9, %struct.msqid_ds* %3)
ret void
}