#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*/ fwrite(unsigned char *, size_t, int, int /*<<< orphan*/ *);
int create_fs(char *name, size_t blocksize) {
  FILE *fs = fopen(name, "r");
  if (fs != NULL) {
    fclose(fs);
    return -1;
  }
  fs = fopen(name, "w+");
  unsigned char arr[200 * blocksize];
  fwrite(arr, blocksize, 200, fs);
  fclose(fs);
  return 0;
}


x86 assembly (clang, -O0):
<create_fs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1174 <create_fs+0x44>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <create_fs+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
imul   $0xc8,%rax,%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0xc8,%edx
call   1050 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@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):
<create_fs>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb9(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1160 <create_fs+0x30>
mov    %rax,%rdi
call   1030 <fclose@plt>
mov    $0xffffffff,%eax
jmp    11aa <create_fs+0x7a>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r15
imul   $0xc8,%r14,%rax
mov    %rsp,%rdi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
mov    %r14,%rsi
mov    $0xc8,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
mov    %r15,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"w+\00"
define i32 @create_fs(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** %6
%15 = call i32 @fclose(i32* %14)
store i32 -1, i32* %3
br label %29
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i64, i64* %5
%20 = mul i64 200, %19
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %7
%22 = alloca i8, i64 %20
store i64 %20, i64* %8
%23 = load i64, i64* %5
%24 = load i32*, i32** %6
%25 = call i32 @fwrite(i8* %22, i64 %23, i32 200, i32* %24)
%26 = load i32*, i32** %6
%27 = call i32 @fclose(i32* %26)
store i32 0, i32* %3
%28 = load i8*, i8** %7
br label %29
29: ; preds = %16, %13
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"w+\00"
define i32 @create_fs(i8* nocapture %0, i64 %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @fclose(i32* %3)
br label %14
7: ; preds = %2
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = mul i64 %1, 200
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = call i32 @fwrite(i8* %11, i64 %1, i32 200, i32* %8)
%13 = tail call i32 @fclose(i32* %8)
tail call void @llvm.stackrestore(i8* %10)
br label %14
14: ; preds = %7, %5
%15 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %15
}