#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int /*<<< orphan*/ printf(char *);
void write_metadata(char *fileName, int totalSize, int parityBlockNum,
                    int nativeBlockNum) {
  FILE *fp;
  if ((fp = fopen(fileName, "wb")) == NULL) {
    printf("Can not open META file!\n");
    exit(0);
  }
  fprintf(fp, "%d\n", totalSize);
  fprintf(fp, "%d %d\n", parityBlockNum, nativeBlockNum);
  fclose(fp);
}


x86 assembly (clang, -O0):
<write_metadata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1196 <write_metadata+0x46>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_metadata>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11af <write_metadata+0x5f>
mov    %rax,%rbx
lea    0xe8c(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [25 x i8] c"Can not open META file!\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [7 x i8] c"%d %d\0A\00"
define void @write_metadata(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %9
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %4
%17 = load i32*, i32** %9
%18 = load i32, i32* %6
%19 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %9
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %22)
%24 = load i32*, i32** %9
%25 = call i32 @fclose(i32* %24)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [7 x i8] c"%d %d\0A\00"
@str = [24 x i8] c"Can not open META file!\00"
define void @write_metadata(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %4
%11 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %1)
%12 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %2, i32 %3)
%13 = tail call i32 @fclose(i32* %5)
ret void
}