#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. Beli Senjata\n");
  printf("Masukkan 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")) {
        if ((value[0] - stock) < 0) {
          printf("You can't afford MP4A1\n");
        } else {
          value[0] -= stock;
        }
      } else if (!strcmp(masuk, "PM2-V1")) {
        if ((value[1] - stock) < 0) {
          printf("You can't afford PM2-V1\n");
        } else {
          value[1] -= stock;
        }
      } else if (!strcmp(masuk, "SPR-3")) {
        if ((value[2] - stock) < 0) {
          printf("You can't afford SPR-3\n");
        } else {
          value[2] -= stock;
        }
      } else if (!strcmp(masuk, "SS2-V5")) {
        if ((value[3] - stock) < 0) {
          printf("You can't afford SS2-V5\n");
        } else {
          value[3] -= stock;
        }
      } else if (!strcmp(masuk, "SPG1-V3")) {
        if ((value[4] - stock) < 0) {
          printf("You can't afford SPG1-V3\n");
        } else {
          value[4] -= stock;
        }
      } else if (!strcmp(masuk, "MINE")) {
        if ((value[5] - stock) < 0) {
          printf("You can't afford MINE\n");
        } else {
          value[5] -= stock;
        }
      } else
        printf("Unavailable");
    } else {
      status = 0;
    }
    printf("1. Lihat Stok Senjata\n");
    printf("2. Beli Senjata\n");
    printf("Masukkan 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    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1525 <main+0x3a5>
lea    0xe17(%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    0xdcc(%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    14f6 <main+0x376>
cmpl   $0x2,-0x18(%rbp)
jne    14ea <main+0x36a>
lea    -0x58(%rbp),%rsi
lea    0xda4(%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    131f <main+0x19f>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sub    -0x5c(%rbp),%eax
cmp    $0x0,%eax
jge    130d <main+0x18d>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    131a <main+0x19a>
mov    -0x5c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    14e5 <main+0x365>
lea    -0x58(%rbp),%rdi
lea    0xcdc(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1372 <main+0x1f2>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
sub    -0x5c(%rbp),%eax
cmp    $0x0,%eax
jge    135e <main+0x1de>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    136d <main+0x1ed>
mov    -0x5c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0x4(%rax)
jmp    14e0 <main+0x360>
lea    -0x58(%rbp),%rdi
lea    0xc90(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13c5 <main+0x245>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
sub    -0x5c(%rbp),%eax
cmp    $0x0,%eax
jge    13b1 <main+0x231>
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13c0 <main+0x240>
mov    -0x5c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0x8(%rax)
jmp    14db <main+0x35b>
lea    -0x58(%rbp),%rdi
lea    0xc43(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1418 <main+0x298>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
sub    -0x5c(%rbp),%eax
cmp    $0x0,%eax
jge    1404 <main+0x284>
lea    0xcbf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1413 <main+0x293>
mov    -0x5c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0xc(%rax)
jmp    14d6 <main+0x356>
lea    -0x58(%rbp),%rdi
lea    0xbf7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    146b <main+0x2eb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
sub    -0x5c(%rbp),%eax
cmp    $0x0,%eax
jge    1457 <main+0x2d7>
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1466 <main+0x2e6>
mov    -0x5c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0x10(%rax)
jmp    14d1 <main+0x351>
lea    -0x58(%rbp),%rdi
lea    0xbac(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    14be <main+0x33e>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
sub    -0x5c(%rbp),%eax
cmp    $0x0,%eax
jge    14aa <main+0x32a>
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14b9 <main+0x339>
mov    -0x5c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0x14(%rax)
jmp    14cc <main+0x34c>
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14d1 <main+0x351>
jmp    14d6 <main+0x356>
jmp    14db <main+0x35b>
jmp    14e0 <main+0x360>
jmp    14e5 <main+0x365>
jmp    14f1 <main+0x371>
movl   $0x0,-0x1c(%rbp)
jmp    14f6 <main+0x376>
lea    0xb2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb36(%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    0x2aa8(%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    0xe77(%rip),%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
lea    0xe31(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3c(%rip),%rbp
lea    0x14(%rsp),%r14
lea    0xe26(%rip),%r15
jmp    121e <main+0xae>
mov    (%rbx),%eax
sub    0x4(%rsp),%eax
js     13a0 <main+0x230>
mov    %eax,(%rbx)
nopl   0x0(%rax)
lea    0xe24(%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    1439 <main+0x2c9>
mov    (%rbx),%edx
mov    %r15,%rdi
lea    0xe15(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%edx
mov    %r15,%rdi
lea    0xe18(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%edx
mov    %r15,%rdi
lea    0xe1c(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%edx
mov    %r15,%rdi
lea    0xe1f(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%edx
mov    %r15,%rdi
lea    0xe23(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%edx
mov    %r15,%rdi
lea    0xe28(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <main+0x90>
nopl   (%rax)
lea    0xd52(%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     137e <main+0x20e>
mov    0x8(%rsp),%eax
mov    $0x2d525053,%ecx
xor    %ecx,%eax
movzwl 0xc(%rsp),%ecx
xor    $0x33,%ecx
or     %eax,%ecx
je     138f <main+0x21f>
mov    0x8(%rsp),%eax
mov    $0x2d325353,%ecx
xor    %ecx,%eax
mov    0xb(%rsp),%ecx
mov    $0x35562d,%edx
xor    %edx,%ecx
or     %eax,%ecx
je     13b1 <main+0x241>
movabs $0x33562d31475053,%rax
cmp    %rax,0x8(%rsp)
je     13d3 <main+0x263>
mov    0x8(%rsp),%eax
mov    $0x454e494d,%ecx
xor    %ecx,%eax
movzbl 0xc(%rsp),%ecx
or     %eax,%ecx
je     13f5 <main+0x285>
lea    0xcad(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <main+0x90>
mov    0x4(%rbx),%eax
sub    0x4(%rsp),%eax
js     13c2 <main+0x252>
mov    %eax,0x4(%rbx)
jmp    1200 <main+0x90>
mov    0x8(%rbx),%eax
sub    0x4(%rsp),%eax
js     13e4 <main+0x274>
mov    %eax,0x8(%rbx)
jmp    1200 <main+0x90>
lea    0xcaa(%rip),%rdi
call   1030 <puts@plt>
jmp    1200 <main+0x90>
mov    0xc(%rbx),%eax
sub    0x4(%rsp),%eax
js     1406 <main+0x296>
mov    %eax,0xc(%rbx)
jmp    1200 <main+0x90>
lea    0xc9f(%rip),%rdi
call   1030 <puts@plt>
jmp    1200 <main+0x90>
mov    0x10(%rbx),%eax
sub    0x4(%rsp),%eax
js     1417 <main+0x2a7>
mov    %eax,0x10(%rbx)
jmp    1200 <main+0x90>
lea    0xc95(%rip),%rdi
call   1030 <puts@plt>
jmp    1200 <main+0x90>
mov    0x14(%rbx),%eax
sub    0x4(%rsp),%eax
js     1428 <main+0x2b8>
mov    %eax,0x14(%rbx)
jmp    1200 <main+0x90>
lea    0xc8a(%rip),%rdi
call   1030 <puts@plt>
jmp    1200 <main+0x90>
lea    0xc91(%rip),%rdi
call   1030 <puts@plt>
jmp    1200 <main+0x90>
lea    0xc99(%rip),%rdi
call   1030 <puts@plt>
jmp    1200 <main+0x90>
lea    0xbeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xbf5(%rip),%rdi
call   1030 <puts@plt>
lea    0xba8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <shmdt@plt>
mov    0x2b72(%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 = [17 x i8] c"2. Beli Senjata\0A\00"
@.str.8 = [18 x i8] c"Masukkan 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 = [24 x i8] c"You can't afford MP4A1\0A\00"
@.str.13 = [25 x i8] c"You can't afford PM2-V1\0A\00"
@.str.14 = [24 x i8] c"You can't afford SPR-3\0A\00"
@.str.15 = [25 x i8] c"You can't afford SS2-V5\0A\00"
@.str.16 = [26 x i8] c"You can't afford SPG1-V3\0A\00"
@.str.17 = [23 x i8] c"You can't afford MINE\0A\00"
@.str.18 = [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 ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %27
27: ; preds = %188, %0
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %192
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 %188
53: ; preds = %30
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 2
br i1 %55, label %56, label %186
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 %78, label %62
62: ; preds = %56
%63 = load i32*, i32** %2
%64 = getelementptr inbounds i32, i32* %63, i64 0
%65 = load i32, i32* %64
%66 = load i32, i32* %8
%67 = sub nsw i32 %65, %66
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %62
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
br label %77
71: ; preds = %62
%72 = load i32, i32* %8
%73 = load i32*, i32** %2
%74 = getelementptr inbounds i32, i32* %73, i64 0
%75 = load i32, i32* %74
%76 = sub nsw i32 %75, %72
store i32 %76, i32* %74
br label %77
77: ; preds = %71, %69
br label %185
78: ; preds = %56
%79 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %98, label %82
82: ; preds = %78
%83 = load i32*, i32** %2
%84 = getelementptr inbounds i32, i32* %83, i64 1
%85 = load i32, i32* %84
%86 = load i32, i32* %8
%87 = sub nsw i32 %85, %86
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %82
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
br label %97
91: ; preds = %82
%92 = load i32, i32* %8
%93 = load i32*, i32** %2
%94 = getelementptr inbounds i32, i32* %93, i64 1
%95 = load i32, i32* %94
%96 = sub nsw i32 %95, %92
store i32 %96, i32* %94
br label %97
97: ; preds = %91, %89
br label %184
98: ; preds = %78
%99 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%100 = call i32 @strcmp(i8* %99, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%101 = icmp ne i32 %100, 0
br i1 %101, label %118, label %102
102: ; preds = %98
%103 = load i32*, i32** %2
%104 = getelementptr inbounds i32, i32* %103, i64 2
%105 = load i32, i32* %104
%106 = load i32, i32* %8
%107 = sub nsw i32 %105, %106
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %102
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0))
br label %117
111: ; preds = %102
%112 = load i32, i32* %8
%113 = load i32*, i32** %2
%114 = getelementptr inbounds i32, i32* %113, i64 2
%115 = load i32, i32* %114
%116 = sub nsw i32 %115, %112
store i32 %116, i32* %114
br label %117
117: ; preds = %111, %109
br label %183
118: ; preds = %98
%119 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%120 = call i32 @strcmp(i8* %119, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%121 = icmp ne i32 %120, 0
br i1 %121, label %138, label %122
122: ; preds = %118
%123 = load i32*, i32** %2
%124 = getelementptr inbounds i32, i32* %123, i64 3
%125 = load i32, i32* %124
%126 = load i32, i32* %8
%127 = sub nsw i32 %125, %126
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %122
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
br label %137
131: ; preds = %122
%132 = load i32, i32* %8
%133 = load i32*, i32** %2
%134 = getelementptr inbounds i32, i32* %133, i64 3
%135 = load i32, i32* %134
%136 = sub nsw i32 %135, %132
store i32 %136, i32* %134
br label %137
137: ; preds = %131, %129
br label %182
138: ; preds = %118
%139 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%140 = call i32 @strcmp(i8* %139, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%141 = icmp ne i32 %140, 0
br i1 %141, label %158, label %142
142: ; preds = %138
%143 = load i32*, i32** %2
%144 = getelementptr inbounds i32, i32* %143, i64 4
%145 = load i32, i32* %144
%146 = load i32, i32* %8
%147 = sub nsw i32 %145, %146
%148 = icmp slt i32 %147, 0
br i1 %148, label %149, label %151
149: ; preds = %142
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.16, i64 0, i64 0))
br label %157
151: ; preds = %142
%152 = load i32, i32* %8
%153 = load i32*, i32** %2
%154 = getelementptr inbounds i32, i32* %153, i64 4
%155 = load i32, i32* %154
%156 = sub nsw i32 %155, %152
store i32 %156, i32* %154
br label %157
157: ; preds = %151, %149
br label %181
158: ; preds = %138
%159 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%160 = call i32 @strcmp(i8* %159, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%161 = icmp ne i32 %160, 0
br i1 %161, label %178, label %162
162: ; preds = %158
%163 = load i32*, i32** %2
%164 = getelementptr inbounds i32, i32* %163, i64 5
%165 = load i32, i32* %164
%166 = load i32, i32* %8
%167 = sub nsw i32 %165, %166
%168 = icmp slt i32 %167, 0
br i1 %168, label %169, label %171
169: ; preds = %162
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
br label %177
171: ; preds = %162
%172 = load i32, i32* %8
%173 = load i32*, i32** %2
%174 = getelementptr inbounds i32, i32* %173, i64 5
%175 = load i32, i32* %174
%176 = sub nsw i32 %175, %172
store i32 %176, i32* %174
br label %177
177: ; preds = %171, %169
br label %180
178: ; preds = %158
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0))
br label %180
180: ; preds = %178, %177
br label %181
181: ; preds = %180, %157
br label %182
182: ; preds = %181, %137
br label %183
183: ; preds = %182, %117
br label %184
184: ; preds = %183, %97
br label %185
185: ; preds = %184, %77
br label %187
186: ; preds = %53
store i32 0, i32* %5
br label %187
187: ; preds = %186, %185
br label %188
188: ; preds = %187, %52
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %27
192: ; preds = %27
%193 = load i32*, i32** %2
%194 = call i32 @shmdt(i32* %193)
%195 = load i32, i32* %3
%196 = load i32, i32* @IPC_RMID
%197 = call i32 @shmctl(i32 %195, i32 %196, 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 = [18 x i8] c"Masukkan 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.18 = [12 x i8] c"Unavailable\00"
@IPC_RMID = global i32 0
@str.20 = [22 x i8] c"1. Lihat Stok Senjata\00"
@str.21 = [16 x i8] c"2. Beli Senjata\00"
@str.22 = [23 x i8] c"You can't afford MP4A1\00"
@str.23 = [24 x i8] c"You can't afford PM2-V1\00"
@str.24 = [23 x i8] c"You can't afford SPR-3\00"
@str.25 = [24 x i8] c"You can't afford SS2-V5\00"
@str.26 = [25 x i8] c"You can't afford SPG1-V3\00"
@str.27 = [22 x i8] c"You can't afford MINE\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.20, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.21, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 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 = %104, %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 %108 [
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 %104
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 %47
39: ; preds = %35
%40 = load i32, i32* %7
%41 = load i32, i32* %3
%42 = sub nsw i32 %40, %41
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.22, i64 0, i64 0))
br label %104
46: ; preds = %39
store i32 %42, i32* %7
br label %104
47: ; preds = %35
%48 = 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)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %47
%51 = load i32, i32* %18
%52 = load i32, i32* %3
%53 = sub nsw i32 %51, %52
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.23, i64 0, i64 0))
br label %104
57: ; preds = %50
store i32 %53, i32* %18
br label %104
58: ; preds = %47
%59 = 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)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %69
61: ; preds = %58
%62 = load i32, i32* %17
%63 = load i32, i32* %3
%64 = sub nsw i32 %62, %63
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.24, i64 0, i64 0))
br label %104
68: ; preds = %61
store i32 %64, i32* %17
br label %104
69: ; preds = %58
%70 = 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)
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %80
72: ; preds = %69
%73 = load i32, i32* %16
%74 = load i32, i32* %3
%75 = sub nsw i32 %73, %74
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %72
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.25, i64 0, i64 0))
br label %104
79: ; preds = %72
store i32 %75, i32* %16
br label %104
80: ; preds = %69
%81 = 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)
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %91
83: ; preds = %80
%84 = load i32, i32* %15
%85 = load i32, i32* %3
%86 = sub nsw i32 %84, %85
%87 = icmp slt i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %83
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.26, i64 0, i64 0))
br label %104
90: ; preds = %83
store i32 %86, i32* %15
br label %104
91: ; preds = %80
%92 = 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)
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %102
94: ; preds = %91
%95 = load i32, i32* %14
%96 = load i32, i32* %3
%97 = sub nsw i32 %95, %96
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.27, i64 0, i64 0))
br label %104
101: ; preds = %94
store i32 %97, i32* %14
br label %104
102: ; preds = %91
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0))
br label %104
104: ; preds = %22, %57, %55, %79, %77, %102, %101, %99, %88, %90, %66, %68, %44, %46
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.20, i64 0, i64 0))
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.21, i64 0, i64 0))
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %19
108: ; preds = %19
%109 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.20, i64 0, i64 0))
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.21, i64 0, i64 0))
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%112 = call i32 @shmdt(i32* %7)
%113 = load i32, i32* @IPC_RMID
%114 = call i32 @shmctl(i32 %6, i32 %113, i32* null)
ret void
}