#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 EXIT_SUCCESS;
int /*<<< orphan*/ mkfs(char const *, char const *, int);
int /*<<< orphan*/ printf(char *, char const *, char const *, unsigned int,
                          unsigned int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  unsigned ninodes;
  unsigned nblocks;
  const char *diskfile;
  const char *fs_name;
  if (argc < 5)
    usage();
  diskfile = argv[1];
  fs_name = argv[2];
  sscanf(argv[3], "%u", &ninodes);
  sscanf(argv[4], "%u", &nblocks);
  printf("fs: mkfs %s,%s,%d,%d\n", diskfile, fs_name, ninodes, nblocks);
  int size = ninodes << 16;
  size = size + nblocks;
  mkfs(diskfile, fs_name, size);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1167 <main+0x27>
mov    $0x0,%al
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe72(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe5a(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <mkfs@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jg     1157 <main+0x17>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%r14
mov    0x18(%rbx),%rdi
lea    0xe96(%rip),%r12
lea    0x4(%rsp),%rdx
mov    %r12,%rsi
call   1050 <sscanf@plt>
mov    0x20(%rbx),%rdi
mov    %rsp,%rdx
mov    %r12,%rsi
call   1050 <sscanf@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%r8d
lea    0xe6e(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
shl    $0x10,%edx
add    (%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <mkfs@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [22 x i8] c"fs: mkfs %s,%s,%d,%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @usage()
br label %15
15: ; preds = %13, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
store i8* %21, i8** %9
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%30 = load i8*, i8** %8
%31 = load i8*, i8** %9
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %31, i32 %32, i32 %33)
%35 = load i32, i32* %6
%36 = shl i32 %35, 16
store i32 %36, i32* %10
%37 = load i32, i32* %10
%38 = load i32, i32* %7
%39 = add i32 %37, %38
store i32 %39, i32* %10
%40 = load i8*, i8** %8
%41 = load i8*, i8** %9
%42 = load i32, i32* %10
%43 = call i32 @mkfs(i8* %40, i8* %41, i32 %42)
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [22 x i8] c"fs: mkfs %s,%s,%d,%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp slt i32 %0, 5
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (...) @usage()
br label %10
10: ; preds = %8, %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%18 = getelementptr inbounds i8*, i8** %1, i64 4
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %14, i32 %21, i32 %22)
%24 = load i32, i32* %3
%25 = shl i32 %24, 16
%26 = load i32, i32* %4
%27 = add i32 %25, %26
%28 = call i32 @mkfs(i8* %12, i8* %14, i32 %27)
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}