#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 */

/* Variables and functions */
int chdir(char *);
int /*<<< orphan*/ close(int);
int creat(char *, int);
int write(int, char *, int);
void GPF_init(char *f) {
  int fd, r, nc;
  r = chdir(".nife");
  if ((fd = creat(f, 0600)) != -1) {
    nc = write(fd, "# Nife auto-generated GNUplot file !\n", 37);
    close(fd);
  }
  if (r == 0)
    r = chdir("..");
}


x86 assembly (clang, -O0):
<GPF_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1040 <chdir@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x180,%esi
call   1060 <creat@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     1194 <GPF_init+0x54>
mov    -0xc(%rbp),%edi
lea    0xe87(%rip),%rsi
mov    $0x25,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11ad <GPF_init+0x6d>
lea    0xe87(%rip),%rdi
call   1040 <chdir@plt>
mov    %eax,-0x10(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPF_init>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbp
lea    0xeb3(%rip),%rdi
call   1040 <chdir@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    $0x180,%esi
call   1060 <creat@plt>
cmp    $0xffffffff,%eax
je     1182 <GPF_init+0x42>
mov    %eax,%ebp
lea    0xe97(%rip),%rsi
mov    %eax,%edi
mov    $0x25,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
je     118d <GPF_init+0x4d>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe98(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <chdir@plt>

LLVM IR (-O0):
@.str = [6 x i8] c".nife\00"
@.str.1 = [38 x i8] c"# Nife auto-generated GNUplot file !\0A\00"
@.str.2 = [3 x i8] c"..\00"
define void @GPF_init(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %4
%7 = load i8*, i8** %2
%8 = call i32 @creat(i8* %7, i32 384)
store i32 %8, i32* %3
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 37)
store i32 %12, i32* %5
%13 = load i32, i32* %3
%14 = call i32 @close(i32 %13)
br label %15
15: ; preds = %10, %1
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %19, i32* %4
br label %20
20: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c".nife\00"
@.str.1 = [38 x i8] c"# Nife auto-generated GNUplot file !\0A\00"
@.str.2 = [3 x i8] c"..\00"
define void @GPF_init(i8* %0) {
%2 = tail call i32 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @creat(i8* %0, i32 384)
%4 = icmp eq i32 %3, -1
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 @write(i32 %3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 37)
%7 = tail call i32 @close(i32 %3)
br label %8
8: ; preds = %5, %1
%9 = icmp eq i32 %2, 0
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
ret void
}