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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
char *basename(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int ext4fixup_internal(char *, int, int, int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ sscanf(int /*<<< orphan*/, char *, int *, int *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int opt;
  int verbose = 0;
  int no_write = 0;
  char *fsdev;
  char *me;
  int stop_phase = 0, stop_loc = 0, stop_count = 0;
  me = basename(argv[0]);
  while ((opt = getopt(argc, argv, "vnd:")) != -1) {
    switch (opt) {
    case 'v':
      verbose = 1;
      break;
    case 'n':
      no_write = 1;
      break;
    case 'd':
      sscanf(optarg, "%d,%d,%d", &stop_phase, &stop_loc, &stop_count);
      break;
    }
  }
  if (optind >= argc) {
    fprintf(stderr, "expected image or block device after options\n");
    usage(me);
    exit(EXIT_FAILURE);
  }
  fsdev = argv[optind++];
  if (optind < argc) {
    fprintf(stderr, "Unexpected argument: %s\n", argv[optind]);
    usage(me);
    exit(EXIT_FAILURE);
  }
  return ext4fixup_internal(fsdev, verbose, no_write, stop_phase, stop_loc,
                            stop_count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <basename@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe39(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     124c <main+0xdc>
mov    -0x14(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x64,%eax
je     1226 <main+0xb6>
jmp    11ec <main+0x7c>
mov    -0x40(%rbp),%eax
sub    $0x6e,%eax
je     121a <main+0xaa>
jmp    11fd <main+0x8d>
mov    -0x40(%rbp),%eax
sub    $0x76,%eax
jne    1247 <main+0xd7>
jmp    120e <main+0x9e>
movl   $0x1,-0x18(%rbp)
jmp    1247 <main+0xd7>
movl   $0x1,-0x1c(%rbp)
jmp    1247 <main+0xd7>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1050 <sscanf@plt>
jmp    11b9 <main+0x49>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     128c <main+0x11c>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <usage@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2d49(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d3b(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1304 <main+0x194>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2d08(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <usage@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
call   1080 <ext4fixup_internal@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
mov    (%rsi),%rdi
call   1040 <basename@plt>
mov    %rax,0x20(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xe49(%rip),%r13
lea    0x1c(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x14(%rsp),%r14
movl   $0x0,0xc(%rsp)
jmp    11ee <main+0x7e>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1050 <sscanf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1070 <getopt@plt>
cmp    $0x6d,%eax
jg     1210 <main+0xa0>
cmp    $0x64,%eax
je     11d0 <main+0x60>
cmp    $0xffffffff,%eax
jne    11ee <main+0x7e>
jmp    122e <main+0xbe>
nopl   0x0(%rax)
cmp    $0x6e,%eax
je     1224 <main+0xb4>
cmp    $0x76,%eax
jne    11ee <main+0x7e>
movl   $0x1,0xc(%rsp)
jmp    11ee <main+0x7e>
movl   $0x1,0x10(%rsp)
jmp    11ee <main+0x7e>
mov    0x2dab(%rip),%rcx
movslq (%rcx),%rax
cmp    %ebp,%eax
jge    1273 <main+0x103>
lea    0x1(%rax),%edx
mov    %edx,(%rcx)
cmp    %ebp,%edx
jl     128c <main+0x11c>
mov    (%rbx,%rax,8),%rdi
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
call   1080 <ext4fixup_internal@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    0xd8b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    12a8 <main+0x138>
mov    0x2d3d(%rip),%rcx
mov    (%rcx),%edi
mov    0x8(%rbx,%rax,8),%rdx
lea    0xd9b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x20(%rsp),%rdi
call   1060 <usage@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"vnd:\00"
@optarg = global i32 0
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@optind = global i32 0
@stderr = global i32 0
@.str.2 = [46 x i8] c"expected image or block device after options\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [25 x i8] c"Unexpected argument: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i8* @basename(i8* %16)
store i8* %17, i8** %10
br label %18
18: ; preds = %30, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %6
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %31
23: ; preds = %18
%24 = load i32, i32* %6
switch i32 %24, label %30 [
i32 118, label %25
i32 110, label %26
i32 100, label %27
]
25: ; preds = %23
store i32 1, i32* %7
br label %30
26: ; preds = %23
store i32 1, i32* %8
br label %30
27: ; preds = %23
%28 = load i32, i32* @optarg
%29 = call i32 @sscanf(i32 %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
br label %30
30: ; preds = %23, %27, %26, %25
br label %18
31: ; preds = %18
%32 = load i32, i32* @optind
%33 = load i32, i32* %4
%34 = icmp sge i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%38 = load i8*, i8** %10
%39 = call i32 @usage(i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %31
%43 = load i8**, i8*** %5
%44 = load i32, i32* @optind
%45 = add nsw i32 %44, 1
store i32 %45, i32* @optind
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
%48 = load i8*, i8** %47
store i8* %48, i8** %9
%49 = load i32, i32* @optind
%50 = load i32, i32* %4
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %64
52: ; preds = %42
%53 = load i32, i32* @stderr
%54 = load i8**, i8*** %5
%55 = load i32, i32* @optind
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %58)
%60 = load i8*, i8** %10
%61 = call i32 @usage(i8* %60)
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %42
%65 = load i8*, i8** %9
%66 = load i32, i32* %7
%67 = load i32, i32* %8
%68 = load i32, i32* %11
%69 = load i32, i32* %12
%70 = load i32, i32* %13
%71 = call i32 @ext4fixup_internal(i8* %65, i32 %66, i32 %67, i32 %68, i32 %69, i32 %70)
ret i32 %71
}

LLVM IR (-O2):
@.str = [5 x i8] c"vnd:\00"
@optarg = global i32 0
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@optind = global i32 0
@stderr = global i32 0
@.str.2 = [46 x i8] c"expected image or block device after options\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [25 x i8] c"Unexpected argument: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = load i8*, i8** %1
%10 = tail call i8* @basename(i8* %9)
br label %11
11: ; preds = %16, %2
%12 = phi i32 [ 0, %2 ], [ 1, %16 ]
%13 = phi i32 [ 0, %2 ], [ %15, %16 ]
br label %14
14: ; preds = %16, %11
%15 = phi i32 [ %13, %11 ], [ 1, %16 ]
br label %16
16: ; preds = %18, %14
%17 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %17, label %18 [
i32 -1, label %22
i32 118, label %14
i32 110, label %11
i32 100, label %19
]
18: ; preds = %16, %19
br label %16
19: ; preds = %16
%20 = load i32, i32* @optarg
%21 = call i32 @sscanf(i32 %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
br label %18
22: ; preds = %16
%23 = load i32, i32* @optind
%24 = icmp slt i32 %23, %0
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @usage(i8* %10)
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %22
%32 = add nsw i32 %23, 1
store i32 %32, i32* @optind
%33 = icmp slt i32 %32, %0
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = sext i32 %32 to i64
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = call i32 @usage(i8* %10)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %31
%44 = sext i32 %23 to i64
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = call i32 @ext4fixup_internal(i8* %46, i32 %15, i32 %12, i32 %47, i32 %48, i32 %49)
ret i32 %50
}