#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
void writeOutput(char *buff, char *f) {
  FILE *fp;
  fp = fopen(f, "w");
  printf("client: writing server data back to file\n\n");
  if (fputs(buff, fp) == EOF) {
    printf("Failed to write server data to output");
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<writeOutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%rax
jne    1199 <writeOutput+0x59>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeOutput>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe9f(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%rax
jne    119b <writeOutput+0x4b>
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [43 x i8] c"client: writing server data back to file\0A\0A\00"
@EOF = global i64 0
@.str.2 = [38 x i8] c"Failed to write server data to output\00"
define void @writeOutput(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%9 = load i8*, i8** %3
%10 = load i32*, i32** %5
%11 = call i64 @fputs(i8* %9, i32* %10)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = load i32*, i32** %5
%18 = call i32 @fclose(i32* %17)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@EOF = global i64 0
@.str.2 = [38 x i8] c"Failed to write server data to output\00"
@str = [42 x i8] c"client: writing server data back to file\0A\00"
define void @writeOutput(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%5 = tail call i64 @fputs(i8* %0, i32* %3)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = tail call i32 @fclose(i32* %3)
ret void
}