#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 unsigned long long __u64;

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ exit(int);
scalar_t__ fd_is_raid(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_dev_geometry(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, unsigned long long *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
int strlen(char *);
int abort_if_not_full_device(int fd, __u64 lba, const char *devname,
                             const char *msg) {
  __u64 start_lba;
  int i, err, shortened = 0;
  char *fdevname = strdup(devname);
  err = get_dev_geometry(fd, NULL, NULL, NULL, &start_lba, NULL);
  if (err)
    exit(err);
  for (i = strlen(fdevname);
       --i > 2 && (fdevname[i] >= '0' && fdevname[i] <= '9');) {
    fdevname[i] = '\0';
    shortened = 1;
  }
  if (!shortened)
    fdevname = strdup("the full disk");
  if (start_lba == 0ULL)
    return 0;
  if (start_lba == (~0ull) || fd_is_raid(fd)) {
    fprintf(stderr,
            "%s is a RAID device: please specify an absolute LBA of a raw "
            "member device instead (raid1 only)\n",
            devname);
  } else if (msg) {
    fprintf(stderr, "%s\n", msg);
  } else {
    fprintf(stderr, "Device %s has non-zero LBA starting offset of %llu.\n",
            devname, start_lba);
    fprintf(stderr, "Please use an absolute LBA with the /dev/ entry for the "
                    "raw device, rather than a partition or raid name.\n");
    fprintf(stderr, "%s is probably a partition of %s (?)\n", devname,
            fdevname);
    fprintf(stderr, "The absolute LBA of sector %llu from %s should be %llu\n",
            lba, devname, start_lba + lba);
  }
  fprintf(stderr, "Aborting.\n");
  exit(EINVAL);
}


x86 assembly (clang, -O0):
<abort_if_not_full_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
xor    %eax,%eax
mov    %eax,%r9d
lea    -0x28(%rbp),%r8
mov    %r9,%rsi
mov    %r9,%rdx
mov    %r9,%rcx
call   1060 <get_dev_geometry@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     11ba <abort_if_not_full_device+0x5a>
mov    -0x30(%rbp),%edi
call   1070 <exit@plt>
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x2c(%rbp)
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x41(%rbp)
jle    1212 <abort_if_not_full_device+0xb2>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x42(%rbp)
jl     120c <abort_if_not_full_device+0xac>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1222 <abort_if_not_full_device+0xc2>
jmp    123a <abort_if_not_full_device+0xda>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x34(%rbp)
jmp    11c6 <abort_if_not_full_device+0x66>
cmpl   $0x0,-0x34(%rbp)
jne    1254 <abort_if_not_full_device+0xf4>
lea    0xdb5(%rip),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1267 <abort_if_not_full_device+0x107>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret
cmpq   $0xffffffffffffffff,-0x28(%rbp)
je     1284 <abort_if_not_full_device+0x124>
mov    -0x4(%rbp),%edi
call   1040 <fd_is_raid@plt>
cmp    $0x0,%rax
je     12a4 <abort_if_not_full_device+0x144>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1350 <abort_if_not_full_device+0x1f0>
cmpq   $0x0,-0x20(%rbp)
je     12cf <abort_if_not_full_device+0x16f>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    134b <abort_if_not_full_device+0x1eb>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
add    -0x10(%rbp),%r8
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1350 <abort_if_not_full_device+0x1f0>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<abort_if_not_full_device>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rdx,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%r8
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r9d,%r9d
call   1060 <get_dev_geometry@plt>
test   %eax,%eax
jne    12e4 <abort_if_not_full_device+0x184>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jl     11f9 <abort_if_not_full_device+0x99>
lea    -0x1(%rax),%edx
mov    (%rbx,%rdx,1),%dil
add    $0xd0,%dil
cmp    $0x9,%dil
ja     11f9 <abort_if_not_full_device+0x99>
add    %rbx,%rdx
mov    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x0,(%rdx)
cmp    $0x4,%rax
jle    1208 <abort_if_not_full_device+0xa8>
lea    -0x1(%rax),%rsi
add    $0xfffffffe,%eax
lea    (%rbx,%rax,1),%rdx
movzbl (%rbx,%rax,1),%ecx
add    $0xd0,%cl
mov    %rsi,%rax
cmp    $0x9,%cl
jbe    11d0 <abort_if_not_full_device+0x70>
cmp    $0xa,%dil
jb     1208 <abort_if_not_full_device+0xa8>
lea    0xe00(%rip),%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
test   %rax,%rax
jne    1221 <abort_if_not_full_device+0xc1>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0xffffffffffffffff,%rax
je     12a5 <abort_if_not_full_device+0x145>
mov    %ebp,%edi
call   1040 <fd_is_raid@plt>
test   %rax,%rax
jne    12a5 <abort_if_not_full_device+0x145>
mov    0x2da6(%rip),%rbp
mov    0x0(%rbp),%edi
test   %r12,%r12
jne    12eb <abort_if_not_full_device+0x18b>
mov    0x8(%rsp),%rcx
lea    0xe21(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe42(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe9c(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    0x8(%rsp),%r8
add    %r14,%r8
lea    0xea3(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12bf <abort_if_not_full_device+0x15f>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    %eax,%edi
call   1070 <exit@plt>
lea    0xd7d(%rip),%rsi
mov    %r12,%rdx
jmp    12b8 <abort_if_not_full_device+0x158>

LLVM IR (-O0):
@.str = [14 x i8] c"the full disk\00"
@stderr = global i32 0
@.str.1 = [97 x i8] c"%s is a RAID device: please specify an absolute LBA of a raw member device instead (raid1 only)\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [53 x i8] c"Device %s has non-zero LBA starting offset of %llu.\0A\00"
@.str.4 = [107 x i8] c"Please use an absolute LBA with the /dev/ entry for the raw device, rather than a partition or raid name.\0A\00"
@.str.5 = [38 x i8] c"%s is probably a partition of %s (?)\0A\00"
@.str.6 = [56 x i8] c"The absolute LBA of sector %llu from %s should be %llu\0A\00"
@.str.7 = [11 x i8] c"Aborting.\0A\00"
@EINVAL = global i32 0
define i32 @abort_if_not_full_device(i32 %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i32 %0, i32* %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %12
%14 = load i8*, i8** %7
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %13
%16 = load i32, i32* %5
%17 = call i32 @get_dev_geometry(i32 %16, i32* null, i32* null, i32* null, i64* %9, i32* null)
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %4
%21 = load i32, i32* %11
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %4
%24 = load i8*, i8** %13
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %10
br label %26
26: ; preds = %50, %23
%27 = load i32, i32* %10
%28 = add nsw i32 %27, -1
store i32 %28, i32* %10
%29 = icmp sgt i32 %28, 2
br i1 %29, label %30, label %48
30: ; preds = %26
%31 = load i8*, i8** %13
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp sge i32 %36, 48
br i1 %37, label %38, label %46
38: ; preds = %30
%39 = load i8*, i8** %13
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp sle i32 %44, 57
br label %46
46: ; preds = %38, %30
%47 = phi i1 [ false, %30 ], [ %45, %38 ]
br label %48
48: ; preds = %46, %26
%49 = phi i1 [ false, %26 ], [ %47, %46 ]
br i1 %49, label %50, label %55
50: ; preds = %48
%51 = load i8*, i8** %13
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 0, i8* %54
store i32 1, i32* %12
br label %26
55: ; preds = %48
%56 = load i32, i32* %12
%57 = icmp ne i32 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = call i8* @strdup(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* %59, i8** %13
br label %60
60: ; preds = %58, %55
%61 = load i64, i64* %9
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %60
ret i32 0
64: ; preds = %60
%65 = load i64, i64* %9
%66 = icmp eq i64 %65, -1
br i1 %66, label %71, label %67
67: ; preds = %64
%68 = load i32, i32* %5
%69 = call i64 @fd_is_raid(i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %67, %64
%72 = load i32, i32* @stderr
%73 = load i8*, i8** %7
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.1, i64 0, i64 0), i8* %73)
br label %101
75: ; preds = %67
%76 = load i8*, i8** %8
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %82
78: ; preds = %75
%79 = load i32, i32* @stderr
%80 = load i8*, i8** %8
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %80)
br label %100
82: ; preds = %75
%83 = load i32, i32* @stderr
%84 = load i8*, i8** %7
%85 = load i64, i64* %9
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %84, i64 %85)
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.4, i64 0, i64 0))
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %7
%91 = load i8*, i8** %13
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %90, i8* %91)
%93 = load i32, i32* @stderr
%94 = load i64, i64* %6
%95 = load i8*, i8** %7
%96 = load i64, i64* %9
%97 = load i64, i64* %6
%98 = add i64 %96, %97
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i64 %94, i8* %95, i64 %98)
br label %100
100: ; preds = %82, %78
br label %101
101: ; preds = %100, %71
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%104 = load i32, i32* @EINVAL
%105 = call i32 @exit(i32 %104)
unreachable
}

LLVM IR (-O2):
@.str = [14 x i8] c"the full disk\00"
@stderr = global i32 0
@.str.1 = [97 x i8] c"%s is a RAID device: please specify an absolute LBA of a raw member device instead (raid1 only)\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [53 x i8] c"Device %s has non-zero LBA starting offset of %llu.\0A\00"
@.str.4 = [107 x i8] c"Please use an absolute LBA with the /dev/ entry for the raw device, rather than a partition or raid name.\0A\00"
@.str.5 = [38 x i8] c"%s is probably a partition of %s (?)\0A\00"
@.str.6 = [56 x i8] c"The absolute LBA of sector %llu from %s should be %llu\0A\00"
@.str.7 = [11 x i8] c"Aborting.\0A\00"
@EINVAL = global i32 0
define i32 @abort_if_not_full_device(i32 %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = tail call i8* @strdup(i8* %2)
%8 = call i32 @get_dev_geometry(i32 %0, i32* null, i32* null, i32* null, i64* %5, i32* null)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = call i32 @exit(i32 %8)
unreachable
12: ; preds = %4
%13 = call i32 @strlen(i8* %7)
%14 = icmp sgt i32 %13, 3
br i1 %14, label %15, label %38
15: ; preds = %12
%16 = add nsw i32 %13, -1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %7, i64 %17
%19 = load i8, i8* %18
%20 = add i8 %19, -48
%21 = icmp ult i8 %20, 10
br i1 %21, label %22, label %38
22: ; preds = %15
%23 = zext i32 %13 to i64
br label %32
24: ; preds = %32
%25 = add nsw i64 %35, -1
%26 = add nsw i32 %34, -1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %7, i64 %27
%29 = load i8, i8* %28
%30 = add i8 %29, -48
%31 = icmp ult i8 %30, 10
br i1 %31, label %32, label %37
32: ; preds = %22, %24
%33 = phi i8* [ %18, %22 ], [ %28, %24 ]
%34 = phi i32 [ %16, %22 ], [ %26, %24 ]
%35 = phi i64 [ %23, %22 ], [ %25, %24 ]
store i8 0, i8* %33
%36 = icmp sgt i64 %35, 4
br i1 %36, label %24, label %40
37: ; preds = %24
br i1 %21, label %40, label %38
38: ; preds = %15, %12, %37
%39 = call dereferenceable_or_null(14) i8* @strdup(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %32, %38, %37
%41 = phi i8* [ %7, %37 ], [ %39, %38 ], [ %7, %32 ]
%42 = load i64, i64* %5
switch i64 %42, label %44 [
i64 0, label %43
i64 -1, label %47
]
43: ; preds = %40
ret i32 0
44: ; preds = %40
%45 = call i64 @fd_is_raid(i32 %0)
%46 = icmp eq i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %40, %44
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %66
50: ; preds = %44
%51 = icmp eq i8* %3, null
%52 = load i32, i32* @stderr
br i1 %51, label %55, label %53
53: ; preds = %50
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %66
55: ; preds = %50
%56 = load i64, i64* %5
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %2, i64 %56)
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.4, i64 0, i64 0))
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %41)
%62 = load i32, i32* @stderr
%63 = load i64, i64* %5
%64 = add i64 %63, %1
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i64 %1, i8* %2, i64 %64)
br label %66
66: ; preds = %53, %55, %47
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%69 = load i32, i32* @EINVAL
%70 = call i32 @exit(i32 %69)
unreachable
}