#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*/ *stdout;
int Write_File(char *file, char *str) {
  FILE *arq;
  arq = fopen(file, "a");
  if (!arq) {
    fprintf(stdout, "error in Write_File() %s", file);
    return 0;
  }
  fprintf(arq, "%s\n", str);
  fclose(arq);
  return 1;
}


x86 assembly (clang, -O0):
<Write_File>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1185 <Write_File+0x55>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe8e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <Write_File+0x79>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Write_File>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1170 <Write_File+0x40>
mov    %rax,%rbx
lea    0xec5(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    118b <Write_File+0x5b>
mov    0x2e69(%rip),%rax
mov    (%rax),%rdi
lea    0xe81(%rip),%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@stdout = global i32* null
@.str.1 = [25 x i8] c"error in Write_File() %s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @Write_File(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32*, i32** @stdout
%13 = load i8*, i8** %4
%14 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 0, i32* %3
br label %21
15: ; preds = %2
%16 = load i32*, i32** %6
%17 = load i8*, i8** %5
%18 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i32*, i32** %6
%20 = call i32 @fclose(i32* %19)
store i32 1, i32* %3
br label %21
21: ; preds = %15, %11
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@stdout = global i32* null
@.str.1 = [25 x i8] c"error in Write_File() %s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @Write_File(i8* %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 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** @stdout
%7 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %11
8: ; preds = %2
%9 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%10 = tail call i32 @fclose(i32* %3)
br label %11
11: ; preds = %8, %5
%12 = phi i32 [ 1, %8 ], [ 0, %5 ]
ret i32 %12
}