#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 udev_device {
  int dummy;
};
typedef int /*<<< orphan*/ filename;

/* Variables and functions */
int /*<<< orphan*/ strscpyl(char *, int, char *, char const *,
                            int /*<<< orphan*/ *);
char *udev_device_get_id_filename(struct udev_device *);
int /*<<< orphan*/ unlink(char *);
int udev_device_delete_db(struct udev_device *udev_device) {
  const char *id;
  char filename[1024];
  id = udev_device_get_id_filename(udev_device);
  if (id == NULL)
    return -1;
  strscpyl(filename, sizeof(filename), "/run/udev/data/", id, NULL);
  unlink(filename);
  return 0;
}


x86 assembly (clang, -O0):
<udev_device_delete_db>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <udev_device_get_id_filename@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <udev_device_delete_db+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <udev_device_delete_db+0x67>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x400,%esi
lea    0xe86(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_delete_db>:
push   %r14
push   %rbx
sub    $0x408,%rsp
call   1050 <udev_device_get_id_filename@plt>
test   %rax,%rax
je     116d <udev_device_delete_db+0x3d>
lea    0xeb5(%rip),%rdx
xor    %ebx,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rax,%rcx
xor    %r8d,%r8d
call   1040 <strscpyl@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
jmp    1172 <udev_device_delete_db+0x42>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
@.str = [16 x i8] c"/run/udev/data/\00"
define i32 @udev_device_delete_db(%struct.udev_device* %0) {
%2 = alloca i32
%3 = alloca %struct.udev_device*
%4 = alloca i8*
%5 = alloca [1024 x i8]
store %struct.udev_device* %0, %struct.udev_device** %3
%6 = load %struct.udev_device*, %struct.udev_device** %3
%7 = call i8* @udev_device_get_id_filename(%struct.udev_device* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %17
11: ; preds = %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @strscpyl(i8* %12, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %13, i32* null)
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%16 = call i32 @unlink(i8* %15)
store i32 0, i32* %2
br label %17
17: ; preds = %11, %10
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
@.str = [16 x i8] c"/run/udev/data/\00"
define i32 @udev_device_delete_db(%struct.udev_device* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @udev_device_get_id_filename(%struct.udev_device* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = call i32 @strscpyl(i8* %3, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %4, i32* null)
%8 = call i32 @unlink(i8* %3)
br label %9
9: ; preds = %1, %6
%10 = phi i32 [ 0, %6 ], [ -1, %1 ]
ret i32 %10
}