#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*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
FILE *openReportFile(char *name, const char *fSuffix) {
  FILE *file;
  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);
    file = fopen(savedName, "w");
    free(savedName);
  } else
    file = fopen(name, "w");
  return file;
}


x86 assembly (clang, -O0):
<openReportFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f0 <openReportFile+0xa0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f0 <openReportFile+0xa0>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    1204 <openReportFile+0xb4>
mov    -0x8(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openReportFile>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rsi,%rsi
je     11c5 <openReportFile+0x75>
mov    %rsi,%rbx
cmpb   $0x0,(%rsi)
je     11c5 <openReportFile+0x75>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1050 <malloc@plt>
mov    %rax,%r15
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
lea    0xe57(%rip),%rsi
mov    %r15,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe34(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <fopen@plt>

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

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