#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(int *, int, unsigned int, int /*<<< orphan*/ *);
int *malloc(int);
int /*<<< orphan*/ print_usage();
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ srand(int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  int i;
  unsigned int n;
  int *data;
  FILE *file;
  int number_length = 0;
  char get_number[10];
  n = 1024;
  if (argc > 1) {
    for (i = 1; i < argc;) {
      if (strcmp(argv[i], "-s") == 0) {
        n = atoi(argv[i + 1]);
        i += 2;
      } else {
        print_usage();
        return 0;
      }
    }
  }
  srand(3838);
  data = malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    data[i] = rand() % 1000 + 1;
    sprintf(get_number, "%d", data[i]);
    if (strlen(get_number) > number_length)
      number_length = strlen(get_number);
  }
  file = fopen("input.data", "w");
  fwrite(&number_length, sizeof(int), 1, file);
  fwrite(data, sizeof(int), n, file);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x400,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1257 <main+0xa7>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1252 <main+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdfc(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123a <main+0x8a>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    124d <main+0x9d>
mov    $0x0,%al
call   10c0 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1342 <main+0x192>
jmp    11e5 <main+0x35>
jmp    1257 <main+0xa7>
mov    $0xefe,%edi
call   1050 <srand@plt>
mov    -0x18(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    12ef <main+0x13f>
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x36(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd4a(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x36(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x2c(%rbp),%eax
jle    12dc <main+0x12c>
lea    -0x36(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    12e1 <main+0x131>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    127a <main+0xca>
lea    0xd10(%rip),%rdi
lea    0xd14(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
call   10b0 <fwrite@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x400,%ebx
cmp    $0x2,%edi
jl     120a <main+0x5a>
mov    %rsi,%r15
mov    %edi,%ebp
mov    $0x1,%ebx
lea    0xe27(%rip),%r14
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12fd <main+0x14d>
add    $0x2,%rbx
cmp    %rbp,%rbx
jb     11e0 <main+0x30>
mov    -0x8(%r15,%rbx,8),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    $0xefe,%edi
call   1050 <srand@plt>
lea    0x0(,%rbx,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r12
test   %ebx,%ebx
mov    %rbx,0x10(%rsp)
je     12ab <main+0xfb>
mov    %ebx,%r13d
lea    0xdcd(%rip),%r15
lea    0x1e(%rsp),%rbx
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1259 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14
cmp    %r14,%r13
je     12ad <main+0xfd>
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    %edx,(%r12,%r14,4)
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %ebp,%eax
jle    1250 <main+0xa0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
jmp    1250 <main+0xa0>
xor    %ebp,%ebp
mov    %ebp,0xc(%rsp)
lea    0xd4e(%rip),%rdi
lea    0xd52(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
mov    %r12,%rdi
mov    $0x4,%esi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1304 <main+0x154>
xor    %eax,%eax
call   10c0 <print_usage@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"input.data\00"
@.str.3 = [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 i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 1024, i32* %7
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %41
14: ; preds = %2
store i32 1, i32* %6
br label %15
15: ; preds = %39, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %19
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %28, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %7
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 2
store i32 %36, i32* %6
br label %39
37: ; preds = %19
%38 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %88
39: ; preds = %27
br label %15
40: ; preds = %15
br label %41
41: ; preds = %40, %2
%42 = call i32 @srand(i32 3838)
%43 = load i32, i32* %7
%44 = zext i32 %43 to i64
%45 = mul i64 4, %44
%46 = trunc i64 %45 to i32
%47 = call i32* @malloc(i32 %46)
store i32* %47, i32** %8
store i32 0, i32* %6
br label %48
48: ; preds = %75, %41
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = icmp ult i32 %49, %50
br i1 %51, label %52, label %78
52: ; preds = %48
%53 = call i32 (...) @rand()
%54 = srem i32 %53, 1000
%55 = add nsw i32 %54, 1
%56 = load i32*, i32** %8
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %56, i64 %58
store i32 %55, i32* %59
%60 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%61 = load i32*, i32** %8
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = load i32, i32* %64
%66 = call i32 @sprintf(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%68 = call i32 @strlen(i8* %67)
%69 = load i32, i32* %10
%70 = icmp sgt i32 %68, %69
br i1 %70, label %71, label %74
71: ; preds = %52
%72 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%73 = call i32 @strlen(i8* %72)
store i32 %73, i32* %10
br label %74
74: ; preds = %71, %52
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %48
78: ; preds = %48
%79 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %79, i32** %9
%80 = load i32*, i32** %9
%81 = call i32 @fwrite(i32* %10, i32 4, i32 1, i32* %80)
%82 = load i32*, i32** %8
%83 = load i32, i32* %7
%84 = load i32*, i32** %9
%85 = call i32 @fwrite(i32* %82, i32 4, i32 %83, i32* %84)
%86 = load i32*, i32** %9
%87 = call i32 @fclose(i32* %86)
store i32 0, i32* %3
br label %88
88: ; preds = %78, %37
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"input.data\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %16
%11 = phi i64 [ 1, %8 ], [ %17, %16 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = add nuw nsw i64 %11, 2
%18 = icmp ult i64 %17, %9
br i1 %18, label %10, label %21
19: ; preds = %10
%20 = tail call i32 (...) @print_usage()
br label %56
21: ; preds = %16
%22 = add nuw nsw i64 %11, 1
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
br label %26
26: ; preds = %21, %2
%27 = phi i32 [ 1024, %2 ], [ %25, %21 ]
%28 = tail call i32 @srand(i32 3838)
%29 = shl i32 %27, 2
%30 = tail call i32* @malloc(i32 %29)
%31 = icmp eq i32 %27, 0
br i1 %31, label %50, label %32
32: ; preds = %26
%33 = zext i32 %27 to i64
br label %34
34: ; preds = %32, %46
%35 = phi i64 [ 0, %32 ], [ %48, %46 ]
%36 = phi i32 [ 0, %32 ], [ %47, %46 ]
%37 = call i32 (...) @rand()
%38 = srem i32 %37, 1000
%39 = add nsw i32 %38, 1
%40 = getelementptr inbounds i32, i32* %30, i64 %35
store i32 %39, i32* %40
%41 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%42 = call i32 @strlen(i8* %6)
%43 = icmp sgt i32 %42, %36
br i1 %43, label %44, label %46
44: ; preds = %34
%45 = call i32 @strlen(i8* %6)
br label %46
46: ; preds = %34, %44
%47 = phi i32 [ %36, %34 ], [ %45, %44 ]
%48 = add nuw nsw i64 %35, 1
%49 = icmp eq i64 %48, %33
br i1 %49, label %50, label %34
50: ; preds = %46, %26
%51 = phi i32 [ 0, %26 ], [ %47, %46 ]
store i32 %51, i32* %3
%52 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %52)
%54 = call i32 @fwrite(i32* %30, i32 4, i32 %27, i32* %52)
%55 = call i32 @fclose(i32* %52)
br label %56
56: ; preds = %50, %19
ret i32 0
}