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

/* Variables and functions */
int /*<<< orphan*/ closedisk();
int /*<<< orphan*/ dumpbits(int /*<<< orphan*/);
int /*<<< orphan*/ dumpdir(int);
int /*<<< orphan*/ dumpsb();
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ opendisk(char *);
int main(int argc, char **argv) {
  u_int32_t nblocks;
  if (argc != 2) {
    errx(1, "Usage: dumpsfs device/diskfile");
  }
  opendisk(argv[1]);
  nblocks = dumpsb();
  dumpbits(nblocks);
  dumpdir(1);
  closedisk();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x31>
mov    $0x1,%edi
lea    0xe74(%rip),%rsi
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <opendisk@plt>
mov    $0x0,%al
call   1060 <dumpsb@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1080 <dumpbits@plt>
mov    $0x1,%edi
call   1040 <dumpdir@plt>
mov    $0x0,%al
call   1070 <closedisk@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     117a <main+0x1a>
lea    0xe90(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
mov    0x8(%rbx),%rdi
call   1050 <opendisk@plt>
xor    %eax,%eax
call   1060 <dumpsb@plt>
mov    %eax,%edi
call   1080 <dumpbits@plt>
mov    $0x1,%edi
call   1040 <dumpdir@plt>
xor    %eax,%eax
call   1070 <closedisk@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: dumpsfs device/diskfile\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @errx(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @opendisk(i8* %14)
%16 = call i32 (...) @dumpsb()
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i32 @dumpbits(i32 %17)
%19 = call i32 @dumpdir(i32 1)
%20 = call i32 (...) @closedisk()
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Usage: dumpsfs device/diskfile\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @opendisk(i8* %8)
%10 = tail call i32 (...) @dumpsb()
%11 = tail call i32 @dumpbits(i32 %10)
%12 = tail call i32 @dumpdir(i32 1)
%13 = tail call i32 (...) @closedisk()
ret i32 0
}