#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*/ SEEK_SET;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
FILE *eeprom_create_empty_file() {
  FILE *fp = fopen("EEPROM.DAT", "w+b");
  int i;
  if (fp) {
    for (i = 0; i < 4096; i++) {
      fputc(0, fp);
    }
    fseek(fp, 0, SEEK_SET);
  }
  return fp;
}


x86 assembly (clang, -O0):
<eeprom_create_empty_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119b <eeprom_create_empty_file+0x6b>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1000,-0xc(%rbp)
jge    1187 <eeprom_create_empty_file+0x57>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1161 <eeprom_create_empty_file+0x31>
mov    -0x8(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_create_empty_file>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1182 <eeprom_create_empty_file+0x52>
mov    $0x1000,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebp
jne    1160 <eeprom_create_empty_file+0x30>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"EEPROM.DAT\00"
@.str.1 = [4 x i8] c"w+b\00"
@SEEK_SET = global i32 0
define i32* @eeprom_create_empty_file() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %20
6: ; preds = %0
store i32 0, i32* %2
br label %7
7: ; preds = %13, %6
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 4096
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32*, i32** %1
%12 = call i32 @fputc(i32 0, i32* %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %7
16: ; preds = %7
%17 = load i32*, i32** %1
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @fseek(i32* %17, i32 0, i32 %18)
br label %20
20: ; preds = %16, %0
%21 = load i32*, i32** %1
ret i32* %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"EEPROM.DAT\00"
@.str.1 = [4 x i8] c"w+b\00"
@SEEK_SET = global i32 0
define noalias i32* @eeprom_create_empty_file() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %11, label %3
3: ; preds = %0, %3
%4 = phi i32 [ %6, %3 ], [ 0, %0 ]
%5 = tail call i32 @fputc(i32 0, i32* %1)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 4096
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %1, i32 0, i32 %9)
br label %11
11: ; preds = %8, %0
ret i32* %1
}