#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ uid_t;
typedef int /*<<< orphan*/ pathname;

/* Variables and functions */
int chown(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int chrdev_chown(uint8_t minor, uid_t uid, uid_t gid) {
  char pathname[64];
  int x;
  snprintf(pathname, sizeof(pathname), "/dev/mhvtl%d", minor);
  ;
  x = chown(pathname, uid, uid);
  if (x == -1) {

    ;
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<chrdev_chown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x40,%esi
lea    0xebc(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <chown@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
jne    1171 <chrdev_chown+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    1178 <chrdev_chown+0x58>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chrdev_chown>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %esi,%ebx
mov    %edi,%ecx
lea    0xece(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x40,%esi
call   1030 <snprintf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
call   1040 <chown@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/mhvtl%d\00"
define i32 @chrdev_chown(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [64 x i8]
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%11 = load i32, i32* %5
%12 = call i32 @snprintf(i8* %10, i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%14 = load i32, i32* %6
%15 = load i32, i32* %6
%16 = call i32 @chown(i8* %13, i32 %14, i32 %15)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 -1, i32* %4
br label %21
20: ; preds = %3
store i32 0, i32* %4
br label %21
21: ; preds = %20, %19
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/mhvtl%d\00"
define i32 @chrdev_chown(i32 %0, i32 %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0)
%7 = call i32 @chown(i8* %5, i32 %1, i32 %1)
%8 = icmp eq i32 %7, -1
%9 = sext i1 %8 to i32
ret i32 %9
}