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

/* Variables and functions */
int /*<<< orphan*/ array_with_types_r(int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ array_with_types_rw(int, size_t, int /*<<< orphan*/ *);
int atoi(char *);
int /*<<< orphan*/ close(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int opcnt;
  FILE *devnull;
  size_t arrsize;
  if (argc < 2) {
    printf("usage: %s OPCNT\n", argv[0]);
    exit(0);
  }
  opcnt = atoi(argv[1]);
  arrsize = opcnt + 1;
  devnull = fopen("/dev/null", "w");
  array_with_types_r(opcnt, arrsize, devnull);
  array_with_types_rw(opcnt, arrsize, devnull);
  close(devnull);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11aa <main+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
lea    0xe44(%rip),%rdi
lea    0xe47(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <array_with_types_r@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <array_with_types_rw@plt>
mov    -0x20(%rbp),%rdi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x1,%edi
jle    11cf <main+0x5f>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
lea    0x1(%r15),%eax
movslq %eax,%r14
lea    0xe7d(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <array_with_types_r@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <array_with_types_rw@plt>
mov    %rbx,%rdi
call   1050 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    (%rsi),%rsi
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"usage: %s OPCNT\0A\00"
@.str.1 = [10 x i8] c"/dev/null\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
store i64 %24, i64* %8
%25 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %25, i32** %7
%26 = load i32, i32* %6
%27 = load i64, i64* %8
%28 = load i32*, i32** %7
%29 = call i32 @array_with_types_r(i32 %26, i64 %27, i32* %28)
%30 = load i32, i32* %6
%31 = load i64, i64* %8
%32 = load i32*, i32** %7
%33 = call i32 @array_with_types_rw(i32 %30, i64 %31, i32* %32)
%34 = load i32*, i32** %7
%35 = call i32 @close(i32* %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"usage: %s OPCNT\0A\00"
@.str.1 = [10 x i8] c"/dev/null\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @array_with_types_r(i32 %11, i64 %13, i32* %14)
%16 = tail call i32 @array_with_types_rw(i32 %11, i64 %13, i32* %14)
%17 = tail call i32 @close(i32* %14)
ret i32 0
}