#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*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int unlink(char *);
void *remove_tmp(int idx) {
  int r;
  char fname[20];
  sprintf(fname, "tmpfile.%08x", idx);
  r = unlink(fname);
  if (r == -1) {
    perror("remove_tmp");
    printf("remove %s\n", fname);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<remove_tmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea7(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1190 <remove_tmp+0x50>
lea    0xe92(%rip),%rdi
call   1050 <perror@plt>
lea    -0x20(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_tmp>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%edx
lea    0xeb2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     116e <remove_tmp+0x2e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe98(%rip),%rdi
call   1050 <perror@plt>
lea    0xe97(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
jmp    1166 <remove_tmp+0x26>

LLVM IR (-O0):
@.str = [13 x i8] c"tmpfile.%08x\00"
@.str.1 = [11 x i8] c"remove_tmp\00"
@.str.2 = [11 x i8] c"remove %s\0A\00"
define i8* @remove_tmp(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
store i32 %0, i32* %2
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* %2
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = call i32 @unlink(i8* %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %1
ret i8* null
}

LLVM IR (-O2):
@.str = [13 x i8] c"tmpfile.%08x\00"
@.str.1 = [11 x i8] c"remove_tmp\00"
@.str.2 = [11 x i8] c"remove %s\0A\00"
define noalias i8* @remove_tmp(i32 %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i32 @unlink(i8* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %10
10: ; preds = %7, %1
ret i8* null
}