#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 /*<<< orphan*/ copy_and_return_nonemptiness(int);
int /*<<< orphan*/ gui_fatal(char *);
scalar_t__ rename(char *, char *);
int /*<<< orphan*/ unlink(char *);
void actually_recv_file(char *fname, char *tempfile, int tmpfd) {
  if (!copy_and_return_nonemptiness(tmpfd)) {
    unlink(tempfile);
    return;
  }
  if (rename(tempfile, fname))
    gui_fatal("rename");
}


x86 assembly (clang, -O0):
<actually_recv_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <copy_and_return_nonemptiness@plt>
cmp    $0x0,%eax
jne    1172 <actually_recv_file+0x32>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
jmp    1195 <actually_recv_file+0x55>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <rename@plt>
cmp    $0x0,%rax
je     1195 <actually_recv_file+0x55>
lea    0xe70(%rip),%rdi
call   1060 <gui_fatal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<actually_recv_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%edi
call   1040 <copy_and_return_nonemptiness@plt>
mov    %rbx,%rdi
test   %eax,%eax
je     1178 <actually_recv_file+0x38>
mov    %r14,%rsi
call   1050 <rename@plt>
test   %rax,%rax
je     1184 <actually_recv_file+0x44>
lea    0xe94(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <gui_fatal@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <unlink@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"rename\00"
define void @actually_recv_file(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = call i32 @copy_and_return_nonemptiness(i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = call i32 @unlink(i8* %11)
br label %20
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = call i64 @rename(i8* %14, i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @gui_fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %10, %18, %13
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"rename\00"
define void @actually_recv_file(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @copy_and_return_nonemptiness(i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @unlink(i8* %1)
br label %13
8: ; preds = %3
%9 = tail call i64 @rename(i8* %1, i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @gui_fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %6, %11, %8
ret void
}