#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 atoi(char *);
int /*<<< orphan*/ bmount(char *);
int /*<<< orphan*/ bumount();
int /*<<< orphan*/ bwrite(int, unsigned char *);
int /*<<< orphan*/ initAI(int);
int /*<<< orphan*/ initMB(int);
int /*<<< orphan*/ initSB(int, char *);
int /*<<< orphan*/ leerSB();
int main(int argc, char **argv) {
  if (argc == 3) {
    bmount(argv[1]);
    int nbloques = atoi(argv[2]);
    if (nbloques < 0) {
      nbloques = nbloques * (-1);
    }
    unsigned char buffer[1024];
    int i;
    for (i = 0; i < nbloques; i++) {
      bwrite(i, buffer);
    }
    initSB(nbloques, argv[1]);
    initMB(nbloques);
    initAI(nbloques);
    leerSB();
    bumount();
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    123e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <bmount@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d1 <main+0x51>
imul   $0xffffffff,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x424(%rbp)
mov    -0x424(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1210 <main+0x90>
mov    -0x424(%rbp),%edi
lea    -0x420(%rbp),%rsi
call   1030 <bwrite@plt>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    11db <main+0x5b>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1080 <initSB@plt>
mov    -0x14(%rbp),%edi
call   1070 <initMB@plt>
mov    -0x14(%rbp),%edi
call   1060 <initAI@plt>
mov    $0x0,%al
call   10a0 <leerSB@plt>
mov    $0x0,%al
call   1040 <bumount@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x3,%edi
jne    121a <main+0x9a>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <bmount@plt>
mov    0x10(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
neg    %r15d
cmovs  %eax,%r15d
jae    11e1 <main+0x61>
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovae %r15d,%ebp
xor    %ebx,%ebx
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12,%rsi
call   1030 <bwrite@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    11d0 <main+0x50>
mov    0x8(%r14),%rsi
mov    %r15d,%edi
call   1080 <initSB@plt>
mov    %r15d,%edi
call   1070 <initMB@plt>
mov    %r15d,%edi
call   1060 <initAI@plt>
xor    %eax,%eax
call   10a0 <leerSB@plt>
xor    %eax,%eax
call   1040 <bumount@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %49
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @bmount(i8* %14)
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %11
%23 = load i32, i32* %6
%24 = mul nsw i32 %23, -1
store i32 %24, i32* %6
br label %25
25: ; preds = %22, %11
store i32 0, i32* %8
br label %26
26: ; preds = %34, %25
%27 = load i32, i32* %8
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i32, i32* %8
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%33 = call i32 @bwrite(i32 %31, i8* %32)
br label %34
34: ; preds = %30
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %26
37: ; preds = %26
%38 = load i32, i32* %6
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @initSB(i32 %38, i8* %41)
%43 = load i32, i32* %6
%44 = call i32 @initMB(i32 %43)
%45 = load i32, i32* %6
%46 = call i32 @initAI(i32 %45)
%47 = call i32 (...) @leerSB()
%48 = call i32 (...) @bumount()
br label %49
49: ; preds = %37, %2
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %5, label %29
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @bmount(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 @llvm.abs.i32(i32 %11, i1 true)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = icmp eq i32 %11, 0
br i1 %14, label %22, label %15
15: ; preds = %5
%16 = call i32 @llvm.umax.i32(i32 %12, i32 1)
br label %17
17: ; preds = %15, %17
%18 = phi i32 [ %20, %17 ], [ 0, %15 ]
%19 = call i32 @bwrite(i32 %18, i8* %13)
%20 = add nuw i32 %18, 1
%21 = icmp eq i32 %20, %16
br i1 %21, label %22, label %17
22: ; preds = %17, %5
%23 = load i8*, i8** %6
%24 = call i32 @initSB(i32 %12, i8* %23)
%25 = call i32 @initMB(i32 %12)
%26 = call i32 @initAI(i32 %12)
%27 = call i32 (...) @leerSB()
%28 = call i32 (...) @bumount()
br label %29
29: ; preds = %22, %2
ret i32 0
}