#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*/ cmd;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int is_special_backup_format(char *dev) {
  int ret = 0;
  int i = 0;
  FILE *fp;
  char cmd[128], buf[256];
  memset(cmd, 0, 128);
  memset(buf, 0, 256);
  snprintf(cmd, sizeof(cmd),
           "/bin/mount | grep '/mnt/%s' | awk '{print$5}' > "
           "/tmp/disk_special_format",
           dev);
  system(cmd);
  if (!(fp = fopen("/tmp/disk_special_format", "r")))
    return -1;
  fgets(buf, sizeof(buf), fp);
  fclose(fp);
  i = 0;
  while (buf[i] != '\0' && buf[i] != '\r' && buf[i] != '\n')
    i++;
  buf[i] = '\0';
  if (!strcmp(buf, "hfsplus") || !strcmp(buf, "xfs") || !strcmp(buf, "ntfs") ||
      !strcmp(buf, "ext2") || !strcmp(buf, "ext3") || !strcmp(buf, "ext4"))
    ret = 1;
  return ret;
}


x86 assembly (clang, -O0):
<is_special_backup_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xe36(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <system@plt>
lea    0xe4e(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1208 <is_special_backup_format+0x98>
movl   $0xffffffff,-0x4(%rbp)
jmp    1361 <is_special_backup_format+0x1f1>
lea    -0x1a0(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movsbl -0x1a0(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1a1(%rbp)
je     127f <is_special_backup_format+0x10f>
movslq -0x18(%rbp),%rax
movsbl -0x1a0(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x1a1(%rbp)
je     127f <is_special_backup_format+0x10f>
movslq -0x18(%rbp),%rax
movsbl -0x1a0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
setne  %al
mov    %al,-0x1a1(%rbp)
mov    -0x1a1(%rbp),%al
test   $0x1,%al
jne    1292 <is_special_backup_format+0x122>
jmp    12a0 <is_special_backup_format+0x130>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    122d <is_special_backup_format+0xbd>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x1a0(%rbp,%rax,1)
lea    -0x1a0(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     1354 <is_special_backup_format+0x1e4>
lea    -0x1a0(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     1354 <is_special_backup_format+0x1e4>
lea    -0x1a0(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     1354 <is_special_backup_format+0x1e4>
lea    -0x1a0(%rbp),%rdi
lea    0xd4e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     1354 <is_special_backup_format+0x1e4>
lea    -0x1a0(%rbp),%rdi
lea    0xd37(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     1354 <is_special_backup_format+0x1e4>
lea    -0x1a0(%rbp),%rdi
lea    0xd20(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    135b <is_special_backup_format+0x1eb>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_special_backup_format>:
push   %r14
push   %rbx
sub    $0x188,%rsp
mov    %rdi,%rbx
lea    0x100(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    0xe66(%rip),%rdx
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
lea    0xe77(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1281 <is_special_backup_format+0x121>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
mov    $0x2401,%ecx
jmp    1204 <is_special_backup_format+0xa4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
movzbl (%rsp,%rax,1),%edx
cmp    $0xd,%rdx
ja     1200 <is_special_backup_format+0xa0>
bt     %rdx,%rcx
jae    1200 <is_special_backup_format+0xa0>
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    (%rsp),%rax
movabs $0x73756c70736668,%rcx
cmp    %rcx,%rax
je     127a <is_special_backup_format+0x11a>
cmp    $0x736678,%eax
je     127a <is_special_backup_format+0x11a>
mov    $0x7366746e,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     127a <is_special_backup_format+0x11a>
mov    $0x32747865,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     127a <is_special_backup_format+0x11a>
mov    $0x33747865,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     127a <is_special_backup_format+0x11a>
mov    $0x34747865,%ecx
xor    (%rsp),%ecx
movzbl 0x4(%rsp),%edx
xor    %eax,%eax
or     %ecx,%edx
jne    1286 <is_special_backup_format+0x126>
mov    $0x1,%eax
jmp    1286 <is_special_backup_format+0x126>
mov    $0xffffffff,%eax
add    $0x188,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [73 x i8] c"/bin/mount | grep '/mnt/%s' | awk '{print$5}' > /tmp/disk_special_format\00"
@.str.1 = [25 x i8] c"/tmp/disk_special_format\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [8 x i8] c"hfsplus\00"
@.str.4 = [4 x i8] c"xfs\00"
@.str.5 = [5 x i8] c"ntfs\00"
@.str.6 = [5 x i8] c"ext2\00"
@.str.7 = [5 x i8] c"ext3\00"
@.str.8 = [5 x i8] c"ext4\00"
define i32 @is_special_backup_format(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca [128 x i8]
%8 = alloca [256 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 128)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 256)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @snprintf(i8* %13, i32 128, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%17 = call i32 @system(i8* %16)
%18 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %18, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %21, label %20
20: ; preds = %1
store i32 -1, i32* %2
br label %83
21: ; preds = %1
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%23 = load i32*, i32** %6
%24 = call i32 @fgets(i8* %22, i32 256, i32* %23)
%25 = load i32*, i32** %6
%26 = call i32 @fclose(i32* %25)
store i32 0, i32* %5
br label %27
27: ; preds = %50, %21
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %27
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 13
br i1 %40, label %41, label %48
41: ; preds = %34
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 10
br label %48
48: ; preds = %41, %34, %27
%49 = phi i1 [ false, %34 ], [ false, %27 ], [ %47, %41 ]
br i1 %49, label %50, label %53
50: ; preds = %48
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %27
53: ; preds = %48
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %55
store i8 0, i8* %56
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%58 = call i32 @strcmp(i8* %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %80
60: ; preds = %53
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%62 = call i32 @strcmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %80
64: ; preds = %60
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %80
68: ; preds = %64
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%70 = call i32 @strcmp(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %80
72: ; preds = %68
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%74 = call i32 @strcmp(i8* %73, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %72
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%78 = call i32 @strcmp(i8* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%79 = icmp ne i32 %78, 0
br i1 %79, label %81, label %80
80: ; preds = %76, %72, %68, %64, %60, %53
store i32 1, i32* %4
br label %81
81: ; preds = %80, %76
%82 = load i32, i32* %4
store i32 %82, i32* %2
br label %83
83: ; preds = %81, %20
%84 = load i32, i32* %2
ret i32 %84
}

LLVM IR (-O2):
@.str = [73 x i8] c"/bin/mount | grep '/mnt/%s' | awk '{print$5}' > /tmp/disk_special_format\00"
@.str.1 = [25 x i8] c"/tmp/disk_special_format\00"
@.str.2 = [2 x i8] c"r\00"
@.str.5 = [5 x i8] c"ntfs\00"
@.str.6 = [5 x i8] c"ext2\00"
@.str.7 = [5 x i8] c"ext3\00"
@.str.8 = [5 x i8] c"ext4\00"
define i32 @is_special_backup_format(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %4, i32 0, i32 128)
%7 = call i32 @memset(i8* %5, i32 0, i32 256)
%8 = call i32 @snprintf(i8* %4, i32 128, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @system(i8* %4)
%10 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %43, label %12
12: ; preds = %1
%13 = call i32 @fgets(i8* %5, i32 256, i32* %10)
%14 = call i32 @fclose(i32* %10)
br label %15
15: ; preds = %19, %12
%16 = phi i64 [ %20, %19 ], [ 0, %12 ]
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %16
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 0, label %21
i8 13, label %21
i8 10, label %21
]
19: ; preds = %15
%20 = add nuw i64 %16, 1
br label %15
21: ; preds = %15, %15, %15
%22 = and i64 %16, 4294967295
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %22
store i8 0, i8* %23
%24 = bitcast [256 x i8]* %3 to i64*
%25 = load i64, i64* %24
%26 = icmp eq i64 %25, 32498730925254248
%27 = trunc i64 %25 to i32
%28 = icmp eq i32 %27, 7562872
%29 = or i1 %26, %28
br i1 %29, label %42, label %30
30: ; preds = %21
%31 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 5)
%32 = icmp eq i32 %31, 0
br i1 %32, label %42, label %33
33: ; preds = %30
%34 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 5)
%35 = icmp eq i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i64 5)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %39, %36, %33, %30, %21
br label %43
43: ; preds = %39, %42, %1
%44 = phi i32 [ -1, %1 ], [ 0, %39 ], [ 1, %42 ]
ret i32 %44
}