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

/* Variables and functions */
int /*<<< orphan*/ __ploop_err(int /*<<< orphan*/, char *, char const *,
                               char *);
scalar_t__ read_line(char const *, char *, int);
int sscanf(char *, char *, int /*<<< orphan*/ *);
int get_dev_start(const char *path, __u32 *start) {
  char nbuf[4096];
  if (read_line(path, nbuf, sizeof(nbuf)))
    return -1;
  if (sscanf(nbuf, "%u", start) != 1) {
    __ploop_err(0, "Unexpected format of %s: %s", path, nbuf);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_dev_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%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     116e <get_dev_start+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <get_dev_start+0x8a>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe80(%rip),%rsi
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     11b3 <get_dev_start+0x83>
mov    -0x10(%rbp),%rdx
lea    -0x1020(%rbp),%rcx
xor    %edi,%edi
lea    0xe61(%rip),%rsi
call   1050 <__ploop_err@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <get_dev_start+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dev_start>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0x1000,%edx
call   1040 <read_line@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    118e <get_dev_start+0x5e>
lea    0xe9f(%rip),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
je     118e <get_dev_start+0x5e>
lea    0xe87(%rip),%rsi
mov    %rsp,%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   1050 <__ploop_err@plt>
mov    $0xffffffff,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [28 x i8] c"Unexpected format of %s: %s\00"
define i32 @get_dev_start(i8* %0, i32* %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = call i64 @read_line(i8* %0, i8* %4, i32 4096)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @__ploop_err(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %4)
br label %12
12: ; preds = %7, %2, %10
%13 = phi i32 [ -1, %10 ], [ -1, %2 ], [ 0, %7 ]
ret i32 %13
}