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

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


x86 assembly (clang, -O0):
<udev_device_delete_db>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <udev_device_get_udev@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <udev_device_get_id_filename@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1190 <udev_device_delete_db+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <udev_device_delete_db+0x8d>
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <udev_get_run_path@plt>
mov    -0x428(%rbp),%rdi
mov    %eax,%edx
mov    -0x18(%rbp),%r8
mov    $0x400,%esi
lea    0xe40(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
call   1060 <util_strscpyl@plt>
lea    -0x420(%rbp),%rdi
call   1040 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_delete_db>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
call   1030 <udev_device_get_udev@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <udev_device_get_id_filename@plt>
test   %rax,%rax
je     11ab <udev_device_delete_db+0x5b>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <udev_get_run_path@plt>
lea    0xe7a(%rip),%rcx
xor    %r14d,%r14d
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x400,%esi
mov    %eax,%edx
mov    %rbx,%r8
xor    %r9d,%r9d
call   1060 <util_strscpyl@plt>
mov    %r15,%rdi
call   1040 <unlink@plt>
jmp    11b1 <udev_device_delete_db+0x61>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
@.str = [7 x i8] c"/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 %struct.udev*
%6 = alloca [1024 x i8]
store %struct.udev_device* %0, %struct.udev_device** %3
%7 = load %struct.udev_device*, %struct.udev_device** %3
%8 = call %struct.udev* @udev_device_get_udev(%struct.udev_device* %7)
store %struct.udev* %8, %struct.udev** %5
%9 = load %struct.udev_device*, %struct.udev_device** %3
%10 = call i8* @udev_device_get_id_filename(%struct.udev_device* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %22
14: ; preds = %1
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = load %struct.udev*, %struct.udev** %5
%17 = call i32 @udev_get_run_path(%struct.udev* %16)
%18 = load i8*, i8** %4
%19 = call i32 @util_strscpyl(i8* %15, i32 1024, i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18, i32* null)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%21 = call i32 @unlink(i8* %20)
store i32 0, i32* %2
br label %22
22: ; preds = %14, %13
%23 = load i32, i32* %2
ret i32 %23
}

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