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

/* Variables and functions */
char EOF;
int /*<<< orphan*/ allocate(char **, int);
int /*<<< orphan*/ assert(int);
scalar_t__ calloc(unsigned int, int);
int /*<<< orphan*/ deallocate(char **);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(void *);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_from_memory(char *, int);
int sscanf(char *, char *, unsigned int *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
unsigned int strtoul(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write_to_memory(char *, int);
int main(int argc, char *argv[]) {
  char **array;
  unsigned array_size;
  char command[32];
  unsigned array_index;
  char command_letter;
  int size_or_position;
  int error = 0;
  if (argc != 2) {
    fprintf(stderr, "%s: array-size\n", argv[0]);
    return -1;
  }
  array_size = strtoul(argv[1], 0, 0);
  array = (char **)calloc(array_size, sizeof(char *));
  assert(array != 0);
  while (!error) {
    printf("please enter a command: ");
    command_letter = getchar();
    assert(command_letter != EOF);
    switch (command_letter) {
    case 'a':
      fgets(command, sizeof(command), stdin);
      if (sscanf(command, "%u %i", &array_index, &size_or_position) == 2 &&
          array_index < array_size) {
        allocate(&(array[array_index]), size_or_position);
      } else {
        error = 1;
      }
      break;
    case 'd':
      fgets(command, sizeof(command), stdin);
      if (sscanf(command, "%u", &array_index) == 1 &&
          array_index < array_size) {
        deallocate(&(array[array_index]));
      } else {
        error = 1;
      }
      break;
    case 'r':
      fgets(command, sizeof(command), stdin);
      if (sscanf(command, "%u %i", &array_index, &size_or_position) == 2 &&
          array_index < array_size) {
        read_from_memory(array[array_index], size_or_position);
      } else {
        error = 1;
      }
      break;
    case 'w':
      fgets(command, sizeof(command), stdin);
      if (sscanf(command, "%u %i", &array_index, &size_or_position) == 2 &&
          array_index < array_size) {
        write_to_memory(array[array_index], size_or_position);
      } else {
        error = 1;
      }
      break;
    case 'q':
      free((void *)array);
      return 0;
    default:
      error = 1;
    }
  }
  free((void *)array);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     121f <main+0x4f>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4e(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    149f <main+0x2cf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10e0 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
cmpl   $0x0,-0x50(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    126c <main+0x9c>
jmp    148f <main+0x2bf>
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %al,-0x45(%rbp)
movsbl -0x45(%rbp),%eax
mov    0x2d53(%rip),%rcx
movsbl (%rcx),%ecx
sub    %ecx,%eax
setne  %al
movzbl %al,%edi
call   10a0 <assert@plt>
movsbl -0x45(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x16,%eax
ja     1483 <main+0x2b3>
mov    -0x58(%rbp),%rax
lea    0xd42(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x40(%rbp),%rdi
mov    0x2d16(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xd9c(%rip),%rsi
lea    -0x44(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
jne    1328 <main+0x158>
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1328 <main+0x158>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x4c(%rbp),%esi
call   10f0 <allocate@plt>
jmp    132f <main+0x15f>
movl   $0x1,-0x50(%rbp)
jmp    148a <main+0x2ba>
lea    -0x40(%rbp),%rdi
mov    0x2ca9(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xd35(%rip),%rsi
lea    -0x44(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    138e <main+0x1be>
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    138e <main+0x1be>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rdi
call   1060 <deallocate@plt>
jmp    1395 <main+0x1c5>
movl   $0x1,-0x50(%rbp)
jmp    148a <main+0x2ba>
lea    -0x40(%rbp),%rdi
mov    0x2c43(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xcc9(%rip),%rsi
lea    -0x44(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
jne    13f8 <main+0x228>
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    13f8 <main+0x228>
mov    -0x18(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x4c(%rbp),%esi
call   1040 <read_from_memory@plt>
jmp    13ff <main+0x22f>
movl   $0x1,-0x50(%rbp)
jmp    148a <main+0x2ba>
lea    -0x40(%rbp),%rdi
mov    0x2bd9(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xc5f(%rip),%rsi
lea    -0x44(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
jne    1462 <main+0x292>
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1462 <main+0x292>
mov    -0x18(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x4c(%rbp),%esi
call   10d0 <write_to_memory@plt>
jmp    1469 <main+0x299>
movl   $0x1,-0x50(%rbp)
jmp    148a <main+0x2ba>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    149f <main+0x2cf>
movl   $0x1,-0x50(%rbp)
jmp    1256 <main+0x86>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jne    13cf <main+0x1ff>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <strtoul@plt>
mov    %eax,%r15d
mov    %eax,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   10a0 <assert@plt>
lea    0xde5(%rip),%r12
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
movsbl %al,%r14d
xor    %edi,%edi
mov    0x2d90(%rip),%rax
cmp    (%rax),%r14b
setne  %dil
call   10a0 <assert@plt>
add    $0xffffff9f,%r14d
cmp    $0x16,%r14d
ja     13ee <main+0x21e>
movslq (%r12,%r14,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x2d6e(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbp,%rdi
lea    0xdf2(%rip),%rsi
mov    %r13,%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
jne    13ee <main+0x21e>
mov    0xc(%rsp),%eax
cmp    %r15d,%eax
jae    13ee <main+0x21e>
lea    (%rbx,%rax,8),%rdi
mov    0x8(%rsp),%esi
call   10f0 <allocate@plt>
jmp    1230 <main+0x60>
nopw   0x0(%rax,%rax,1)
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbp,%rdi
lea    0xd9b(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    13ee <main+0x21e>
mov    0xc(%rsp),%eax
cmp    %r15d,%eax
jae    13ee <main+0x21e>
lea    (%rbx,%rax,8),%rdi
call   1060 <deallocate@plt>
jmp    1230 <main+0x60>
xchg   %ax,%ax
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbp,%rdi
lea    0xd45(%rip),%rsi
mov    %r13,%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
jne    13ee <main+0x21e>
mov    0xc(%rsp),%eax
cmp    %r15d,%eax
jae    13ee <main+0x21e>
mov    (%rbx,%rax,8),%rdi
mov    0x8(%rsp),%esi
call   1040 <read_from_memory@plt>
jmp    1230 <main+0x60>
nopw   0x0(%rax,%rax,1)
mov    0x2c61(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbp,%rdi
lea    0xce5(%rip),%rsi
mov    %r13,%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
jne    13ee <main+0x21e>
mov    0xc(%rsp),%eax
cmp    %r15d,%eax
jae    13ee <main+0x21e>
mov    (%rbx,%rax,8),%rdi
mov    0x8(%rsp),%esi
call   10d0 <write_to_memory@plt>
jmp    1230 <main+0x60>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xc7a(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13fb <main+0x22b>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    13fb <main+0x22b>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"%s: array-size\0A\00"
@.str.1 = [25 x i8] c"please enter a command: \00"
@EOF = global i8 0
@stdin = global i32 0
@.str.2 = [6 x i8] c"%u %i\00"
@.str.3 = [3 x i8] c"%u\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [32 x i8]
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 -1, i32* %3
br label %140
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strtoul(i8* %24, i32 0, i32 0)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = call i64 @calloc(i32 %26, i32 8)
%28 = inttoptr i64 %27 to i8**
store i8** %28, i8*** %6
%29 = load i8**, i8*** %6
%30 = icmp ne i8** %29, null
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
br label %33
33: ; preds = %135, %21
%34 = load i32, i32* %12
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
br i1 %36, label %37, label %136
37: ; preds = %33
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%39 = call signext i8 (...) @getchar()
store i8 %39, i8* %10
%40 = load i8, i8* %10
%41 = sext i8 %40 to i32
%42 = load i8, i8* @EOF
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %41, %43
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load i8, i8* %10
%48 = sext i8 %47 to i32
switch i32 %48, label %134 [
i32 97, label %49
i32 100, label %69
i32 114, label %88
i32 119, label %109
i32 113, label %130
]
49: ; preds = %37
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%51 = load i32, i32* @stdin
%52 = call i32 @fgets(i8* %50, i32 32, i32 %51)
%53 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%54 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %11)
%55 = icmp eq i32 %54, 2
br i1 %55, label %56, label %67
56: ; preds = %49
%57 = load i32, i32* %9
%58 = load i32, i32* %7
%59 = icmp ult i32 %57, %58
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = load i8**, i8*** %6
%62 = load i32, i32* %9
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i32, i32* %11
%66 = call i32 @allocate(i8** %64, i32 %65)
br label %68
67: ; preds = %56, %49
store i32 1, i32* %12
br label %68
68: ; preds = %67, %60
br label %135
69: ; preds = %37
%70 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%71 = load i32, i32* @stdin
%72 = call i32 @fgets(i8* %70, i32 32, i32 %71)
%73 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%74 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%75 = icmp eq i32 %74, 1
br i1 %75, label %76, label %86
76: ; preds = %69
%77 = load i32, i32* %9
%78 = load i32, i32* %7
%79 = icmp ult i32 %77, %78
br i1 %79, label %80, label %86
80: ; preds = %76
%81 = load i8**, i8*** %6
%82 = load i32, i32* %9
%83 = zext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = call i32 @deallocate(i8** %84)
br label %87
86: ; preds = %76, %69
store i32 1, i32* %12
br label %87
87: ; preds = %86, %80
br label %135
88: ; preds = %37
%89 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%90 = load i32, i32* @stdin
%91 = call i32 @fgets(i8* %89, i32 32, i32 %90)
%92 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%93 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %92, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %11)
%94 = icmp eq i32 %93, 2
br i1 %94, label %95, label %107
95: ; preds = %88
%96 = load i32, i32* %9
%97 = load i32, i32* %7
%98 = icmp ult i32 %96, %97
br i1 %98, label %99, label %107
99: ; preds = %95
%100 = load i8**, i8*** %6
%101 = load i32, i32* %9
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %100, i64 %102
%104 = load i8*, i8** %103
%105 = load i32, i32* %11
%106 = call i32 @read_from_memory(i8* %104, i32 %105)
br label %108
107: ; preds = %95, %88
store i32 1, i32* %12
br label %108
108: ; preds = %107, %99
br label %135
109: ; preds = %37
%110 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%111 = load i32, i32* @stdin
%112 = call i32 @fgets(i8* %110, i32 32, i32 %111)
%113 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%114 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %113, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %11)
%115 = icmp eq i32 %114, 2
br i1 %115, label %116, label %128
116: ; preds = %109
%117 = load i32, i32* %9
%118 = load i32, i32* %7
%119 = icmp ult i32 %117, %118
br i1 %119, label %120, label %128
120: ; preds = %116
%121 = load i8**, i8*** %6
%122 = load i32, i32* %9
%123 = zext i32 %122 to i64
%124 = getelementptr inbounds i8*, i8** %121, i64 %123
%125 = load i8*, i8** %124
%126 = load i32, i32* %11
%127 = call i32 @write_to_memory(i8* %125, i32 %126)
br label %129
128: ; preds = %116, %109
store i32 1, i32* %12
br label %129
129: ; preds = %128, %120
br label %135
130: ; preds = %37
%131 = load i8**, i8*** %6
%132 = bitcast i8** %131 to i8*
%133 = call i32 @free(i8* %132)
store i32 0, i32* %3
br label %140
134: ; preds = %37
store i32 1, i32* %12
br label %135
135: ; preds = %134, %129, %108, %87, %68
br label %33
136: ; preds = %33
%137 = load i8**, i8*** %6
%138 = bitcast i8** %137 to i8*
%139 = call i32 @free(i8* %138)
store i32 1, i32* %3
br label %140
140: ; preds = %136, %130, %15
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"%s: array-size\0A\00"
@.str.1 = [25 x i8] c"please enter a command: \00"
@EOF = global i8 0
@stdin = global i32 0
@.str.2 = [6 x i8] c"%u %i\00"
@.str.3 = [3 x i8] c"%u\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %91
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @strtoul(i8* %16, i32 0, i32 0)
%18 = tail call i64 @calloc(i32 %17, i32 8)
%19 = inttoptr i64 %18 to i8**
%20 = icmp ne i64 %18, 0
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
br label %23
23: ; preds = %84, %14
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%25 = call signext i8 (...) @getchar()
%26 = sext i8 %25 to i32
%27 = load i8, i8* @EOF
%28 = icmp ne i8 %25, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
switch i32 %26, label %88 [
i32 97, label %31
i32 100, label %44
i32 114, label %56
i32 119, label %70
i32 113, label %85
]
31: ; preds = %23
%32 = load i32, i32* @stdin
%33 = call i32 @fgets(i8* %6, i32 32, i32 %32)
%34 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5)
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %88
36: ; preds = %31
%37 = load i32, i32* %4
%38 = icmp ult i32 %37, %17
br i1 %38, label %39, label %88
39: ; preds = %36
%40 = zext i32 %37 to i64
%41 = getelementptr inbounds i8*, i8** %19, i64 %40
%42 = load i32, i32* %5
%43 = call i32 @allocate(i8** %41, i32 %42)
br label %84
44: ; preds = %23
%45 = load i32, i32* @stdin
%46 = call i32 @fgets(i8* %6, i32 32, i32 %45)
%47 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %88
49: ; preds = %44
%50 = load i32, i32* %4
%51 = icmp ult i32 %50, %17
br i1 %51, label %52, label %88
52: ; preds = %49
%53 = zext i32 %50 to i64
%54 = getelementptr inbounds i8*, i8** %19, i64 %53
%55 = call i32 @deallocate(i8** %54)
br label %84
56: ; preds = %23
%57 = load i32, i32* @stdin
%58 = call i32 @fgets(i8* %6, i32 32, i32 %57)
%59 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5)
%60 = icmp eq i32 %59, 2
br i1 %60, label %61, label %88
61: ; preds = %56
%62 = load i32, i32* %4
%63 = icmp ult i32 %62, %17
br i1 %63, label %64, label %88
64: ; preds = %61
%65 = zext i32 %62 to i64
%66 = getelementptr inbounds i8*, i8** %19, i64 %65
%67 = load i8*, i8** %66
%68 = load i32, i32* %5
%69 = call i32 @read_from_memory(i8* %67, i32 %68)
br label %84
70: ; preds = %23
%71 = load i32, i32* @stdin
%72 = call i32 @fgets(i8* %6, i32 32, i32 %71)
%73 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5)
%74 = icmp eq i32 %73, 2
br i1 %74, label %75, label %88
75: ; preds = %70
%76 = load i32, i32* %4
%77 = icmp ult i32 %76, %17
br i1 %77, label %78, label %88
78: ; preds = %75
%79 = zext i32 %76 to i64
%80 = getelementptr inbounds i8*, i8** %19, i64 %79
%81 = load i8*, i8** %80
%82 = load i32, i32* %5
%83 = call i32 @write_to_memory(i8* %81, i32 %82)
br label %84
84: ; preds = %78, %64, %52, %39
br label %23
85: ; preds = %23
%86 = inttoptr i64 %18 to i8*
%87 = call i32 @free(i8* %86)
br label %91
88: ; preds = %23, %70, %75, %56, %61, %44, %49, %31, %36
%89 = inttoptr i64 %18 to i8*
%90 = call i32 @free(i8* %89)
br label %91
91: ; preds = %88, %85, %10
%92 = phi i32 [ -1, %10 ], [ 0, %85 ], [ 1, %88 ]
ret i32 %92
}