#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(char *, int, int, int /*<<< orphan*/ *);
int cree(char *f2) {
  FILE *dest;
  int i;
  char octets[6];
  dest = fopen(f2, "wb");
  if (dest == NULL) {
    return (-1);
  }
  for (i = 0; i < 5; i++)
    octets[i] = 0;
  for (i = 0; i < 1024; i++) {
    fwrite(octets, 1, 5, dest);
  }
  fclose(dest);
  return (4096);
}


x86 assembly (clang, -O0):
<cree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1167 <cree+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <cree+0xa8>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    118f <cree+0x5f>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x22(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <cree+0x3e>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jge    11c8 <cree+0x98>
lea    -0x22(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x5,%edx
call   1050 <fwrite@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1196 <cree+0x66>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1000,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cree>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1199 <cree+0x69>
mov    %rax,%rbx
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    $0x400,%ebp
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
add    $0xffffffff,%ebp
jne    1170 <cree+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1000,%eax
jmp    119e <cree+0x6e>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
define i32 @cree(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [6 x i8]
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %37
12: ; preds = %1
store i32 0, i32* %5
br label %13
13: ; preds = %20, %12
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 5
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %16
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %13
23: ; preds = %13
store i32 0, i32* %5
br label %24
24: ; preds = %31, %23
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 1024
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%29 = load i32*, i32** %4
%30 = call i32 @fwrite(i8* %28, i32 1, i32 5, i32* %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %24
34: ; preds = %24
%35 = load i32*, i32** %4
%36 = call i32 @fclose(i32* %35)
store i32 4096, i32* %2
br label %37
37: ; preds = %34, %11
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
define i32 @cree(i8* nocapture %0) {
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %11, %8 ], [ 0, %6 ]
%10 = call i32 @fwrite(i8* %3, i32 1, i32 5, i32* %4)
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, 1024
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = tail call i32 @fclose(i32* %4)
br label %15
15: ; preds = %1, %13
%16 = phi i32 [ 4096, %13 ], [ -1, %1 ]
ret i32 %16
}