#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 PATH_MAX;
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int /*<<< orphan*/);
int write_file(char *, char *);
int main(int argc, char **argv) {
  int i = 0;
  int spaceleft = 0;
  char namebase[] = "binzero";
  char filename[PATH_MAX];
  char wipeage[8192];
  memset(wipeage, 0, 8192);
  printf("ffs initializing...\t\t\n");
  printf("ffs filling fs...\n");
  do {
    snprintf(filename, PATH_MAX, "%s_%.5d", namebase, i++);
    printf("calling write_file() on %s\n", filename);
    spaceleft = write_file(filename, wipeage);
  } while (spaceleft != 0);
  printf("ffs succeeded. or unknown error ;) XD\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movabs $0x6f72657a6e6962,%rax
mov    %rax,-0x20(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x2038(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1060 <memset@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2038(%rbp),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    %r8d,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe37(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x2038(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2038(%rbp),%rdi
lea    -0x2030(%rbp),%rsi
call   1040 <write_file@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11d3 <main+0x93>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    %rsp,-0x30(%rbp)
movabs $0x6f72657a6e6962,%rax
mov    %rax,-0x38(%rbp)
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x2040(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1070 <memset@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3e(%rip),%r15
lea    -0x38(%rbp),%r12
lea    0xe3b(%rip),%r13
xor    %r8d,%r8d
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
lea    0x1(%r8),%r14d
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    -0x2040(%rbp),%rsi
call   1050 <write_file@plt>
mov    %r14d,%r8d
test   %eax,%eax
jne    11d0 <main+0x80>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
mov    -0x30(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.namebase = [8 x i8] c"binzero\00"
@PATH_MAX = global i32 0
@.str = [23 x i8] c"ffs initializing...\09\09\0A\00"
@.str.1 = [19 x i8] c"ffs filling fs...\0A\00"
@.str.2 = [8 x i8] c"%s_%.5d\00"
@.str.3 = [28 x i8] c"calling write_file() on %s\0A\00"
@.str.4 = [39 x i8] c"ffs succeeded. or unknown error ;) XD\0A\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 [8 x i8]
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [8192 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%12 = bitcast [8 x i8]* %8 to i8*
%13 = load i32, i32* @PATH_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i8, i64 %14
store i64 %14, i64* %10
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i32 8192)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %30, %2
%22 = load i32, i32* @PATH_MAX
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
%26 = call i32 @snprintf(i8* %16, i32 %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %24)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%28 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%29 = call i32 @write_file(i8* %16, i8* %28)
store i32 %29, i32* %7
br label %30
30: ; preds = %21
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, 0
br i1 %32, label %21, label %33
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
%35 = load i8*, i8** %9
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str.2 = [8 x i8] c"%s_%.5d\00"
@.str.3 = [28 x i8] c"calling write_file() on %s\0A\00"
@str = [22 x i8] c"ffs initializing...\09\09\00"
@str.5 = [18 x i8] c"ffs filling fs...\00"
@str.6 = [38 x i8] c"ffs succeeded. or unknown error ;) XD\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca [8192 x i8]
%5 = bitcast i64* %3 to i8*
store i64 31369502586202466, i64* %3
%6 = load i32, i32* @PATH_MAX
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 8192)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
br label %14
14: ; preds = %14, %2
%15 = phi i32 [ 0, %2 ], [ %17, %14 ]
%16 = load i32, i32* @PATH_MAX
%17 = add nuw nsw i32 %15, 1
%18 = call i32 @snprintf(i8* %9, i32 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %15)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%20 = call i32 @write_file(i8* %9, i8* %10)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %14
22: ; preds = %14
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}