#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*/ free(char *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
char *malloc(size_t);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
void writeFileData(char *name, char *output, size_t outputsize,
                   const char *fSuffix) {
  FILE *fp;
  if ((fSuffix != NULL) && (fSuffix[0] != '\0')) {
    char *savedName;
    size_t nameSize;
    nameSize = strlen(name) + strlen(fSuffix) + 1;
    savedName = malloc(nameSize);
    savedName[0] = '\0';
    strcat(savedName, name);
    strcat(savedName, fSuffix);
    fp = fopen(savedName, "w");
    free(savedName);
  } else
    fp = fopen(name, "w");
  fwrite(output, 1, outputsize, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<writeFileData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1218 <writeFileData+0xa8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1218 <writeFileData+0xa8>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    122c <writeFileData+0xbc>
mov    -0x8(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeFileData>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
test   %rcx,%rcx
je     11e8 <writeFileData+0x78>
mov    %rcx,%rbx
cmpb   $0x0,(%rcx)
je     11e8 <writeFileData+0x78>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    %r13d,%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1060 <malloc@plt>
mov    %rax,%r13
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
lea    0xe2d(%rip),%rsi
mov    %r13,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1030 <free@plt>
jmp    11fa <writeFileData+0x8a>
lea    0xe11(%rip),%rsi
mov    %r12,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
define void @writeFileData(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %42
14: ; preds = %4
%15 = load i8*, i8** %8
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %42
20: ; preds = %14
%21 = load i8*, i8** %5
%22 = call i32 @strlen(i8* %21)
%23 = load i8*, i8** %8
%24 = call i32 @strlen(i8* %23)
%25 = add nsw i32 %22, %24
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
store i64 %27, i64* %11
%28 = load i64, i64* %11
%29 = call i8* @malloc(i64 %28)
store i8* %29, i8** %10
%30 = load i8*, i8** %10
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 0, i8* %31
%32 = load i8*, i8** %10
%33 = load i8*, i8** %5
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = load i8*, i8** %10
%36 = load i8*, i8** %8
%37 = call i32 @strcat(i8* %35, i8* %36)
%38 = load i8*, i8** %10
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %39, i32** %9
%40 = load i8*, i8** %10
%41 = call i32 @free(i8* %40)
br label %45
42: ; preds = %14, %4
%43 = load i8*, i8** %5
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %44, i32** %9
br label %45
45: ; preds = %42, %20
%46 = load i8*, i8** %6
%47 = load i64, i64* %7
%48 = load i32*, i32** %9
%49 = call i32 @fwrite(i8* %46, i32 1, i64 %47, i32* %48)
%50 = load i32*, i32** %9
%51 = call i32 @fclose(i32* %50)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
define void @writeFileData(i8* %0, i8* nocapture %1, i64 %2, i8* %3) {
%5 = icmp eq i8* %3, null
br i1 %5, label %20, label %6
6: ; preds = %4
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i32 @strlen(i8* %3)
%12 = add i32 %10, 1
%13 = add i32 %12, %11
%14 = sext i32 %13 to i64
%15 = tail call i8* @malloc(i64 %14)
store i8 0, i8* %15
%16 = tail call i32 @strcat(i8* %15, i8* %0)
%17 = tail call i32 @strcat(i8* %15, i8* %3)
%18 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @free(i8* %15)
br label %22
20: ; preds = %6, %4
%21 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %9
%23 = phi i32* [ %18, %9 ], [ %21, %20 ]
%24 = tail call i32 @fwrite(i8* %1, i32 1, i64 %2, i32* %23)
%25 = tail call i32 @fclose(i32* %23)
ret void
}