#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 */
char *ioc_name(unsigned int, unsigned int);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int, unsigned int);
int /*<<< orphan*/ strcmp(char *, char *);
char *get_devname(unsigned int major, unsigned int minor, int pretty) {
  static char buf[32];
  char *name;
  snprintf(buf, 32, "dev%d-%d", major, minor);
  if (!pretty)
    return (buf);
  name = ioc_name(major, minor);
  if ((name == NULL) || !strcmp(name, "nodev"))
    return (buf);
  return (name);
}


x86 assembly (clang, -O0):
<get_devname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0x2f01(%rip),%rdi
mov    $0x20,%esi
lea    0xea5(%rip),%rdx
call   1030 <snprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    117a <get_devname+0x4a>
lea    0x2edf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c5 <get_devname+0x95>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <ioc_name@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ad <get_devname+0x7d>
mov    -0x20(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11bd <get_devname+0x8d>
lea    0x2e9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c5 <get_devname+0x95>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_devname>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x2f0a(%rip),%rbx
lea    0xeb3(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <snprintf@plt>
test   %r15d,%r15d
je     1192 <get_devname+0x62>
mov    %ebp,%edi
mov    %r14d,%esi
call   1050 <ioc_name@plt>
test   %rax,%rax
je     1192 <get_devname+0x62>
mov    %rax,%rbp
lea    0xe8c(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
lea    0x2ec2(%rip),%rbx
cmovne %rbp,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_devname.buf = internal global [32 x i8] zeroinitializer
@.str = [9 x i8] c"dev%d-%d\00"
@.str.1 = [6 x i8] c"nodev\00"
define i8* @get_devname(i32 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %3
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), i8** %4
br label %28
15: ; preds = %3
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = call i8* @ioc_name(i32 %16, i32 %17)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp eq i8* %19, null
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = load i8*, i8** %8
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21, %15
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), i8** %4
br label %28
26: ; preds = %21
%27 = load i8*, i8** %8
store i8* %27, i8** %4
br label %28
28: ; preds = %26, %25, %14
%29 = load i8*, i8** %4
ret i8* %29
}

LLVM IR (-O2):
@get_devname.buf = internal global [32 x i8] zeroinitializer
@.str = [9 x i8] c"dev%d-%d\00"
@.str.1 = [6 x i8] c"nodev\00"
define i8* @get_devname(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%5 = icmp eq i32 %2, 0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i8* @ioc_name(i32 %0, i32 %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call i32 @strcmp(i8* %7, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), i8* %7
br label %13
13: ; preds = %9, %6, %3
%14 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), %3 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @get_devname.buf, i64 0, i64 0), %6 ], [ %12, %9 ]
ret i8* %14
}