#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 */
scalar_t__ createDisk(char *, unsigned long);
scalar_t__ fileExist(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int newraid(char *path, int size) {
  if (size >= 2 && size <= 10) {
    char string[256];
    strcpy(string, path);
    strcat(string, "drive.dat");
    if (fileExist(string)) {
      perror("Ya existe una unidad en esta ubicación");
      return 0;
    } else {
      unsigned long bytes = size * 1024 * 1024;
      unsigned long n = bytes / 128;
      if (createDisk(path, n))
        printf("Unidad creada exitosamente\n %sdrive.dat", path);
      else
        perror("Error al intentar crear la unidad");
    }
  } else
    return 0;
}


x86 assembly (clang, -O0):
<newraid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jl     1240 <newraid+0xe0>
cmpl   $0xa,-0x14(%rbp)
jg     1240 <newraid+0xe0>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x120(%rbp),%rdi
call   1080 <fileExist@plt>
cmp    $0x0,%rax
je     11d7 <newraid+0x77>
lea    0xe3a(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <newraid+0xe7>
mov    -0x14(%rbp),%eax
shl    $0xa,%eax
shl    $0xa,%eax
cltq
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
shr    $0x7,%rax
mov    %rax,-0x130(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x130(%rbp),%rsi
call   1050 <createDisk@plt>
cmp    $0x0,%rax
je     122a <newraid+0xca>
mov    -0x10(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
jmp    1236 <newraid+0xd6>
lea    0xe1f(%rip),%rdi
call   1060 <perror@plt>
jmp    123b <newraid+0xdb>
jmp    1247 <newraid+0xe7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newraid>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ebx
lea    -0x2(%rbx),%eax
cmp    $0x8,%eax
ja     11cb <newraid+0x6b>
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xeb8(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
mov    %r15,%rdi
call   1080 <fileExist@plt>
test   %rax,%rax
jne    11da <newraid+0x7a>
shl    $0xd,%ebx
and    $0x1ffe000,%ebx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <createDisk@plt>
test   %rax,%rax
je     11e3 <newraid+0x83>
lea    0xe65(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe1f(%rip),%rdi
jmp    11ea <newraid+0x8a>
lea    0xe66(%rip),%rdi
call   1060 <perror@plt>
jmp    11cb <newraid+0x6b>

LLVM IR (-O0):
@.str = [10 x i8] c"drive.dat\00"
@.str.1 = [40 x i8] c"Ya existe una unidad en esta ubicaci\C3\B3n\00"
@.str.2 = [40 x i8] c"Unidad creada exitosamente\0A %sdrive.dat\00"
@.str.3 = [34 x i8] c"Error al intentar crear la unidad\00"
define i32 @newraid(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %43
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 10
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%21 = call i64 @fileExist(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %44
25: ; preds = %14
%26 = load i32, i32* %5
%27 = mul nsw i32 %26, 1024
%28 = mul nsw i32 %27, 1024
%29 = sext i32 %28 to i64
store i64 %29, i64* %7
%30 = load i64, i64* %7
%31 = udiv i64 %30, 128
store i64 %31, i64* %8
%32 = load i8*, i8** %4
%33 = load i64, i64* %8
%34 = call i64 @createDisk(i8* %32, i64 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %25
%37 = load i8*, i8** %4
%38 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %41
39: ; preds = %25
%40 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
br label %42
42: ; preds = %41
br label %44
43: ; preds = %11, %2
store i32 0, i32* %3
br label %44
44: ; preds = %23, %43, %42
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [10 x i8] c"drive.dat\00"
@.str.1 = [40 x i8] c"Ya existe una unidad en esta ubicaci\C3\B3n\00"
@.str.2 = [40 x i8] c"Unidad creada exitosamente\0A %sdrive.dat\00"
@.str.3 = [34 x i8] c"Error al intentar crear la unidad\00"
define i32 @newraid(i8* %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = add i32 %1, -2
%5 = icmp ult i32 %4, 9
br i1 %5, label %6, label %25
6: ; preds = %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* %0)
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = call i64 @fileExist(i8* %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %24
14: ; preds = %6
%15 = shl nuw nsw i32 %1, 13
%16 = and i32 %15, 33546240
%17 = zext i32 %16 to i64
%18 = call i64 @createDisk(i8* %0, i64 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %24
22: ; preds = %14
%23 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %20, %22, %12
br label %25
25: ; preds = %2, %24
ret i32 0
}