#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 uid;
  int gid;
  int mode;
};
struct msqid_ds {
  int msg_cbytes;
  int msg_qnum;
  int msg_qbytes;
  TYPE_1__ msg_perm;
};

/* Variables and functions */
int /*<<< orphan*/ IPC_RMID;
int /*<<< orphan*/ IPC_SET;
int /*<<< orphan*/ IPC_STAT;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int msgctl(int, int /*<<< orphan*/, struct msqid_ds *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int uid, gid, mode, bytes;
  int rtrn, msqid, command, choice;
  struct msqid_ds msqid_ds, *buf;
  buf = &msqid_ds;
  printf("Enter the msqid: ");
  scanf("%i", &msqid);
  printf("\n1 = IPC_STAT\n2 = IPC_SET\n3 = IPC_RMID\n");
  printf("Enter command number: ");
  scanf("%i", &command);
  printf("\n\nmsqid = %d, command = %d\n", msqid, command);
  switch (command) {
  case 1:
    rtrn = msgctl(msqid, IPC_STAT, buf);
    if (rtrn != -1) {
      printf("User %d, group %d, perms 0%o\n", buf->msg_perm.uid,
             buf->msg_perm.gid, buf->msg_perm.mode);
      printf("cbytes: %d, qnum: %d, qbytes %d\n", buf->msg_cbytes,
             buf->msg_qnum, buf->msg_qbytes);
    }
    break;
  case 2:
    rtrn = msgctl(msqid, IPC_STAT, buf);
    if (rtrn == -1)
      break;
    printf("\n1 = uid, 2 = gid, 3 = mode, 4 = qbytes\n");
    printf("Number of field to change: ");
    scanf("%i", &choice);
    switch (choice) {
    case 1:
      printf("\nUser id: ");
      scanf("%i", &uid);
      buf->msg_perm.uid = uid;
      printf("User = %d\n", buf->msg_perm.uid);
      break;
    case 2:
      printf("\nGroup id: ");
      scanf("%i", &gid);
      buf->msg_perm.gid = gid;
      printf("Group = %d\n", buf->msg_perm.gid);
      break;
    case 3:
      printf("\nMode: ");
      scanf("%i", &mode);
      buf->msg_perm.mode = mode;
      printf("Mode = 0%o\n", buf->msg_perm.mode);
      break;
    case 4:
      printf("\nQbytes: ");
      scanf("%i", &bytes);
      buf->msg_qbytes = bytes;
      printf("Qbytes = %d\n", buf->msg_qbytes);
      break;
    }
    rtrn = msgctl(msqid, IPC_SET, buf);
    break;
  case 3:
    rtrn = msgctl(msqid, IPC_RMID, NULL);
    break;
  }
  if (rtrn == -1)
    perror("msgctl");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xea2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x4d(%rbp)
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
mov    %rdi,-0x58(%rbp)
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4d(%rbp),%al
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4d(%rbp),%al
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x58(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4d(%rbp),%al
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x1,%eax
je     1202 <main+0xb2>
jmp    11e0 <main+0x90>
mov    -0x4c(%rbp),%eax
sub    $0x2,%eax
je     126e <main+0x11e>
jmp    11f1 <main+0xa1>
mov    -0x4c(%rbp),%eax
sub    $0x3,%eax
je     140e <main+0x2be>
jmp    1426 <main+0x2d6>
mov    -0x1c(%rbp),%edi
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rdx
call   1040 <msgctl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     1269 <main+0x119>
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%ecx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1426 <main+0x2d6>
mov    -0x1c(%rbp),%edi
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rdx
call   1040 <msgctl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1295 <main+0x145>
jmp    1426 <main+0x2d6>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x61(%rbp)
call   1030 <printf@plt>
mov    -0x61(%rbp),%al
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
lea    0xd66(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x3,%eax
ja     13f1 <main+0x2a1>
mov    -0x60(%rbp),%rax
lea    0xd1b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd1f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13f1 <main+0x2a1>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcdd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13f1 <main+0x2a1>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc9b(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13f1 <main+0x2a1>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc59(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    0x2bed(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rdx
call   1040 <msgctl@plt>
mov    %eax,-0x18(%rbp)
jmp    1426 <main+0x2d6>
mov    -0x1c(%rbp),%edi
mov    0x2bb8(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <msgctl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    143c <main+0x2ec>
lea    0xd26(%rip),%rdi
call   1060 <perror@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xf85(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     1236 <main+0xd6>
cmp    $0x2,%eax
je     124a <main+0xea>
cmp    $0x1,%eax
jne    1399 <main+0x239>
mov    0x8(%rsp),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
je     1399 <main+0x239>
mov    0x1c(%rsp),%esi
mov    0x20(%rsp),%edx
mov    0x24(%rsp),%ecx
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%ecx
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x8(%rsp),%edi
mov    0x2d8f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
jmp    138f <main+0x22f>
mov    0x8(%rsp),%edi
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
je     1399 <main+0x239>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd97(%rip),%rdi
lea    0x2c(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2c(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     137d <main+0x21d>
lea    0xd54(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd58(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %esi,0x1c(%rsp)
lea    0xddb(%rip),%rdi
jmp    1376 <main+0x216>
lea    0xdda(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd25(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %esi,0x20(%rsp)
lea    0xdbf(%rip),%rdi
jmp    1376 <main+0x216>
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcf5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %esi,0x24(%rsp)
lea    0xda3(%rip),%rdi
jmp    1376 <main+0x216>
lea    0xda6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcc5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %esi,0x18(%rsp)
lea    0xd89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
jne    13a5 <main+0x245>
lea    0xd6c(%rip),%rdi
call   1070 <perror@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.msqid_ds = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32, i32 }
@.str = [18 x i8] c"Enter the msqid: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [40 x i8] c"\0A1 = IPC_STAT\0A2 = IPC_SET\0A3 = IPC_RMID\0A\00"
@.str.3 = [23 x i8] c"Enter command number: \00"
@.str.4 = [28 x i8] c"\0A\0Amsqid = %d, command = %d\0A\00"
@IPC_STAT = global i32 0
@.str.5 = [30 x i8] c"User %d, group %d, perms 0%o\0A\00"
@.str.6 = [33 x i8] c"cbytes: %d, qnum: %d, qbytes %d\0A\00"
@.str.7 = [41 x i8] c"\0A1 = uid, 2 = gid, 3 = mode, 4 = qbytes\0A\00"
@.str.8 = [28 x i8] c"Number of field to change: \00"
@.str.9 = [11 x i8] c"\0AUser id: \00"
@.str.10 = [11 x i8] c"User = %d\0A\00"
@.str.11 = [12 x i8] c"\0AGroup id: \00"
@.str.12 = [12 x i8] c"Group = %d\0A\00"
@.str.13 = [8 x i8] c"\0AMode: \00"
@.str.14 = [12 x i8] c"Mode = 0%o\0A\00"
@.str.15 = [10 x i8] c"\0AQbytes: \00"
@.str.16 = [13 x i8] c"Qbytes = %d\0A\00"
@IPC_SET = global i32 0
@IPC_RMID = global i32 0
@.str.17 = [7 x i8] c"msgctl\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.msqid_ds
%11 = alloca %struct.msqid_ds*
store i32 0, i32* %1
store %struct.msqid_ds* %10, %struct.msqid_ds** %11
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %8
switch i32 %20, label %121 [
i32 1, label %21
i32 2, label %53
i32 3, label %117
]
21: ; preds = %0
%22 = load i32, i32* %7
%23 = load i32, i32* @IPC_STAT
%24 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%25 = call i32 @msgctl(i32 %22, i32 %23, %struct.msqid_ds* %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %52
28: ; preds = %21
%29 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%30 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %29, i32 0, i32 3
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%34 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %33, i32 0, i32 3
%35 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%38 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %37, i32 0, i32 3
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 2
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %32, i32 %36, i32 %40)
%42 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%43 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%46 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %45, i32 0, i32 1
%47 = load i32, i32* %46
%48 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%49 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %48, i32 0, i32 2
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %47, i32 %50)
br label %52
52: ; preds = %28, %21
br label %121
53: ; preds = %0
%54 = load i32, i32* %7
%55 = load i32, i32* @IPC_STAT
%56 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%57 = call i32 @msgctl(i32 %54, i32 %55, %struct.msqid_ds* %56)
store i32 %57, i32* %6
%58 = load i32, i32* %6
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %61
60: ; preds = %53
br label %121
61: ; preds = %53
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%65 = load i32, i32* %9
switch i32 %65, label %112 [
i32 1, label %66
i32 2, label %78
i32 3, label %90
i32 4, label %102
]
66: ; preds = %61
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%68 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%69 = load i32, i32* %2
%70 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%71 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %70, i32 0, i32 3
%72 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %71, i32 0, i32 0
store i32 %69, i32* %72
%73 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%74 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %73, i32 0, i32 3
%75 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %74, i32 0, i32 0
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %76)
br label %112
78: ; preds = %61
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%80 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%81 = load i32, i32* %3
%82 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%83 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %82, i32 0, i32 3
%84 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %83, i32 0, i32 1
store i32 %81, i32* %84
%85 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%86 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %85, i32 0, i32 3
%87 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %86, i32 0, i32 1
%88 = load i32, i32* %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %88)
br label %112
90: ; preds = %61
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%92 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%93 = load i32, i32* %4
%94 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%95 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %94, i32 0, i32 3
%96 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %95, i32 0, i32 2
store i32 %93, i32* %96
%97 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%98 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %97, i32 0, i32 3
%99 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %98, i32 0, i32 2
%100 = load i32, i32* %99
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i32 %100)
br label %112
102: ; preds = %61
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%104 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%105 = load i32, i32* %5
%106 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%107 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %106, i32 0, i32 2
store i32 %105, i32* %107
%108 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%109 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %108, i32 0, i32 2
%110 = load i32, i32* %109
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 %110)
br label %112
112: ; preds = %61, %102, %90, %78, %66
%113 = load i32, i32* %7
%114 = load i32, i32* @IPC_SET
%115 = load %struct.msqid_ds*, %struct.msqid_ds** %11
%116 = call i32 @msgctl(i32 %113, i32 %114, %struct.msqid_ds* %115)
store i32 %116, i32* %6
br label %121
117: ; preds = %0
%118 = load i32, i32* %7
%119 = load i32, i32* @IPC_RMID
%120 = call i32 @msgctl(i32 %118, i32 %119, %struct.msqid_ds* null)
store i32 %120, i32* %6
br label %121
121: ; preds = %0, %117, %112, %60, %52
%122 = load i32, i32* %6
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %126
124: ; preds = %121
%125 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0))
br label %126
126: ; preds = %124, %121
%127 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.msqid_ds = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32, i32 }
@.str = [18 x i8] c"Enter the msqid: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.3 = [23 x i8] c"Enter command number: \00"
@.str.4 = [28 x i8] c"\0A\0Amsqid = %d, command = %d\0A\00"
@IPC_STAT = global i32 0
@.str.5 = [30 x i8] c"User %d, group %d, perms 0%o\0A\00"
@.str.6 = [33 x i8] c"cbytes: %d, qnum: %d, qbytes %d\0A\00"
@.str.8 = [28 x i8] c"Number of field to change: \00"
@.str.9 = [11 x i8] c"\0AUser id: \00"
@.str.10 = [11 x i8] c"User = %d\0A\00"
@.str.11 = [12 x i8] c"\0AGroup id: \00"
@.str.12 = [12 x i8] c"Group = %d\0A\00"
@.str.13 = [8 x i8] c"\0AMode: \00"
@.str.14 = [12 x i8] c"Mode = 0%o\0A\00"
@.str.15 = [10 x i8] c"\0AQbytes: \00"
@.str.16 = [13 x i8] c"Qbytes = %d\0A\00"
@IPC_SET = global i32 0
@IPC_RMID = global i32 0
@.str.17 = [7 x i8] c"msgctl\00"
@str = [39 x i8] c"\0A1 = IPC_STAT\0A2 = IPC_SET\0A3 = IPC_RMID\00"
@str.18 = [40 x i8] c"\0A1 = uid, 2 = gid, 3 = mode, 4 = qbytes\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.msqid_ds
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast %struct.msqid_ds* %8 to i8*
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* %6
switch i32 %25, label %91 [
i32 1, label %26
i32 2, label %46
i32 3, label %84
]
26: ; preds = %0
%27 = load i32, i32* %5
%28 = load i32, i32* @IPC_STAT
%29 = call i32 @msgctl(i32 %27, i32 %28, %struct.msqid_ds* %8)
%30 = icmp eq i32 %29, -1
br i1 %30, label %91, label %31
31: ; preds = %26
%32 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 3, i32 0
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 3, i32 1
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 3, i32 2
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %35, i32 %37)
%39 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 0
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 1
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 2
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %40, i32 %42, i32 %44)
br label %93
46: ; preds = %0
%47 = load i32, i32* %5
%48 = load i32, i32* @IPC_STAT
%49 = call i32 @msgctl(i32 %47, i32 %48, %struct.msqid_ds* %8)
%50 = icmp eq i32 %49, -1
br i1 %50, label %91, label %51
51: ; preds = %46
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.18, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%54 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%55 = load i32, i32* %7
switch i32 %55, label %80 [
i32 1, label %56
i32 2, label %62
i32 3, label %68
i32 4, label %74
]
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%58 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%59 = load i32, i32* %1
%60 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 3, i32 0
store i32 %59, i32* %60
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %59)
br label %80
62: ; preds = %51
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%65 = load i32, i32* %2
%66 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 3, i32 1
store i32 %65, i32* %66
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %65)
br label %80
68: ; preds = %51
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%70 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%71 = load i32, i32* %3
%72 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 3, i32 2
store i32 %71, i32* %72
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i32 %71)
br label %80
74: ; preds = %51
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%77 = load i32, i32* %4
%78 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %8, i64 0, i32 2
store i32 %77, i32* %78
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 %77)
br label %80
80: ; preds = %51, %74, %68, %62, %56
%81 = load i32, i32* %5
%82 = load i32, i32* @IPC_SET
%83 = call i32 @msgctl(i32 %81, i32 %82, %struct.msqid_ds* %8)
br label %88
84: ; preds = %0
%85 = load i32, i32* %5
%86 = load i32, i32* @IPC_RMID
%87 = call i32 @msgctl(i32 %85, i32 %86, %struct.msqid_ds* null)
br label %88
88: ; preds = %84, %80
%89 = phi i32 [ %87, %84 ], [ %83, %80 ]
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %93
91: ; preds = %26, %46, %0, %88
%92 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0))
br label %93
93: ; preds = %31, %91, %88
%94 = call i32 @exit(i32 0)
unreachable
}