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

/* Variables and functions */
int count_data(int, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int load_data(char *, int *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int data[512 + 1] = {-1};
  int arg_cnt;
  int arg_num;
  int ret;
  if ((argc < 2) || (argc > 16 + 1)) {
    fprintf(stderr, "Invalid arguments.\n");
    usage();
    exit(-1);
  }
  ret = load_data(argv[1], data);
  if (ret < 0) {
    exit(-1);
  }
  for (arg_cnt = 2; arg_cnt < argc; arg_cnt++) {
    arg_num = (int)strtol(argv[arg_cnt], NULL, 10);
    ret = count_data(arg_num, data);
    printf("%d %d\n", arg_num, ret);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x804,%edx
call   1050 <memset@plt>
movl   $0xffffffff,-0x820(%rbp)
ff ff ff
cmpl   $0x2,-0x8(%rbp)
jl     11ca <main+0x4a>
cmpl   $0x11,-0x8(%rbp)
jle    11f0 <main+0x70>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1090 <usage@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x820(%rbp),%rsi
call   1030 <load_data@plt>
mov    %eax,-0x82c(%rbp)
cmpl   $0x0,-0x82c(%rbp)
jge    1221 <main+0xa1>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x2,-0x824(%rbp)
mov    -0x824(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a1 <main+0x121>
mov    -0x10(%rbp),%rax
movslq -0x824(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x828(%rbp)
mov    -0x828(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   1080 <count_data@plt>
mov    %eax,-0x82c(%rbp)
mov    -0x828(%rbp),%esi
mov    -0x82c(%rbp),%edx
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x824(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x824(%rbp)
jmp    122b <main+0xab>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r12
mov    %edi,%r14d
mov    %rsp,%rdi
mov    $0x804,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0xffffffff,(%rsp)
lea    -0x12(%r14),%eax
cmp    $0xffffffef,%eax
jbe    1226 <main+0xa6>
mov    0x8(%r12),%rdi
mov    %rsp,%rsi
call   1030 <load_data@plt>
test   %eax,%eax
js     1242 <main+0xc2>
cmp    $0x3,%r14d
jb     1212 <main+0x92>
mov    %r14d,%r13d
mov    $0x2,%ebp
mov    %rsp,%r14
lea    0xe35(%rip),%r15
nop
mov    (%r12,%rbp,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%rbx
mov    %ebx,%edi
mov    %r14,%rsi
call   1080 <count_data@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11e0 <main+0x60>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <usage@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Invalid arguments.\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [513 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [513 x i32]* %6 to i8*
%11 = bitcast i8* %10 to <{ i32, [512 x i32] }>*
%12 = getelementptr inbounds <{ i32, [512 x i32] }>, <{ i32, [512 x i32] }>* %11, i32 0, i32 0
store i32 -1, i32* %12
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 17
br i1 %17, label %18, label %23
18: ; preds = %15, %2
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (...) @usage()
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %15
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = getelementptr inbounds [513 x i32], [513 x i32]* %6, i64 0, i64 0
%28 = call i32 @load_data(i8* %26, i32* %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %23
store i32 2, i32* %7
br label %34
34: ; preds = %52, %33
%35 = load i32, i32* %7
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %55
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strtol(i8* %43, i32* null, i32 10)
%45 = trunc i64 %44 to i32
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = getelementptr inbounds [513 x i32], [513 x i32]* %6, i64 0, i64 0
%48 = call i32 @count_data(i32 %46, i32* %47)
store i32 %48, i32* %9
%49 = load i32, i32* %8
%50 = load i32, i32* %9
%51 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %50)
br label %52
52: ; preds = %38
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %34
55: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Invalid arguments.\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [513 x i32]
%4 = bitcast [513 x i32]* %3 to i8*
%5 = getelementptr inbounds [513 x i32], [513 x i32]* %3, i64 0, i64 0
store i32 -1, i32* %5
%6 = add i32 %0, -18
%7 = icmp ult i32 %6, -16
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (...) @usage()
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @load_data(i8* %15, i32* %5)
%17 = icmp slt i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = icmp ugt i32 %0, 2
br i1 %19, label %20, label %34
20: ; preds = %18
%21 = zext i32 %0 to i64
br label %24
22: ; preds = %13
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %20, %24
%25 = phi i64 [ 2, %20 ], [ %32, %24 ]
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @strtol(i8* nocapture %27, i32* null, i32 10)
%29 = trunc i64 %28 to i32
%30 = call i32 @count_data(i32 %29, i32* %5)
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30)
%32 = add nuw nsw i64 %25, 1
%33 = icmp eq i64 %32, %21
br i1 %33, label %34, label %24
34: ; preds = %24, %18
ret i32 0
}