#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*/ uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fwrite(int /*<<< orphan*/ const *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
void export_configuration(char *filename, const uint8_t capacity[]) {
  FILE *ocv_file = fopen(filename, "wb");
  if (!ocv_file)
    error(-1, errno, "Error creating OCV file");
  size_t result = fwrite(capacity, 1, 16, ocv_file);
  if (result < 16) {
    fclose(ocv_file);
    error(-1, errno, "Error writing to OCV file");
  }
  fclose(ocv_file);
  printf("Export OCV table to %s OK\n", filename);
}


x86 assembly (clang, -O0):
<export_configuration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1199 <export_configuration+0x49>
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
lea    0xe6f(%rip),%rdx
call   1050 <error@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1070 <fwrite@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x10,-0x20(%rbp)
jae    11e2 <export_configuration+0x92>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
lea    0xe3e(%rip),%rdx
call   1050 <error@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rsi
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<export_configuration>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe9e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1189 <export_configuration+0x39>
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdx
mov    $0xffffffff,%edi
call   1050 <error@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
cmp    $0xf,%rax
ja     11c6 <export_configuration+0x76>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rdx
mov    $0xffffffff,%edi
call   1050 <error@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@errno = global i32 0
@.str.1 = [24 x i8] c"Error creating OCV file\00"
@.str.2 = [26 x i8] c"Error writing to OCV file\00"
@.str.3 = [27 x i8] c"Export OCV table to %s OK\0A\00"
define void @export_configuration(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
store i8* %0, i8** %3
store i32* %1, i32** %4
%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** %5
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i32 @error(i32 -1, i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
%15 = load i32*, i32** %4
%16 = load i32*, i32** %5
%17 = call i64 @fwrite(i32* %15, i32 1, i32 16, i32* %16)
store i64 %17, i64* %6
%18 = load i64, i64* %6
%19 = icmp ult i64 %18, 16
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i32*, i32** %5
%22 = call i32 @fclose(i32* %21)
%23 = load i32, i32* @errno
%24 = call i32 @error(i32 -1, i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %20, %14
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
%28 = load i8*, i8** %3
%29 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@errno = global i32 0
@.str.1 = [24 x i8] c"Error creating OCV file\00"
@.str.2 = [26 x i8] c"Error writing to OCV file\00"
@.str.3 = [27 x i8] c"Export OCV table to %s OK\0A\00"
define void @export_configuration(i8* %0, i32* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @error(i32 -1, i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = tail call i64 @fwrite(i32* %1, i32 1, i32 16, i32* %3)
%10 = icmp ult i64 %9, 16
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i32 @fclose(i32* %3)
%13 = load i32, i32* @errno
%14 = tail call i32 @error(i32 -1, i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %11, %8
%16 = tail call i32 @fclose(i32* %3)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %0)
ret void
}