#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 */
struct sourcefile {
  int dummy;
};

/* Variables and functions */
struct sourcefile *AllocFile();
int /*<<< orphan*/ ReportError(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
struct sourcefile *Setfile(struct sourcefile *, struct sourcefile *, char *);
struct sourcefile *Newfile(struct sourcefile *curfile, char *fname) {
  struct sourcefile *nfile;
  if (curfile == NULL) {
    if ((curfile = AllocFile()) == NULL) {
      ReportError(NULL, 0, 3);
      return (NULL);
    } else
      return (Setfile(NULL, curfile, fname));
  } else if ((nfile = AllocFile()) == NULL) {
    ReportError(NULL, 0, 3);
    return (curfile);
  } else
    return (Setfile(curfile, nfile, fname));
}


x86 assembly (clang, -O0):
<Newfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1197 <Newfile+0x67>
mov    $0x0,%al
call   1050 <AllocFile@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117d <Newfile+0x4d>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <ReportError@plt>
movq   $0x0,-0x8(%rbp)
jmp    11de <Newfile+0xae>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
call   1040 <Setfile@plt>
mov    %rax,-0x8(%rbp)
jmp    11de <Newfile+0xae>
mov    $0x0,%al
call   1050 <AllocFile@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11c9 <Newfile+0x99>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <ReportError@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11de <Newfile+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <Setfile@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Newfile>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <AllocFile@plt>
test   %rbx,%rbx
je     1150 <Newfile+0x20>
test   %rax,%rax
je     116b <Newfile+0x3b>
mov    %rbx,%rdi
jmp    1157 <Newfile+0x27>
test   %rax,%rax
je     1169 <Newfile+0x39>
xor    %edi,%edi
mov    %rax,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <Setfile@plt>
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <ReportError@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sourcefile = type { i32 }
define %struct.sourcefile* @Newfile(%struct.sourcefile* %0, i8* %1) {
%3 = alloca %struct.sourcefile*
%4 = alloca %struct.sourcefile*
%5 = alloca i8*
%6 = alloca %struct.sourcefile*
store %struct.sourcefile* %0, %struct.sourcefile** %4
store i8* %1, i8** %5
%7 = load %struct.sourcefile*, %struct.sourcefile** %4
%8 = icmp eq %struct.sourcefile* %7, null
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = call %struct.sourcefile* (...) @AllocFile()
store %struct.sourcefile* %10, %struct.sourcefile** %4
%11 = icmp eq %struct.sourcefile* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @ReportError(i32* null, i32 0, i32 3)
store %struct.sourcefile* null, %struct.sourcefile** %3
br label %29
14: ; preds = %9
%15 = load %struct.sourcefile*, %struct.sourcefile** %4
%16 = load i8*, i8** %5
%17 = call %struct.sourcefile* @Setfile(%struct.sourcefile* null, %struct.sourcefile* %15, i8* %16)
store %struct.sourcefile* %17, %struct.sourcefile** %3
br label %29
18: ; preds = %2
%19 = call %struct.sourcefile* (...) @AllocFile()
store %struct.sourcefile* %19, %struct.sourcefile** %6
%20 = icmp eq %struct.sourcefile* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @ReportError(i32* null, i32 0, i32 3)
%23 = load %struct.sourcefile*, %struct.sourcefile** %4
store %struct.sourcefile* %23, %struct.sourcefile** %3
br label %29
24: ; preds = %18
%25 = load %struct.sourcefile*, %struct.sourcefile** %4
%26 = load %struct.sourcefile*, %struct.sourcefile** %6
%27 = load i8*, i8** %5
%28 = call %struct.sourcefile* @Setfile(%struct.sourcefile* %25, %struct.sourcefile* %26, i8* %27)
store %struct.sourcefile* %28, %struct.sourcefile** %3
br label %29
29: ; preds = %24, %21, %14, %12
%30 = load %struct.sourcefile*, %struct.sourcefile** %3
ret %struct.sourcefile* %30
}

LLVM IR (-O2):
%struct.sourcefile = type { i32 }
define %struct.sourcefile* @Newfile(%struct.sourcefile* %0, i8* %1) {
%3 = icmp eq %struct.sourcefile* %0, null
%4 = tail call %struct.sourcefile* (...) @AllocFile()
%5 = icmp eq %struct.sourcefile* %4, null
br i1 %3, label %6, label %11
6: ; preds = %2
br i1 %5, label %7, label %9
7: ; preds = %6
%8 = tail call i32 @ReportError(i32* null, i32 0, i32 3)
br label %16
9: ; preds = %6
%10 = tail call %struct.sourcefile* @Setfile(%struct.sourcefile* null, %struct.sourcefile* %4, i8* %1)
br label %16
11: ; preds = %2
br i1 %5, label %12, label %14
12: ; preds = %11
%13 = tail call i32 @ReportError(i32* null, i32 0, i32 3)
br label %16
14: ; preds = %11
%15 = tail call %struct.sourcefile* @Setfile(%struct.sourcefile* %0, %struct.sourcefile* %4, i8* %1)
br label %16
16: ; preds = %14, %12, %9, %7
%17 = phi %struct.sourcefile* [ null, %7 ], [ %10, %9 ], [ %0, %12 ], [ %15, %14 ]
ret %struct.sourcefile* %17
}