#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 /*<<< orphan*/ SEEK_CUR;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ write(int, char *, int);
int make_data_blocks(int fd, int nr_blocks) {
  char *buffer;
  int i;
  buffer = (char *)calloc(4096, sizeof(char));
  i = 0;
  for (i = 0; i < nr_blocks; i++) {
    write(fd, buffer, 4096);
  }
  printf("Data Blocks End == %ld\n", lseek(fd, 0, SEEK_CUR));
  printf("Your filesystem successfully created\n");
  return 0;
}


x86 assembly (clang, -O0):
<make_data_blocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x1000,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119a <make_data_blocks+0x5a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1000,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <make_data_blocks+0x2f>
mov    -0x4(%rbp),%edi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_data_blocks>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
mov    $0x1000,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
test   %ebp,%ebp
jle    1185 <make_data_blocks+0x35>
mov    %rax,%rbx
nop
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebp
jne    1170 <make_data_blocks+0x20>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Data Blocks End == %ld\0A\00"
@SEEK_CUR = global i32 0
@.str.1 = [38 x i8] c"Your filesystem successfully created\0A\00"
define i32 @make_data_blocks(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i64 @calloc(i32 4096, i32 1)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %9
9: ; preds = %17, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i32, i32* %3
%15 = load i8*, i8** %5
%16 = call i32 @write(i32 %14, i8* %15, i32 4096)
br label %17
17: ; preds = %13
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %9
20: ; preds = %9
%21 = load i32, i32* %3
%22 = load i32, i32* @SEEK_CUR
%23 = call i32 @lseek(i32 %21, i32 0, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Data Blocks End == %ld\0A\00"
@SEEK_CUR = global i32 0
@str = [37 x i8] c"Your filesystem successfully created\00"
define i32 @make_data_blocks(i32 %0, i32 %1) {
%3 = tail call i64 @calloc(i32 4096, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %11
6: ; preds = %2, %6
%7 = phi i32 [ %9, %6 ], [ 0, %2 ]
%8 = tail call i32 @write(i32 %0, i8* %4, i32 4096)
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %6
11: ; preds = %6, %2
%12 = load i32, i32* @SEEK_CUR
%13 = tail call i32 @lseek(i32 %0, i32 0, i32 %12)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
ret i32 0
}