#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
void init(int num) {
  FILE *fp;
  int n = 0;
  char s[2000];
  fp = fopen("data/ec.db", "w");
  while (n < num) {
    s[n++] = '0';
  }
  for (n = 0; n < num; n++)
    fprintf(fp, "%c", s[n]);
  fclose(fp);
}


x86 assembly (clang, -O0):
<init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb4(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1182 <init+0x52>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movb   $0x30,-0x7f0(%rbp,%rax,1)
30
jmp    115c <init+0x2c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bf <init+0x8f>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
lea    0xe69(%rip),%rsi
movsbl -0x7f0(%rbp,%rax,1),%edx
ff
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <init+0x59>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
push   %r15
push   %r14
push   %rbx
sub    $0x7d0,%rsp
mov    %edi,%ebx
lea    0xeab(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    1195 <init+0x55>
mov    %ebx,%r15d
mov    %rsp,%rdi
mov    $0x30,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%rsp,%rbx,1),%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <init+0x40>
mov    %r14,%rdi
add    $0x7d0,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"data/ec.db\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%c\00"
define void @init(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [2000 x i8]
store i32 %0, i32* %2
store i32 0, i32* %4
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
br label %7
7: ; preds = %11, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %14
store i8 48, i8* %15
br label %7
16: ; preds = %7
store i32 0, i32* %4
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32*, i32** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %17
31: ; preds = %17
%32 = load i32*, i32** %3
%33 = call i32 @fclose(i32* %32)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"data/ec.db\00"
@.str.1 = [2 x i8] c"w\00"
define void @init(i32 %0) {
%2 = alloca [2000 x i8]
%3 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %18
6: ; preds = %1
%7 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%8 = zext i32 %0 to i64
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %16, %10 ]
%12 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = tail call i32 @fputc(i32 %14, i32* %4)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %10, %1
%19 = tail call i32 @fclose(i32* %4)
ret void
}