#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
scalar_t__ system(char *);
int udisk_mount(char dev_list[][255 + 1], char dev_list_mounted[][255 + 1],
                char *directory) {
  int i, j;
  char cmd[255 + 1];
  int flag;
  fprintf(stdout, "--------------------udisk mount--------------------\n");
  i = 0;
  flag = 1;
  while (dev_list[i][0] != '\0') {
    j = 0;
    while (dev_list_mounted[j][0] != '\0') {
      if (strcmp(dev_list[i], dev_list_mounted[j]) == 0) {
        flag = 0;
        break;
      }
      j++;
    }
    if (flag == 1) {
      fprintf(stdout, "mount %s to %s\n", dev_list[i], directory);
      snprintf(cmd, 255, "sudo mount %s %s\n", dev_list[i], directory);
      if (system(cmd) < 0) {
        return -1;
      }
      flag = 2;
      break;
    }
    i++;
  }
  fprintf(stdout,
          "--------------------udisk mount end--------------------\n\n");
  if (flag == 2) {
    return 0;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<udisk_mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x134(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a7 <udisk_mount+0x167>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1206 <udisk_mount+0xc6>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x28(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <udisk_mount+0xb8>
movl   $0x0,-0x134(%rbp)
jmp    1206 <udisk_mount+0xc6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a1 <udisk_mount+0x61>
cmpl   $0x1,-0x134(%rbp)
jne    1299 <udisk_mount+0x159>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rcx
mov    -0x20(%rbp),%r8
mov    $0xff,%esi
lea    0xde2(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x130(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
jge    128a <udisk_mount+0x14a>
movl   $0xffffffff,-0x4(%rbp)
jmp    12de <udisk_mount+0x19e>
movl   $0x2,-0x134(%rbp)
jmp    12a7 <udisk_mount+0x167>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117f <udisk_mount+0x3f>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpl   $0x2,-0x134(%rbp)
jne    12d7 <udisk_mount+0x197>
movl   $0x0,-0x4(%rbp)
jmp    12de <udisk_mount+0x19e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udisk_mount>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
cmpb   $0x0,(%r12)
je     11e2 <udisk_mount+0xa2>
mov    $0x1,%r14b
xor    %r13d,%r13d
mov    %r12,%rbx
jmp    11af <udisk_mount+0x6f>
cs nopw 0x0(%rax,%rax,1)
nop
test   $0x1,%r14b
jne    1212 <udisk_mount+0xd2>
add    $0x1,%r13
mov    %r13,%rax
shl    $0x8,%rax
lea    (%r12,%rax,1),%rbx
xor    %r14d,%r14d
cmpb   $0x0,(%r12,%rax,1)
je     11e2 <udisk_mount+0xa2>
cmpb   $0x0,(%r15)
mov    %r15,%rbp
je     1190 <udisk_mount+0x50>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1196 <udisk_mount+0x56>
cmpb   $0x0,0x100(%rbp)
lea    0x100(%rbp),%rbp
jne    11c0 <udisk_mount+0x80>
jmp    1190 <udisk_mount+0x50>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dc7(%rip),%r14
mov    (%r14),%edi
lea    0xe12(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdx
mov    0x8(%rsp),%r12
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe07(%rip),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0xff,%esi
mov    %rbx,%rcx
mov    %r12,%r8
call   1040 <snprintf@plt>
mov    %r15,%rdi
call   1030 <system@plt>
test   %rax,%rax
js     11f9 <udisk_mount+0xb9>
mov    (%r14),%edi
lea    0xdea(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11fe <udisk_mount+0xbe>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [53 x i8] c"--------------------udisk mount--------------------\0A\00"
@.str.1 = [16 x i8] c"mount %s to %s\0A\00"
@.str.2 = [18 x i8] c"sudo mount %s %s\0A\00"
@.str.3 = [58 x i8] c"--------------------udisk mount end--------------------\0A\0A\00"
define i32 @udisk_mount([256 x i8]* %0, [256 x i8]* %1, i8* %2) {
%4 = alloca i32
%5 = alloca [256 x i8]*
%6 = alloca [256 x i8]*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca i32
store [256 x i8]* %0, [256 x i8]** %5
store [256 x i8]* %1, [256 x i8]** %6
store i8* %2, i8** %7
%12 = load i32, i32* @stdout
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
store i32 1, i32* %11
br label %14
14: ; preds = %75, %3
%15 = load [256 x i8]*, [256 x i8]** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 %17
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %78
23: ; preds = %14
store i32 0, i32* %9
br label %24
24: ; preds = %47, %23
%25 = load [256 x i8]*, [256 x i8]** %6
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %25, i64 %27
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %28, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %24
%34 = load [256 x i8]*, [256 x i8]** %5
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %34, i64 %36
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %37, i64 0, i64 0
%39 = load [256 x i8]*, [256 x i8]** %6
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %39, i64 %41
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %42, i64 0, i64 0
%44 = call i64 @strcmp(i8* %38, i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %33
store i32 0, i32* %11
br label %50
47: ; preds = %33
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %24
50: ; preds = %46, %24
%51 = load i32, i32* %11
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %75
53: ; preds = %50
%54 = load i32, i32* @stdout
%55 = load [256 x i8]*, [256 x i8]** %5
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %55, i64 %57
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %58, i64 0, i64 0
%60 = load i8*, i8** %7
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %59, i8* %60)
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%63 = load [256 x i8]*, [256 x i8]** %5
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %63, i64 %65
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %66, i64 0, i64 0
%68 = load i8*, i8** %7
%69 = call i32 @snprintf(i8* %62, i32 255, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %67, i8* %68)
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%71 = call i64 @system(i8* %70)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %53
store i32 -1, i32* %4
br label %85
74: ; preds = %53
store i32 2, i32* %11
br label %78
75: ; preds = %50
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %14
78: ; preds = %74, %14
%79 = load i32, i32* @stdout
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%81 = load i32, i32* %11
%82 = icmp eq i32 %81, 2
br i1 %82, label %83, label %84
83: ; preds = %78
store i32 0, i32* %4
br label %85
84: ; preds = %78
store i32 -1, i32* %4
br label %85
85: ; preds = %84, %83, %73
%86 = load i32, i32* %4
ret i32 %86
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [53 x i8] c"--------------------udisk mount--------------------\0A\00"
@.str.1 = [16 x i8] c"mount %s to %s\0A\00"
@.str.2 = [18 x i8] c"sudo mount %s %s\0A\00"
@.str.3 = [58 x i8] c"--------------------udisk mount end--------------------\0A\0A\00"
define i32 @udisk_mount([256 x i8]* %0, [256 x i8]* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @stdout
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %0, i64 0, i64 0
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %41, label %11
11: ; preds = %3
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
br label %13
13: ; preds = %11, %36
%14 = phi i64 [ 0, %11 ], [ %37, %36 ]
%15 = phi i8* [ %8, %11 ], [ %38, %36 ]
%16 = phi i1 [ true, %11 ], [ false, %36 ]
%17 = load i8, i8* %12
%18 = icmp eq i8 %17, 0
br i1 %18, label %29, label %23
19: ; preds = %23
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 %28, i64 0
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %13, %19
%24 = phi i64 [ %28, %19 ], [ 0, %13 ]
%25 = phi i8* [ %20, %19 ], [ %12, %13 ]
%26 = tail call i64 @strcmp(i8* %15, i8* %25)
%27 = icmp eq i64 %26, 0
%28 = add nuw i64 %24, 1
br i1 %27, label %36, label %19
29: ; preds = %19, %13
br i1 %16, label %30, label %36
30: ; preds = %29
%31 = load i32, i32* @stdout
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %2)
%33 = call i32 @snprintf(i8* %5, i32 255, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %2)
%34 = call i64 @system(i8* %5)
%35 = icmp slt i64 %34, 0
br i1 %35, label %47, label %44
36: ; preds = %23, %29
%37 = add nuw i64 %14, 1
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %0, i64 %37, i64 0
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %41, label %13
41: ; preds = %36, %3
%42 = load i32, i32* @stdout
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %47
44: ; preds = %30
%45 = load i32, i32* @stdout
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %44, %41, %30
%48 = phi i32 [ -1, %30 ], [ 0, %44 ], [ -1, %41 ]
ret i32 %48
}