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

/* Variables and functions */
scalar_t__ EEXIST;
int IPC_CREAT;
int IPC_EXCL;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ ftok(char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ shmdt(char *);
int shmget(int /*<<< orphan*/, int, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[], char *env[]) {
  if (argc != 2 ||
      (strcmp(argv[1], "set") != 0 && strcmp(argv[1], "find") != 0)) {
    printf("Function must be called with the argument 'set' or 'find'\n");
    exit(-1);
  }
  char *data_base;
  int shmid;
  char pathname[] = "lab06.c";
  key_t key;
  if ((key = ftok(pathname, 0)) < 0) {
    printf("Can\'t generate key\n");
    exit(-1);
  }
  if ((shmid = shmget(key, 5 * (64 + 64 + 2) * sizeof(char),
                      0666 | IPC_CREAT | IPC_EXCL)) < 0) {
    if (errno != EEXIST) {
      printf("Can\'t create shared memory\n");
      exit(-1);
    } else {
      if ((shmid = shmget(key, 5 * (64 + 64 + 2) * sizeof(char), 0)) < 0) {
        printf("Can\'t find shared memory\n");
        exit(-1);
      }
    }
  }
  if ((data_base = (char *)shmat(shmid, NULL, 0)) == (char *)(-1)) {
    printf("Can't attach shared memory\n");
    exit(-1);
  }
  if (strcmp(argv[1], "set") == 0) {
    char name[64];
    char email[64];
    int i;
    for (i = 0; i < 5; i++) {
      memset(name, '\0', 64);
      memset(email, '\0', 64);
      printf("Enter the record number %d\nEnter name: ", i);
      scanf("\n%[^\r\n]", name);
      printf("Enter email: ");
      scanf("\n%[^\r\n]", email);
      strncpy(data_base + (i * (64 + 64 + 2)) * sizeof(char), name, 64);
      strncpy(data_base + (i * (64 + 64 + 2) + 64) * sizeof(char), "\0", 64);
      strncpy(data_base + (i * (64 + 64 + 2) + 64 + 1) * sizeof(char), email,
              64);
      strncpy(data_base + ((i + 1) * (64 + 64 + 2) - 1) * sizeof(char), "\0",
              64);
    }
  } else {
    char name[64];
    memset(name, '\0', 64);
    printf("Enter name: ");
    scanf("\n%[^\r\n]", name);
    int i;
    int result = 0;
    for (i = 0; i < 5; i++) {
      char tempname[64];
      memset(tempname, '\0', 64);
      strncpy(tempname, data_base + (i * (64 + 64 + 2)) * sizeof(char), 64);
      if (strcmp(tempname, name) == 0) {
        result = 1;
        char tempemail[64];
        memset(tempemail, '\0', 64);
        strncpy(tempemail,
                data_base + (i * (64 + 64 + 2) + 64 + 1) * sizeof(char),
                64 + 1);
        printf("%s %s\n", tempname, tempemail);
      }
    }
  }
  if (shmdt(data_base) < 0) {
    printf("Can't detach shared memory\n");
    exit(-1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1203 <main+0x63>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     121b <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe10(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     121b <main+0x7b>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    0xe22(%rip),%rax
mov    %rax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
call   10c0 <ftok@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    1255 <main+0xb5>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x30(%rbp),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%edx
or     $0x1b6,%edx
mov    0x2d82(%rip),%rax
or     (%rax),%edx
mov    $0x28a,%esi
call   10a0 <shmget@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12f5 <main+0x155>
mov    0x2d43(%rip),%rax
mov    (%rax),%rax
mov    0x2d41(%rip),%rcx
cmp    (%rcx),%rax
je     12b8 <main+0x118>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x30(%rbp),%edi
mov    $0x28a,%esi
xor    %edx,%edx
call   10a0 <shmget@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12eb <main+0x14b>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
jmp    12f0 <main+0x150>
jmp    12f5 <main+0x155>
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <shmat@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jne    132f <main+0x18f>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcc2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1493 <main+0x2f3>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x5,-0xb4(%rbp)
jge    148e <main+0x2ee>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    -0xb4(%rbp),%esi
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xd34(%rip),%rdi
call   1080 <scanf@plt>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xb0(%rbp),%rsi
lea    0xd13(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x20(%rbp),%rdi
imul   $0x82,-0xb4(%rbp),%eax
cltq
shl    $0x0,%rax
add    %rax,%rdi
lea    -0x70(%rbp),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
imul   $0x82,-0xb4(%rbp),%eax
add    $0x40,%eax
cltq
shl    $0x0,%rax
add    %rax,%rdi
lea    0xd01(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
imul   $0x82,-0xb4(%rbp),%eax
add    $0x40,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
add    %rax,%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
imul   $0x82,%eax,%eax
sub    $0x1,%eax
cltq
shl    $0x0,%rax
add    %rax,%rdi
lea    0xca3(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1357 <main+0x1b7>
jmp    15c5 <main+0x425>
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x100(%rbp),%rsi
lea    0xc18(%rip),%rdi
call   1080 <scanf@plt>
movl   $0x0,-0x108(%rbp)
movl   $0x0,-0x104(%rbp)
cmpl   $0x5,-0x104(%rbp)
jge    15c0 <main+0x420>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rsi
imul   $0x82,-0x104(%rbp),%eax
cltq
shl    $0x0,%rax
add    %rax,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    -0x150(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    15a7 <main+0x407>
movl   $0x1,-0x108(%rbp)
lea    -0x190(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0x190(%rbp),%rdi
mov    -0x20(%rbp),%rsi
imul   $0x82,-0x104(%rbp),%eax
add    $0x40,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
add    %rax,%rsi
mov    $0x41,%edx
call   1030 <strncpy@plt>
lea    -0x150(%rbp),%rsi
lea    -0x190(%rbp),%rdx
lea    0xb50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15ac <main+0x40c>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    14db <main+0x33b>
jmp    15c5 <main+0x425>
mov    -0x20(%rbp),%rdi
call   1040 <shmdt@plt>
cmp    $0x0,%rax
jge    15f0 <main+0x450>
lea    0xb18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
cmp    $0x2,%edi
jne    1645 <main+0x495>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe28(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11fb <main+0x4b>
mov    0x8(%rbx),%rdi
lea    0xe17(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1645 <main+0x495>
movabs $0x632e363062616c,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10d0 <ftok@plt>
test   %eax,%eax
js     164e <main+0x49e>
mov    %eax,%ebp
mov    0x2da1(%rip),%rax
mov    (%rax),%edx
mov    0x2dc0(%rip),%rax
or     (%rax),%edx
or     $0x1b6,%edx
mov    %ebp,%edi
mov    $0x28a,%esi
call   10b0 <shmget@plt>
test   %eax,%eax
jns    1278 <main+0xc8>
mov    0x2d81(%rip),%rax
mov    (%rax),%rax
mov    0x2d7f(%rip),%rcx
cmp    (%rcx),%rax
jne    1669 <main+0x4b9>
mov    %ebp,%edi
mov    $0x28a,%esi
xor    %edx,%edx
call   10b0 <shmget@plt>
test   %eax,%eax
js     1672 <main+0x4c2>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <shmat@plt>
cmp    $0xffffffffffffffff,%rax
je     1657 <main+0x4a7>
mov    %rax,%r12
mov    0x8(%rbx),%rdi
lea    0xd65(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     154c <main+0x39c>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0xd60(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd5f(%rip),%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    134d <main+0x19d>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x41(%r12),%rsi
mov    %rbx,%rdi
mov    $0x41,%edx
call   1030 <strncpy@plt>
lea    0xd09(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x82(%r12),%rsi
mov    %rbx,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0x50(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    13ca <main+0x21a>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0xc3(%r12),%rsi
mov    %rbx,%rdi
mov    $0x41,%edx
call   1030 <strncpy@plt>
lea    0xc8c(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x104(%r12),%rsi
mov    %rbx,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0x50(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1447 <main+0x297>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x145(%r12),%rsi
mov    %rbx,%rdi
mov    $0x41,%edx
call   1030 <strncpy@plt>
lea    0xc0f(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x186(%r12),%rsi
mov    %rbx,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0x50(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    14c4 <main+0x314>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x1c7(%r12),%rsi
mov    %rbx,%rdi
mov    $0x41,%edx
call   1030 <strncpy@plt>
lea    0xb92(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0x208(%r12),%rsi
mov    %rbx,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0x50(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1624 <main+0x474>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
mov    %r12,%rsi
add    $0x249,%rsi
mov    %rbx,%rdi
mov    $0x41,%edx
call   1030 <strncpy@plt>
lea    0xb0f(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1624 <main+0x474>
lea    0x50(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xad4(%rip),%r13
lea    0xba1(%rip),%r14
mov    %r12,(%rsp)
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0xa74(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
lea    0xa89(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0x40(%r12),%rdi
mov    %r14,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0x41(%r12),%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
add    $0x1,%rbp
lea    0x81(%r12),%rdi
mov    %r14,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
add    $0x82,%r12
cmp    $0x5,%rbp
jne    1570 <main+0x3c0>
mov    (%rsp),%r12
mov    %r12,%rdi
call   1050 <shmdt@plt>
test   %rax,%rax
js     1660 <main+0x4b0>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa7f(%rip),%rdi
jmp    1679 <main+0x4c9>
lea    0xa63(%rip),%rdi
jmp    1679 <main+0x4c9>
lea    0xa0b(%rip),%rdi
jmp    1679 <main+0x4c9>
lea    0x9e7(%rip),%rdi
jmp    1679 <main+0x4c9>
lea    0xa2d(%rip),%rdi
jmp    1679 <main+0x4c9>
lea    0xa0b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"set\00"
@.str.1 = [5 x i8] c"find\00"
@.str.2 = [59 x i8] c"Function must be called with the argument 'set' or 'find'\0A\00"
@__const.main.pathname = [8 x i8] c"lab06.c\00"
@.str.3 = [20 x i8] c"Can't generate key\0A\00"
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.4 = [28 x i8] c"Can't create shared memory\0A\00"
@.str.5 = [26 x i8] c"Can't find shared memory\0A\00"
@.str.6 = [28 x i8] c"Can't attach shared memory\0A\00"
@.str.7 = [40 x i8] c"Enter the record number %d\0AEnter name: \00"
@.str.8 = [8 x i8] c"\0A%[^\0D\0A]\00"
@.str.9 = [14 x i8] c"Enter email: \00"
@.str.10 = [2 x i8] zeroinitializer
@.str.11 = [13 x i8] c"Enter name: \00"
@.str.12 = [7 x i8] c"%s %s\0A\00"
@.str.13 = [28 x i8] c"Can't detach shared memory\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [8 x i8]
%11 = alloca i32
%12 = alloca [64 x i8]
%13 = alloca [64 x i8]
%14 = alloca i32
%15 = alloca [64 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca [64 x i8]
%19 = alloca [64 x i8]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%20 = load i32, i32* %5
%21 = icmp ne i32 %20, 2
br i1 %21, label %34, label %22
22: ; preds = %3
%23 = load i8**, i8*** %6
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %22
%29 = load i8**, i8*** %6
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28, %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %28, %22
%38 = bitcast [8 x i8]* %10 to i8*
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%40 = call i32 @ftok(i8* %39, i32 0)
store i32 %40, i32* %11
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %37
%46 = load i32, i32* %11
%47 = load i32, i32* @IPC_CREAT
%48 = or i32 438, %47
%49 = load i32, i32* @IPC_EXCL
%50 = or i32 %48, %49
%51 = call i32 @shmget(i32 %46, i32 650, i32 %50)
store i32 %51, i32* %9
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %69
53: ; preds = %45
%54 = load i64, i64* @errno
%55 = load i64, i64* @EEXIST
%56 = icmp ne i64 %54, %55
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%59 = call i32 @exit(i32 -1)
unreachable
60: ; preds = %53
%61 = load i32, i32* %11
%62 = call i32 @shmget(i32 %61, i32 650, i32 0)
store i32 %62, i32* %9
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %60
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68, %45
%70 = load i32, i32* %9
%71 = call i64 @shmat(i32 %70, i32* null, i32 0)
%72 = inttoptr i64 %71 to i8*
store i8* %72, i8** %8
%73 = icmp eq i8* %72, inttoptr (i64 -1 to i8*)
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%76 = call i32 @exit(i32 -1)
unreachable
77: ; preds = %69
%78 = load i8**, i8*** %6
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %138
83: ; preds = %77
store i32 0, i32* %14
br label %84
84: ; preds = %134, %83
%85 = load i32, i32* %14
%86 = icmp slt i32 %85, 5
br i1 %86, label %87, label %137
87: ; preds = %84
%88 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%89 = call i32 @memset(i8* %88, i8 signext 0, i32 64)
%90 = getelementptr inbounds [64 x i8], [64 x i8]* %13, i64 0, i64 0
%91 = call i32 @memset(i8* %90, i8 signext 0, i32 64)
%92 = load i32, i32* %14
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %92)
%94 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%95 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%97 = getelementptr inbounds [64 x i8], [64 x i8]* %13, i64 0, i64 0
%98 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %97)
%99 = load i8*, i8** %8
%100 = load i32, i32* %14
%101 = mul nsw i32 %100, 130
%102 = sext i32 %101 to i64
%103 = mul i64 %102, 1
%104 = getelementptr inbounds i8, i8* %99, i64 %103
%105 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%106 = call i32 @strncpy(i8* %104, i8* %105, i32 64)
%107 = load i8*, i8** %8
%108 = load i32, i32* %14
%109 = mul nsw i32 %108, 130
%110 = add nsw i32 %109, 64
%111 = sext i32 %110 to i64
%112 = mul i64 %111, 1
%113 = getelementptr inbounds i8, i8* %107, i64 %112
%114 = call i32 @strncpy(i8* %113, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 64)
%115 = load i8*, i8** %8
%116 = load i32, i32* %14
%117 = mul nsw i32 %116, 130
%118 = add nsw i32 %117, 64
%119 = add nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = mul i64 %120, 1
%122 = getelementptr inbounds i8, i8* %115, i64 %121
%123 = getelementptr inbounds [64 x i8], [64 x i8]* %13, i64 0, i64 0
%124 = call i32 @strncpy(i8* %122, i8* %123, i32 64)
%125 = load i8*, i8** %8
%126 = load i32, i32* %14
%127 = add nsw i32 %126, 1
%128 = mul nsw i32 %127, 130
%129 = sub nsw i32 %128, 1
%130 = sext i32 %129 to i64
%131 = mul i64 %130, 1
%132 = getelementptr inbounds i8, i8* %125, i64 %131
%133 = call i32 @strncpy(i8* %132, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 64)
br label %134
134: ; preds = %87
%135 = load i32, i32* %14
%136 = add nsw i32 %135, 1
store i32 %136, i32* %14
br label %84
137: ; preds = %84
br label %183
138: ; preds = %77
%139 = getelementptr inbounds [64 x i8], [64 x i8]* %15, i64 0, i64 0
%140 = call i32 @memset(i8* %139, i8 signext 0, i32 64)
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%142 = getelementptr inbounds [64 x i8], [64 x i8]* %15, i64 0, i64 0
%143 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %142)
store i32 0, i32* %17
store i32 0, i32* %16
br label %144
144: ; preds = %179, %138
%145 = load i32, i32* %16
%146 = icmp slt i32 %145, 5
br i1 %146, label %147, label %182
147: ; preds = %144
%148 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%149 = call i32 @memset(i8* %148, i8 signext 0, i32 64)
%150 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%151 = load i8*, i8** %8
%152 = load i32, i32* %16
%153 = mul nsw i32 %152, 130
%154 = sext i32 %153 to i64
%155 = mul i64 %154, 1
%156 = getelementptr inbounds i8, i8* %151, i64 %155
%157 = call i32 @strncpy(i8* %150, i8* %156, i32 64)
%158 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%159 = getelementptr inbounds [64 x i8], [64 x i8]* %15, i64 0, i64 0
%160 = call i64 @strcmp(i8* %158, i8* %159)
%161 = icmp eq i64 %160, 0
br i1 %161, label %162, label %178
162: ; preds = %147
store i32 1, i32* %17
%163 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%164 = call i32 @memset(i8* %163, i8 signext 0, i32 64)
%165 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%166 = load i8*, i8** %8
%167 = load i32, i32* %16
%168 = mul nsw i32 %167, 130
%169 = add nsw i32 %168, 64
%170 = add nsw i32 %169, 1
%171 = sext i32 %170 to i64
%172 = mul i64 %171, 1
%173 = getelementptr inbounds i8, i8* %166, i64 %172
%174 = call i32 @strncpy(i8* %165, i8* %173, i32 65)
%175 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%176 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %175, i8* %176)
br label %178
178: ; preds = %162, %147
br label %179
179: ; preds = %178
%180 = load i32, i32* %16
%181 = add nsw i32 %180, 1
store i32 %181, i32* %16
br label %144
182: ; preds = %144
br label %183
183: ; preds = %182, %137
%184 = load i8*, i8** %8
%185 = call i64 @shmdt(i8* %184)
%186 = icmp slt i64 %185, 0
br i1 %186, label %187, label %190
187: ; preds = %183
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%189 = call i32 @exit(i32 -1)
unreachable
190: ; preds = %183
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"set\00"
@.str.1 = [5 x i8] c"find\00"
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.7 = [40 x i8] c"Enter the record number %d\0AEnter name: \00"
@.str.8 = [8 x i8] c"\0A%[^\0D\0A]\00"
@.str.9 = [14 x i8] c"Enter email: \00"
@.str.10 = [2 x i8] zeroinitializer
@.str.11 = [13 x i8] c"Enter name: \00"
@.str.12 = [7 x i8] c"%s %s\0A\00"
@str = [27 x i8] c"Can't detach shared memory\00"
@str.14 = [27 x i8] c"Can't attach shared memory\00"
@str.15 = [25 x i8] c"Can't find shared memory\00"
@str.16 = [27 x i8] c"Can't create shared memory\00"
@str.17 = [19 x i8] c"Can't generate key\00"
@str.18 = [58 x i8] c"Function must be called with the argument 'set' or 'find'\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca i64
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
%8 = alloca [64 x i8]
%9 = alloca [64 x i8]
%10 = icmp eq i32 %0, 2
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16, %3
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.18, i64 0, i64 0))
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %16, %11
%24 = bitcast i64* %4 to i8*
store i64 27916832969220460, i64* %4
%25 = call i32 @ftok(i8* %24, i32 0)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.17, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %23
%31 = load i32, i32* @IPC_CREAT
%32 = load i32, i32* @IPC_EXCL
%33 = or i32 %31, %32
%34 = or i32 %33, 438
%35 = call i32 @shmget(i32 %25, i32 650, i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %50
37: ; preds = %30
%38 = load i64, i64* @errno
%39 = load i64, i64* @EEXIST
%40 = icmp eq i64 %38, %39
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.16, i64 0, i64 0))
%43 = call i32 @exit(i32 -1)
unreachable
44: ; preds = %37
%45 = call i32 @shmget(i32 %25, i32 650, i32 0)
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.15, i64 0, i64 0))
%49 = call i32 @exit(i32 -1)
unreachable
50: ; preds = %44, %30
%51 = phi i32 [ %45, %44 ], [ %35, %30 ]
%52 = call i64 @shmat(i32 %51, i32* null, i32 0)
%53 = inttoptr i64 %52 to i8*
%54 = icmp eq i8* %53, inttoptr (i64 -1 to i8*)
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.14, i64 0, i64 0))
%57 = call i32 @exit(i32 -1)
unreachable
58: ; preds = %50
%59 = load i8*, i8** %12
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %90
62: ; preds = %58
%63 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
br label %65
65: ; preds = %62, %65
%66 = phi i64 [ 0, %62 ], [ %83, %65 ]
%67 = call i32 @memset(i8* %63, i8 signext 0, i32 64)
%68 = call i32 @memset(i8* %64, i8 signext 0, i32 64)
%69 = trunc i64 %66 to i32
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %69)
%71 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %63)
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%73 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %64)
%74 = mul nuw nsw i64 %66, 130
%75 = getelementptr inbounds i8, i8* %53, i64 %74
%76 = call i32 @strncpy(i8* %75, i8* %63, i32 64)
%77 = add nuw nsw i64 %74, 64
%78 = getelementptr inbounds i8, i8* %53, i64 %77
%79 = call i32 @strncpy(i8* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 64)
%80 = add nuw nsw i64 %74, 65
%81 = getelementptr inbounds i8, i8* %53, i64 %80
%82 = call i32 @strncpy(i8* %81, i8* %64, i32 64)
%83 = add nuw nsw i64 %66, 1
%84 = mul nuw nsw i64 %83, 130
%85 = add nsw i64 %84, -1
%86 = getelementptr inbounds i8, i8* %53, i64 %85
%87 = call i32 @strncpy(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 64)
%88 = icmp eq i64 %83, 5
br i1 %88, label %89, label %65
89: ; preds = %65
br label %151
90: ; preds = %58
%91 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%92 = call i32 @memset(i8* %91, i8 signext 0, i32 64)
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%94 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %91)
%95 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%96 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%97 = call i32 @memset(i8* %95, i8 signext 0, i32 64)
%98 = call i32 @strncpy(i8* %95, i8* %53, i32 64)
%99 = call i64 @strcmp(i8* %95, i8* %91)
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %90
%102 = call i32 @memset(i8* %96, i8 signext 0, i32 64)
%103 = getelementptr inbounds i8, i8* %53, i64 65
%104 = call i32 @strncpy(i8* %96, i8* %103, i32 65)
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %95, i8* %96)
br label %106
106: ; preds = %101, %90
%107 = call i32 @memset(i8* %95, i8 signext 0, i32 64)
%108 = getelementptr inbounds i8, i8* %53, i64 130
%109 = call i32 @strncpy(i8* %95, i8* %108, i32 64)
%110 = call i64 @strcmp(i8* %95, i8* %91)
%111 = icmp eq i64 %110, 0
br i1 %111, label %112, label %117
112: ; preds = %106
%113 = call i32 @memset(i8* %96, i8 signext 0, i32 64)
%114 = getelementptr inbounds i8, i8* %53, i64 195
%115 = call i32 @strncpy(i8* %96, i8* %114, i32 65)
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %95, i8* %96)
br label %117
117: ; preds = %112, %106
%118 = call i32 @memset(i8* %95, i8 signext 0, i32 64)
%119 = getelementptr inbounds i8, i8* %53, i64 260
%120 = call i32 @strncpy(i8* %95, i8* %119, i32 64)
%121 = call i64 @strcmp(i8* %95, i8* %91)
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %128
123: ; preds = %117
%124 = call i32 @memset(i8* %96, i8 signext 0, i32 64)
%125 = getelementptr inbounds i8, i8* %53, i64 325
%126 = call i32 @strncpy(i8* %96, i8* %125, i32 65)
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %95, i8* %96)
br label %128
128: ; preds = %123, %117
%129 = call i32 @memset(i8* %95, i8 signext 0, i32 64)
%130 = getelementptr inbounds i8, i8* %53, i64 390
%131 = call i32 @strncpy(i8* %95, i8* %130, i32 64)
%132 = call i64 @strcmp(i8* %95, i8* %91)
%133 = icmp eq i64 %132, 0
br i1 %133, label %134, label %139
134: ; preds = %128
%135 = call i32 @memset(i8* %96, i8 signext 0, i32 64)
%136 = getelementptr inbounds i8, i8* %53, i64 455
%137 = call i32 @strncpy(i8* %96, i8* %136, i32 65)
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %95, i8* %96)
br label %139
139: ; preds = %134, %128
%140 = call i32 @memset(i8* %95, i8 signext 0, i32 64)
%141 = getelementptr inbounds i8, i8* %53, i64 520
%142 = call i32 @strncpy(i8* %95, i8* %141, i32 64)
%143 = call i64 @strcmp(i8* %95, i8* %91)
%144 = icmp eq i64 %143, 0
br i1 %144, label %145, label %150
145: ; preds = %139
%146 = call i32 @memset(i8* %96, i8 signext 0, i32 64)
%147 = getelementptr inbounds i8, i8* %53, i64 585
%148 = call i32 @strncpy(i8* %96, i8* %147, i32 65)
%149 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %95, i8* %96)
br label %150
150: ; preds = %145, %139
br label %151
151: ; preds = %150, %89
%152 = call i64 @shmdt(i8* %53)
%153 = icmp slt i64 %152, 0
br i1 %153, label %154, label %157
154: ; preds = %151
%155 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%156 = call i32 @exit(i32 -1)
unreachable
157: ; preds = %151
ret i32 0
}