#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 scalar_t__ dev_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ NODEV;
int major(scalar_t__);
int minor(scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
char *mkdevstr(dev_t d) {
  static char buf[32];
  if (d == NODEV)
    (void)snprintf(buf, sizeof(buf), "NODEV");
  else
    (void)snprintf(buf, sizeof(buf), "makedev(%d, %d)", major(d), minor(d));
  return buf;
}


x86 assembly (clang, -O0):
<mkdevstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2ea9(%rip),%rcx
cmp    (%rcx),%rax
jne    116f <mkdevstr+0x3f>
lea    0x2ef9(%rip),%rdi
mov    $0x20,%esi
lea    0xe9d(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    11a4 <mkdevstr+0x74>
mov    -0x8(%rbp),%rdi
call   1050 <major@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <minor@plt>
mov    -0xc(%rbp),%ecx
mov    %eax,%r8d
lea    0x2ebf(%rip),%rdi
mov    $0x20,%esi
lea    0xe69(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2ea5(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkdevstr>:
push   %rbp
push   %rbx
push   %rax
mov    0x2eb6(%rip),%rax
cmp    %rdi,(%rax)
jne    115b <mkdevstr+0x2b>
lea    0x2f0a(%rip),%rdi
lea    0xeb3(%rip),%rdx
mov    $0x20,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    118c <mkdevstr+0x5c>
mov    %rdi,%rbx
call   1050 <major@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <minor@plt>
lea    0x2edc(%rip),%rdi
lea    0xe8b(%rip),%rdx
mov    $0x20,%esi
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0x2ebd(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@mkdevstr.buf = internal global [32 x i8] zeroinitializer
@NODEV = global i64 0
@.str = [6 x i8] c"NODEV\00"
@.str.1 = [16 x i8] c"makedev(%d, %d)\00"
define i8* @mkdevstr(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = load i64, i64* @NODEV
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mkdevstr.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %14
8: ; preds = %1
%9 = load i64, i64* %2
%10 = call i32 @major(i64 %9)
%11 = load i64, i64* %2
%12 = call i32 @minor(i64 %11)
%13 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mkdevstr.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
br label %14
14: ; preds = %8, %6
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mkdevstr.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@mkdevstr.buf = internal global [32 x i8] zeroinitializer
@NODEV = global i64 0
@.str = [6 x i8] c"NODEV\00"
@.str.1 = [16 x i8] c"makedev(%d, %d)\00"
define i8* @mkdevstr(i64 %0) {
%2 = load i64, i64* @NODEV
%3 = icmp eq i64 %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mkdevstr.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %10
6: ; preds = %1
%7 = tail call i32 @major(i64 %0)
%8 = tail call i32 @minor(i64 %0)
%9 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mkdevstr.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
br label %10
10: ; preds = %6, %4
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mkdevstr.buf, i64 0, i64 0)
}