#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*/ dev_t;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ makedev(int, int);
char *strchr(char *, char);
int /*<<< orphan*/ util_strlcpy(char *, char *, int);
int /*<<< orphan*/ warnx(char *);
int dinfo_extract_dev(dev_t *dev, char *str) {
  char tmp[80];
  char *p = NULL;
  int ma, mi;
  bzero(tmp, 80);
  util_strlcpy(tmp, str, 80);
  p = strchr(tmp, ':');
  if (p == NULL) {
    warnx("Error: unable to extract major/minor");
    return -1;
  }
  *p = '\0';
  ma = atoi(tmp);
  mi = atoi(p + sizeof(char));
  *dev = makedev(ma, mi);
  return 0;
}


x86 assembly (clang, -O0):
<dinfo_extract_dev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x50,%esi
call   1050 <bzero@plt>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x50,%edx
call   1060 <util_strlcpy@plt>
lea    -0x70(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    11d0 <dinfo_extract_dev+0x70>
lea    0xe41(%rip),%rdi
call   1040 <warnx@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120d <dinfo_extract_dev+0xad>
mov    -0x78(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x70(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x78(%rbp),%rdi
add    $0x1,%rdi
call   1080 <atoi@plt>
mov    %eax,-0x80(%rbp)
mov    -0x7c(%rbp),%edi
mov    -0x80(%rbp),%esi
call   1070 <makedev@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dinfo_extract_dev>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x50,%esi
call   1050 <bzero@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1060 <util_strlcpy@plt>
mov    %r15,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11ce <dinfo_extract_dev+0x6e>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rsp,%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
add    $0x1,%rbx
mov    %rbx,%rdi
call   1080 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <makedev@plt>
mov    %eax,(%r14)
xor    %eax,%eax
jmp    11df <dinfo_extract_dev+0x7f>
lea    0xe2b(%rip),%rdi
call   1040 <warnx@plt>
mov    $0xffffffff,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Error: unable to extract major/minor\00"
define i32 @dinfo_extract_dev(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [80 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* null, i8** %7
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 80)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @util_strlcpy(i8* %12, i8* %13, i32 80)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%16 = call i8* @strchr(i8* %15, i8 signext 58)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @warnx(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
21: ; preds = %2
%22 = load i8*, i8** %7
store i8 0, i8* %22
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = call i32 @makedev(i32 %28, i32 %29)
%31 = load i32*, i32** %4
store i32 %30, i32* %31
store i32 0, i32* %3
br label %32
32: ; preds = %21, %19
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [37 x i8] c"Error: unable to extract major/minor\00"
define i32 @dinfo_extract_dev(i32* nocapture writeonly %0, i8* %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 80)
%6 = call i32 @util_strlcpy(i8* %4, i8* %1, i32 80)
%7 = call i8* @strchr(i8* %4, i8 signext 58)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @warnx(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %16
11: ; preds = %2
store i8 0, i8* %7
%12 = call i32 @atoi(i8* %4)
%13 = getelementptr inbounds i8, i8* %7, i64 1
%14 = call i32 @atoi(i8* %13)
%15 = call i32 @makedev(i32 %12, i32 %14)
store i32 %15, i32* %0
br label %16
16: ; preds = %11, %9
%17 = phi i32 [ -1, %9 ], [ 0, %11 ]
ret i32 %17
}