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

/* Variables and functions */
int /*<<< orphan*/ __ploop_err(int /*<<< orphan*/, char *, char const *,
                               char *);
int /*<<< orphan*/ makedev(int, int);
scalar_t__ read_line(char const *, char *, int);
int sscanf(char *, char *, int *, int *);
int get_dev_num(const char *path, dev_t *dev_num) {
  char nbuf[4096];
  int maj, min;
  if (read_line(path, nbuf, sizeof(nbuf)))
    return -1;
  if (sscanf(nbuf, "%d:%d", &maj, &min) != 2) {
    __ploop_err(0, "Unexpected format of %s: %s", path, nbuf);
    return -1;
  }
  *dev_num = makedev(maj, min);
  return 0;
}


x86 assembly (clang, -O0):
<get_dev_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <read_line@plt>
cmp    $0x0,%rax
je     117e <get_dev_num+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <get_dev_num+0xad>
lea    -0x1020(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    -0x1024(%rbp),%rdx
lea    -0x1028(%rbp),%rcx
call   1030 <sscanf@plt>
cmp    $0x2,%eax
je     11cd <get_dev_num+0x8d>
mov    -0x10(%rbp),%rdx
lea    -0x1020(%rbp),%rcx
xor    %edi,%edi
lea    0xe4a(%rip),%rsi
call   1060 <__ploop_err@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <get_dev_num+0xad>
mov    -0x1024(%rbp),%edi
mov    -0x1028(%rbp),%esi
call   1050 <makedev@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dev_num>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
mov    $0x1000,%edx
call   1040 <read_line@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    11b4 <get_dev_num+0x74>
lea    0xe8f(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    119e <get_dev_num+0x5e>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1050 <makedev@plt>
mov    %eax,(%r14)
xor    %ebp,%ebp
jmp    11b4 <get_dev_num+0x74>
lea    0xe61(%rip),%rsi
lea    0x10(%rsp),%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   1060 <__ploop_err@plt>
mov    %ebp,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d:%d\00"
@.str.1 = [28 x i8] c"Unexpected format of %s: %s\00"
define i32 @get_dev_num(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [4096 x i8]
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%11 = call i64 @read_line(i8* %9, i8* %10, i32 4096)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %27
14: ; preds = %2
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8)
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%21 = call i32 @__ploop_err(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
store i32 -1, i32* %3
br label %27
22: ; preds = %14
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @makedev(i32 %23, i32 %24)
%26 = load i32*, i32** %5
store i32 %25, i32* %26
store i32 0, i32* %3
br label %27
27: ; preds = %22, %18, %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d:%d\00"
@.str.1 = [28 x i8] c"Unexpected format of %s: %s\00"
define i32 @get_dev_num(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i64 @read_line(i8* %0, i8* %6, i32 4096)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%13 = icmp eq i32 %12, 2
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @__ploop_err(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %6)
br label %20
16: ; preds = %11
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @makedev(i32 %17, i32 %18)
store i32 %19, i32* %1
br label %20
20: ; preds = %2, %16, %14
%21 = phi i32 [ -1, %14 ], [ 0, %16 ], [ -1, %2 ]
ret i32 %21
}