#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 */
typedef int key_t;

/* Variables and functions */
int IPC_CREAT;
int /*<<< orphan*/ IPC_RMID;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int *shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ shmctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ shmdt(int *);
int shmget(int, int, int);
int /*<<< orphan*/ strcmp(char *, char *);
void main() {
  key_t key = 1234;
  int *value;
  int shmid = shmget(key, 3 * sizeof(int), IPC_CREAT | 0666);
  value = shmat(shmid, NULL, 0);
  int pilihan;
  int status = 1;
  const char *senjata[6] = {"MP4A1",  "PM2-V1",  "SPR-3",
                            "SS2-V5", "SPG1-V3", "MINE"};
  char masuk[8];
  int stock;
  printf("1. Lihat Stok Senjata\n");
  printf("2. Tambah Stok Senjata\n");
  printf("Masukka syntax: ");
  while (status) {
    scanf("%d", &pilihan);
    if (pilihan == 1) {
      for (int i = 0; i < 6; i++) {
        printf("%s %d\n", senjata[i], value[i]);
      }
    } else if (pilihan == 2) {
      scanf("%s %d", masuk, &stock);
      if (!strcmp(masuk, "MP4A1"))
        value[0] += stock;
      else if (!strcmp(masuk, "PM2-V1"))
        value[1] += stock;
      else if (!strcmp(masuk, "SPR-3"))
        value[2] += stock;
      else if (!strcmp(masuk, "SS2-V5"))
        value[3] += stock;
      else if (!strcmp(masuk, "SPG1-V3"))
        value[4] += stock;
      else if (!strcmp(masuk, "MINE"))
        value[5] += stock;
      else
        printf("Unavailable");
    } else {
      status = 0;
    }
    printf("1. Lihat Stok Senjata\n");
    printf("2. Tambah Stok Senjata\n");
    printf("Masukka syntax: ");
  }
  shmdt(value);
  shmctl(shmid, IPC_RMID, NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x4d2,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
or     $0x1b6,%edx
mov    $0xc,%esi
call   10a0 <shmget@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <shmat@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
lea    0xe22(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe1d(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe19(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe14(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe10(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe0d(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1436 <main+0x2b6>
lea    0xe1d(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    12af <main+0x12f>
movl   $0x0,-0x60(%rbp)
cmpl   $0x6,-0x60(%rbp)
jge    12aa <main+0x12a>
movslq -0x60(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
mov    -0x10(%rbp),%rax
movslq -0x60(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1270 <main+0xf0>
jmp    1407 <main+0x287>
cmpl   $0x2,-0x18(%rbp)
jne    13fb <main+0x27b>
lea    -0x58(%rbp),%rsi
lea    0xdaa(%rip),%rdi
lea    -0x5c(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x58(%rbp),%rdi
lea    0xd26(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12f8 <main+0x178>
mov    -0x5c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
jmp    13f6 <main+0x276>
lea    -0x58(%rbp),%rdi
lea    0xd03(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1323 <main+0x1a3>
mov    -0x5c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
jmp    13f1 <main+0x271>
lea    -0x58(%rbp),%rdi
lea    0xcdf(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    134e <main+0x1ce>
mov    -0x5c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
jmp    13ec <main+0x26c>
lea    -0x58(%rbp),%rdi
lea    0xcba(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1379 <main+0x1f9>
mov    -0x5c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
jmp    13e7 <main+0x267>
lea    -0x58(%rbp),%rdi
lea    0xc96(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13a4 <main+0x224>
mov    -0x5c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0x10(%rax),%ecx
mov    %ecx,0x10(%rax)
jmp    13e2 <main+0x262>
lea    -0x58(%rbp),%rdi
lea    0xc73(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13cf <main+0x24f>
mov    -0x5c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0x14(%rax),%ecx
mov    %ecx,0x14(%rax)
jmp    13dd <main+0x25d>
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e2 <main+0x262>
jmp    13e7 <main+0x267>
jmp    13ec <main+0x26c>
jmp    13f1 <main+0x271>
jmp    13f6 <main+0x276>
jmp    1402 <main+0x282>
movl   $0x0,-0x1c(%rbp)
jmp    1407 <main+0x287>
lea    0xc19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1243 <main+0xc3>
mov    -0x10(%rbp),%rdi
call   1030 <shmdt@plt>
mov    -0x14(%rbp),%edi
mov    0x2b97(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <shmctl@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e53(%rip),%rax
mov    $0x1b6,%edx
or     (%rax),%edx
mov    $0x4d2,%edi
mov    $0xc,%esi
call   1090 <shmget@plt>
mov    %eax,0x10(%rsp)
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <shmat@plt>
mov    %rax,%rbx
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xea7(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
lea    0xe58(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe62(%rip),%rbp
lea    0x14(%rsp),%r14
lea    0xe4c(%rip),%r15
jmp    121e <main+0xae>
mov    0x4(%rsp),%eax
add    %eax,(%rbx)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     12c0 <main+0x150>
cmp    $0x1,%eax
jne    13b2 <main+0x242>
mov    (%rbx),%edx
mov    %r15,%rdi
lea    0xdb3(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%edx
mov    %r15,%rdi
lea    0xda5(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%edx
mov    %r15,%rdi
lea    0xd98(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%edx
mov    %r15,%rdi
lea    0xd8a(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%edx
mov    %r15,%rdi
lea    0xd7d(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%edx
mov    %r15,%rdi
lea    0xd71(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <main+0x90>
nopl   (%rax)
lea    0xd78(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
mov    $0x4134504d,%ecx
xor    %ecx,%eax
movzwl 0xc(%rsp),%ecx
xor    $0x31,%ecx
or     %eax,%ecx
je     11ee <main+0x7e>
mov    0x8(%rsp),%eax
mov    $0x2d324d50,%ecx
xor    %ecx,%eax
mov    0xb(%rsp),%ecx
mov    $0x31562d,%edx
xor    %edx,%ecx
or     %eax,%ecx
je     1376 <main+0x206>
mov    0x8(%rsp),%eax
mov    $0x2d525053,%ecx
xor    %ecx,%eax
movzwl 0xc(%rsp),%ecx
xor    $0x33,%ecx
or     %eax,%ecx
je     1382 <main+0x212>
mov    0x8(%rsp),%eax
mov    $0x2d325353,%ecx
xor    %ecx,%eax
mov    0xb(%rsp),%ecx
mov    $0x35562d,%edx
xor    %edx,%ecx
or     %eax,%ecx
je     138e <main+0x21e>
movabs $0x33562d31475053,%rax
cmp    %rax,0x8(%rsp)
je     139a <main+0x22a>
mov    0x8(%rsp),%eax
mov    $0x454e494d,%ecx
xor    %ecx,%eax
movzbl 0xc(%rsp),%ecx
or     %eax,%ecx
je     13a6 <main+0x236>
lea    0xcdb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <main+0x90>
mov    0x4(%rsp),%eax
add    %eax,0x4(%rbx)
jmp    1200 <main+0x90>
mov    0x4(%rsp),%eax
add    %eax,0x8(%rbx)
jmp    1200 <main+0x90>
mov    0x4(%rsp),%eax
add    %eax,0xc(%rbx)
jmp    1200 <main+0x90>
mov    0x4(%rsp),%eax
add    %eax,0x10(%rbx)
jmp    1200 <main+0x90>
mov    0x4(%rsp),%eax
add    %eax,0x14(%rbx)
jmp    1200 <main+0x90>
lea    0xc98(%rip),%rdi
call   1030 <puts@plt>
lea    0xca2(%rip),%rdi
call   1030 <puts@plt>
lea    0xc56(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <shmdt@plt>
mov    0x2bf9(%rip),%rax
mov    (%rax),%esi
mov    0x10(%rsp),%edi
xor    %edx,%edx
call   1070 <shmctl@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@.str = [6 x i8] c"MP4A1\00"
@.str.1 = [7 x i8] c"PM2-V1\00"
@.str.2 = [6 x i8] c"SPR-3\00"
@.str.3 = [7 x i8] c"SS2-V5\00"
@.str.4 = [8 x i8] c"SPG1-V3\00"
@.str.5 = [5 x i8] c"MINE\00"
@.str.6 = [23 x i8] c"1. Lihat Stok Senjata\0A\00"
@.str.7 = [24 x i8] c"2. Tambah Stok Senjata\0A\00"
@.str.8 = [17 x i8] c"Masukka syntax: \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [7 x i8] c"%s %d\0A\00"
@.str.11 = [6 x i8] c"%s %d\00"
@.str.12 = [12 x i8] c"Unavailable\00"
@IPC_RMID = global i32 0
define void @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [6 x i8*]
%7 = alloca [8 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 1234, i32* %1
%10 = load i32, i32* %1
%11 = load i32, i32* @IPC_CREAT
%12 = or i32 %11, 438
%13 = call i32 @shmget(i32 %10, i32 12, i32 %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = call i32* @shmat(i32 %14, i32* null, i32 0)
store i32* %15, i32** %2
store i32 1, i32* %5
%16 = bitcast [6 x i8*]* %6 to i8*
%17 = bitcast i8* %16 to [6 x i8*]*
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8** %23
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %27
27: ; preds = %128, %0
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %132
30: ; preds = %27
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %4)
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %53
34: ; preds = %30
store i32 0, i32* %9
br label %35
35: ; preds = %49, %34
%36 = load i32, i32* %9
%37 = icmp slt i32 %36, 6
br i1 %37, label %38, label %52
38: ; preds = %35
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = load i32*, i32** %2
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %42, i32 %47)
br label %49
49: ; preds = %38
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %35
52: ; preds = %35
br label %128
53: ; preds = %30
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 2
br i1 %55, label %56, label %126
56: ; preds = %53
%57 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%58 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %57, i32* %8)
%59 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%60 = call i32 @strcmp(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %68, label %62
62: ; preds = %56
%63 = load i32, i32* %8
%64 = load i32*, i32** %2
%65 = getelementptr inbounds i32, i32* %64, i64 0
%66 = load i32, i32* %65
%67 = add nsw i32 %66, %63
store i32 %67, i32* %65
br label %125
68: ; preds = %56
%69 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%70 = call i32 @strcmp(i8* %69, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%71 = icmp ne i32 %70, 0
br i1 %71, label %78, label %72
72: ; preds = %68
%73 = load i32, i32* %8
%74 = load i32*, i32** %2
%75 = getelementptr inbounds i32, i32* %74, i64 1
%76 = load i32, i32* %75
%77 = add nsw i32 %76, %73
store i32 %77, i32* %75
br label %124
78: ; preds = %68
%79 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %88, label %82
82: ; preds = %78
%83 = load i32, i32* %8
%84 = load i32*, i32** %2
%85 = getelementptr inbounds i32, i32* %84, i64 2
%86 = load i32, i32* %85
%87 = add nsw i32 %86, %83
store i32 %87, i32* %85
br label %123
88: ; preds = %78
%89 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%90 = call i32 @strcmp(i8* %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%91 = icmp ne i32 %90, 0
br i1 %91, label %98, label %92
92: ; preds = %88
%93 = load i32, i32* %8
%94 = load i32*, i32** %2
%95 = getelementptr inbounds i32, i32* %94, i64 3
%96 = load i32, i32* %95
%97 = add nsw i32 %96, %93
store i32 %97, i32* %95
br label %122
98: ; preds = %88
%99 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%100 = call i32 @strcmp(i8* %99, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%101 = icmp ne i32 %100, 0
br i1 %101, label %108, label %102
102: ; preds = %98
%103 = load i32, i32* %8
%104 = load i32*, i32** %2
%105 = getelementptr inbounds i32, i32* %104, i64 4
%106 = load i32, i32* %105
%107 = add nsw i32 %106, %103
store i32 %107, i32* %105
br label %121
108: ; preds = %98
%109 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%110 = call i32 @strcmp(i8* %109, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%111 = icmp ne i32 %110, 0
br i1 %111, label %118, label %112
112: ; preds = %108
%113 = load i32, i32* %8
%114 = load i32*, i32** %2
%115 = getelementptr inbounds i32, i32* %114, i64 5
%116 = load i32, i32* %115
%117 = add nsw i32 %116, %113
store i32 %117, i32* %115
br label %120
118: ; preds = %108
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %120
120: ; preds = %118, %112
br label %121
121: ; preds = %120, %102
br label %122
122: ; preds = %121, %92
br label %123
123: ; preds = %122, %82
br label %124
124: ; preds = %123, %72
br label %125
125: ; preds = %124, %62
br label %127
126: ; preds = %53
store i32 0, i32* %5
br label %127
127: ; preds = %126, %125
br label %128
128: ; preds = %127, %52
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %27
132: ; preds = %27
%133 = load i32*, i32** %2
%134 = call i32 @shmdt(i32* %133)
%135 = load i32, i32* %3
%136 = load i32, i32* @IPC_RMID
%137 = call i32 @shmctl(i32 %135, i32 %136, i32* null)
ret void
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@.str = [6 x i8] c"MP4A1\00"
@.str.1 = [7 x i8] c"PM2-V1\00"
@.str.2 = [6 x i8] c"SPR-3\00"
@.str.3 = [7 x i8] c"SS2-V5\00"
@.str.4 = [8 x i8] c"SPG1-V3\00"
@.str.5 = [5 x i8] c"MINE\00"
@.str.8 = [17 x i8] c"Masukka syntax: \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [7 x i8] c"%s %d\0A\00"
@.str.11 = [6 x i8] c"%s %d\00"
@.str.12 = [12 x i8] c"Unavailable\00"
@IPC_RMID = global i32 0
@str.14 = [22 x i8] c"1. Lihat Stok Senjata\00"
@str.15 = [23 x i8] c"2. Tambah Stok Senjata\00"
define void @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i32
%4 = load i32, i32* @IPC_CREAT
%5 = or i32 %4, 438
%6 = tail call i32 @shmget(i32 1234, i32 12, i32 %5)
%7 = tail call i32* @shmat(i32 %6, i32* null, i32 0)
%8 = bitcast i32* %1 to i8*
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%10 = bitcast i32* %3 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%14 = getelementptr inbounds i32, i32* %7, i64 5
%15 = getelementptr inbounds i32, i32* %7, i64 4
%16 = getelementptr inbounds i32, i32* %7, i64 3
%17 = getelementptr inbounds i32, i32* %7, i64 2
%18 = getelementptr inbounds i32, i32* %7, i64 1
br label %19
19: ; preds = %80, %0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
switch i32 %21, label %84 [
i32 1, label %22
i32 2, label %35
]
22: ; preds = %19
%23 = load i32, i32* %7
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %18
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %17
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %16
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %15
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %14
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %80
35: ; preds = %19
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %9, i32* %3)
%37 = call i32 @bcmp(i8* dereferenceable(6) %9, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 6)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* %3
%41 = load i32, i32* %7
%42 = add nsw i32 %41, %40
store i32 %42, i32* %7
br label %80
43: ; preds = %35
%44 = call i32 @bcmp(i8* dereferenceable(7) %9, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 7)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i32, i32* %3
%48 = load i32, i32* %18
%49 = add nsw i32 %48, %47
store i32 %49, i32* %18
br label %80
50: ; preds = %43
%51 = call i32 @bcmp(i8* dereferenceable(6) %9, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 6)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* %3
%55 = load i32, i32* %17
%56 = add nsw i32 %55, %54
store i32 %56, i32* %17
br label %80
57: ; preds = %50
%58 = call i32 @bcmp(i8* dereferenceable(7) %9, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 7)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = load i32, i32* %3
%62 = load i32, i32* %16
%63 = add nsw i32 %62, %61
store i32 %63, i32* %16
br label %80
64: ; preds = %57
%65 = call i32 @bcmp(i8* dereferenceable(8) %9, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 8)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load i32, i32* %3
%69 = load i32, i32* %15
%70 = add nsw i32 %69, %68
store i32 %70, i32* %15
br label %80
71: ; preds = %64
%72 = call i32 @bcmp(i8* dereferenceable(5) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 5)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = load i32, i32* %3
%76 = load i32, i32* %14
%77 = add nsw i32 %76, %75
store i32 %77, i32* %14
br label %80
78: ; preds = %71
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %80
80: ; preds = %22, %46, %60, %74, %78, %67, %53, %39
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0))
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %19
84: ; preds = %19
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0))
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%88 = call i32 @shmdt(i32* %7)
%89 = load i32, i32* @IPC_RMID
%90 = call i32 @shmctl(i32 %6, i32 %89, i32* null)
ret void
}