#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ *stderr;
void SaveFile(char path[], char content[], char tipo[]) {
  FILE *file;
  if ((file = fopen(path, tipo)) == NULL) {
    fprintf(stderr, "Erro: Arquivo Invalido!\r\nEndereco: %s\r\n", path);
    return;
  }
  fprintf(file, "%s\r\n", content);
  fclose(file);
  file = NULL;
}


x86 assembly (clang, -O0):
<SaveFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117e <SaveFile+0x4e>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11a3 <SaveFile+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x20(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SaveFile>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     116a <SaveFile+0x3a>
mov    %rax,%rbx
lea    0xed1(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%rdi
lea    0xe85(%rip),%rsi
mov    %r15,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [40 x i8] c"Erro: Arquivo Invalido!\0D\0AEndereco: %s\0D\0A\00"
@.str.1 = [5 x i8] c"%s\0D\0A\00"
define void @SaveFile(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %6
%10 = call i32* @fopen(i8* %8, i8* %9)
store i32* %10, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32*, i32** @stderr
%14 = load i8*, i8** %4
%15 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %22
16: ; preds = %3
%17 = load i32*, i32** %7
%18 = load i8*, i8** %5
%19 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32*, i32** %7
%21 = call i32 @fclose(i32* %20)
store i32* null, i32** %7
br label %22
22: ; preds = %16, %12
ret void
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [40 x i8] c"Erro: Arquivo Invalido!\0D\0AEndereco: %s\0D\0A\00"
@.str.1 = [5 x i8] c"%s\0D\0A\00"
define void @SaveFile(i8* %0, i8* %1, i8* nocapture %2) {
%4 = tail call i32* @fopen(i8* %0, i8* %2)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32*, i32** @stderr
%8 = tail call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %12
9: ; preds = %3
%10 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%11 = tail call i32 @fclose(i32* %4)
br label %12
12: ; preds = %9, %6
ret void
}