#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_old;
typedef int /*<<< orphan*/ filename;

/* Variables and functions */
int /*<<< orphan*/ devpath_to_db_path(int /*<<< orphan*/, char const *, char *,
                                      int);
int rename(char *, char *);
char const *udev_device_get_devpath(struct udev_device *);
int /*<<< orphan*/ udev_device_get_udev(struct udev_device *);
int udev_device_rename_db(struct udev_device *udev_device,
                          const char *devpath_old) {
  char filename_old[1024];
  char filename[1024];
  devpath_to_db_path(udev_device_get_udev(udev_device), devpath_old,
                     filename_old, sizeof(filename_old));
  devpath_to_db_path(udev_device_get_udev(udev_device),
                     udev_device_get_devpath(udev_device), filename,
                     sizeof(filename));
  return rename(filename_old, filename);
}


x86 assembly (clang, -O0):
<udev_device_rename_db>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <udev_device_get_udev@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
lea    -0x410(%rbp),%rdx
mov    $0x400,%ecx
call   1040 <devpath_to_db_path@plt>
mov    -0x8(%rbp),%rdi
call   1030 <udev_device_get_udev@plt>
mov    %eax,-0x814(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <udev_device_get_devpath@plt>
mov    -0x814(%rbp),%edi
mov    %rax,%rsi
lea    -0x810(%rbp),%rdx
mov    $0x400,%ecx
call   1040 <devpath_to_db_path@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1050 <rename@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_rename_db>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <udev_device_get_udev@plt>
lea    0x400(%rsp),%r15
mov    %eax,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x400,%ecx
call   1040 <devpath_to_db_path@plt>
mov    %rbx,%rdi
call   1030 <udev_device_get_udev@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <udev_device_get_devpath@plt>
mov    %rsp,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    $0x400,%ecx
call   1040 <devpath_to_db_path@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <rename@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
define i32 @udev_device_rename_db(%struct.udev_device* %0, i8* %1) {
%3 = alloca %struct.udev_device*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
store %struct.udev_device* %0, %struct.udev_device** %3
store i8* %1, i8** %4
%7 = load %struct.udev_device*, %struct.udev_device** %3
%8 = call i32 @udev_device_get_udev(%struct.udev_device* %7)
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = call i32 @devpath_to_db_path(i32 %8, i8* %9, i8* %10, i32 1024)
%12 = load %struct.udev_device*, %struct.udev_device** %3
%13 = call i32 @udev_device_get_udev(%struct.udev_device* %12)
%14 = load %struct.udev_device*, %struct.udev_device** %3
%15 = call i8* @udev_device_get_devpath(%struct.udev_device* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%17 = call i32 @devpath_to_db_path(i32 %13, i8* %15, i8* %16, i32 1024)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = call i32 @rename(i8* %18, i8* %19)
ret i32 %20
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
define i32 @udev_device_rename_db(%struct.udev_device* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @udev_device_get_udev(%struct.udev_device* %0)
%8 = call i32 @devpath_to_db_path(i32 %7, i8* %1, i8* %5, i32 1024)
%9 = call i32 @udev_device_get_udev(%struct.udev_device* %0)
%10 = call i8* @udev_device_get_devpath(%struct.udev_device* %0)
%11 = call i32 @devpath_to_db_path(i32 %9, i8* %10, i8* %6, i32 1024)
%12 = call i32 @rename(i8* %5, i8* %6)
ret i32 %12
}