#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 */
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int readlink(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
scalar_t__ stat(char *, struct stat *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int is_usb_fdd_for_host(int host_id) {
  int i;
  char path[PATH_MAX];
  char buf[1024];
  FILE *fp;
  struct stat st;
  sprintf(path, "/sys/class/scsi_host/host%d/device/../driver", host_id);
  if (stat(path, &st) == 0) {
    int n;
    if ((n = readlink(path, buf, sizeof(buf))) < 12 ||
        strncmp(buf + n - 12, "/usb-storage", 12) != 0) {
      return 0;
    }
    sprintf(path, "/sys/class/scsi_host/host%d/device/../bInterfaceClass",
            host_id);
    if ((fp = fopen(path, "r")) == NULL) {
      return 0;
    }
    if (fgets(buf, sizeof(buf), fp) == NULL || strcmp(buf, "08\n") != 0) {
      fclose(fp);
      return 0;
    }
    fclose(fp);
    sprintf(path, "/sys/class/scsi_host/host%d/device/../bInterfaceSubClass",
            host_id);
    if ((fp = fopen(path, "r")) == NULL) {
      return 0;
    }
    if (fgets(buf, sizeof(buf), fp) == NULL || strcmp(buf, "04\n") != 0) {
      fclose(fp);
      return 0;
    }
    fclose(fp);
    return 1;
  }
  sprintf(path, "/proc/scsi/usb-storage/%d", host_id);
  if ((fp = fopen(path, "r")) == NULL) {
    for (i = 0; i < 256; i++) {
      sprintf(path, "/proc/scsi/usb-storage-%d/%d", i, host_id);
      if ((fp = fopen(path, "r")) != NULL) {
        break;
      }
    }
    if (fp == NULL) {
      return 0;
    }
  }
  while (fgets(buf, sizeof(buf), fp) != NULL) {
    if (strcmp(buf, "     Protocol: Uniform Floppy Interface (UFI)\n") == 0) {
      fclose(fp);
      return 1;
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<is_usb_fdd_for_host>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x440(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x440(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jne    13ec <is_usb_fdd_for_host+0x26c>
mov    -0x440(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1040 <readlink@plt>
mov    %eax,-0x434(%rbp)
cmp    $0xc,%eax
jl     1242 <is_usb_fdd_for_host+0xc2>
lea    -0x420(%rbp),%rdi
movslq -0x434(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffff4,%rdi
lea    0xdff(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1258 <is_usb_fdd_for_host+0xd8>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
mov    -0x440(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x440(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
jne    12aa <is_usb_fdd_for_host+0x12a>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12e9 <is_usb_fdd_for_host+0x169>
lea    -0x420(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     130b <is_usb_fdd_for_host+0x18b>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x440(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x440(%rbp),%rdi
lea    0xcee(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
jne    1369 <is_usb_fdd_for_host+0x1e9>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     13a8 <is_usb_fdd_for_host+0x228>
lea    -0x420(%rbp),%rdi
lea    0xd14(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     13ca <is_usb_fdd_for_host+0x24a>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
mov    -0x440(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xcb4(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x440(%rbp),%rdi
lea    0xc19(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
jne    14bc <is_usb_fdd_for_host+0x33c>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    1493 <is_usb_fdd_for_host+0x313>
mov    -0x440(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xc7b(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x440(%rbp),%rdi
lea    0xbc6(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
je     1480 <is_usb_fdd_for_host+0x300>
jmp    1493 <is_usb_fdd_for_host+0x313>
jmp    1485 <is_usb_fdd_for_host+0x305>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    142f <is_usb_fdd_for_host+0x2af>
cmpq   $0x0,-0x428(%rbp)
jne    14b7 <is_usb_fdd_for_host+0x337>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
jmp    14bc <is_usb_fdd_for_host+0x33c>
jmp    14c1 <is_usb_fdd_for_host+0x341>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1527 <is_usb_fdd_for_host+0x3a7>
lea    -0x420(%rbp),%rdi
lea    0xbf7(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1522 <is_usb_fdd_for_host+0x3a2>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
jmp    1544 <is_usb_fdd_for_host+0x3c4>
jmp    14c1 <is_usb_fdd_for_host+0x341>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x438(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_usb_fdd_for_host>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %edi,%r14d
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe48(%rip),%rsi
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    -0x30(%rbp),%rsi
mov    %r12,%rdi
call   1080 <stat@plt>
test   %rax,%rax
je     125d <is_usb_fdd_for_host+0xdd>
lea    0xecd(%rip),%rsi
mov    %r12,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xe33(%rip),%rsi
mov    %r12,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1311 <is_usb_fdd_for_host+0x191>
mov    %r14d,%r15d
lea    0xe15(%rip),%r13
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %r12,%rdi
lea    0xea1(%rip),%rsi
mov    %r14d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
jne    130e <is_usb_fdd_for_host+0x18e>
add    $0x1,%r14d
cmp    $0x100,%r14d
jne    1220 <is_usb_fdd_for_host+0xa0>
jmp    135d <is_usb_fdd_for_host+0x1dd>
lea    -0x430(%rbp),%rsi
mov    %r12,%rdi
mov    $0x400,%edx
call   1040 <readlink@plt>
cmp    $0xc,%eax
jl     1360 <is_usb_fdd_for_host+0x1e0>
mov    %eax,%eax
lea    (%rax,%rbp,1),%rdi
add    $0xfffffffffffffbc4,%rdi
lea    0xd9f(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1360 <is_usb_fdd_for_host+0x1e0>
lea    0xd92(%rip),%rsi
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xd6c(%rip),%rsi
mov    %r12,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1360 <is_usb_fdd_for_host+0x1e0>
mov    %rax,%rbx
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1304 <is_usb_fdd_for_host+0x184>
lea    0xd7d(%rip),%rsi
lea    -0x430(%rbp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1372 <is_usb_fdd_for_host+0x1f2>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1360 <is_usb_fdd_for_host+0x1e0>
mov    %rax,%rbx
lea    -0x430(%rbp),%r14
lea    0xdc9(%rip),%r15
nop
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1355 <is_usb_fdd_for_host+0x1d5>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1320 <is_usb_fdd_for_host+0x1a0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0x1,%r15d
jmp    1360 <is_usb_fdd_for_host+0x1e0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xcf3(%rip),%rsi
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xc93(%rip),%rsi
mov    %r12,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1360 <is_usb_fdd_for_host+0x1e0>
mov    %rax,%rbx
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1304 <is_usb_fdd_for_host+0x184>
lea    0xce1(%rip),%rsi
lea    -0x430(%rbp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1304 <is_usb_fdd_for_host+0x184>
jmp    1345 <is_usb_fdd_for_host+0x1c5>

LLVM IR (-O0):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [45 x i8] c"/sys/class/scsi_host/host%d/device/../driver\00"
@.str.1 = [13 x i8] c"/usb-storage\00"
@.str.2 = [54 x i8] c"/sys/class/scsi_host/host%d/device/../bInterfaceClass\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [4 x i8] c"08\0A\00"
@.str.5 = [57 x i8] c"/sys/class/scsi_host/host%d/device/../bInterfaceSubClass\00"
@.str.6 = [4 x i8] c"04\0A\00"
@.str.7 = [26 x i8] c"/proc/scsi/usb-storage/%d\00"
@.str.8 = [29 x i8] c"/proc/scsi/usb-storage-%d/%d\00"
@.str.9 = [47 x i8] c" Protocol: Uniform Floppy Interface (UFI)\0A\00"
define i32 @is_usb_fdd_for_host(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [1024 x i8]
%8 = alloca i32*
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %5
%15 = alloca i8, i64 %13
store i64 %13, i64* %6
%16 = load i32, i32* %3
%17 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i64 @stat(i8* %15, %struct.stat* %9)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %74
20: ; preds = %1
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%22 = call i32 @readlink(i8* %15, i8* %21, i32 1024)
store i32 %22, i32* %10
%23 = icmp slt i32 %22, 12
br i1 %23, label %32, label %24
24: ; preds = %20
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 -12
%30 = call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 12)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %24, %20
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
33: ; preds = %24
%34 = load i32, i32* %3
%35 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %36, i32** %8
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %39
38: ; preds = %33
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
39: ; preds = %33
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%41 = load i32*, i32** %8
%42 = call i32* @fgets(i8* %40, i32 1024, i32* %41)
%43 = icmp eq i32* %42, null
br i1 %43, label %48, label %44
44: ; preds = %39
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44, %39
%49 = load i32*, i32** %8
%50 = call i32 @fclose(i32* %49)
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
51: ; preds = %44
%52 = load i32*, i32** %8
%53 = call i32 @fclose(i32* %52)
%54 = load i32, i32* %3
%55 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %54)
%56 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %56, i32** %8
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %59
58: ; preds = %51
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
59: ; preds = %51
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%61 = load i32*, i32** %8
%62 = call i32* @fgets(i8* %60, i32 1024, i32* %61)
%63 = icmp eq i32* %62, null
br i1 %63, label %68, label %64
64: ; preds = %59
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %64, %59
%69 = load i32*, i32** %8
%70 = call i32 @fclose(i32* %69)
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
71: ; preds = %64
%72 = load i32*, i32** %8
%73 = call i32 @fclose(i32* %72)
store i32 1, i32* %2
store i32 1, i32* %11
br label %116
74: ; preds = %1
%75 = load i32, i32* %3
%76 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %75)
%77 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %77, i32** %8
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %99
79: ; preds = %74
store i32 0, i32* %4
br label %80
80: ; preds = %91, %79
%81 = load i32, i32* %4
%82 = icmp slt i32 %81, 256
br i1 %82, label %83, label %94
83: ; preds = %80
%84 = load i32, i32* %4
%85 = load i32, i32* %3
%86 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %84, i32 %85)
%87 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %87, i32** %8
%88 = icmp ne i32* %87, null
br i1 %88, label %89, label %90
89: ; preds = %83
br label %94
90: ; preds = %83
br label %91
91: ; preds = %90
%92 = load i32, i32* %4
%93 = add nsw i32 %92, 1
store i32 %93, i32* %4
br label %80
94: ; preds = %89, %80
%95 = load i32*, i32** %8
%96 = icmp eq i32* %95, null
br i1 %96, label %97, label %98
97: ; preds = %94
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
98: ; preds = %94
br label %99
99: ; preds = %98, %74
br label %100
100: ; preds = %112, %99
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%102 = load i32*, i32** %8
%103 = call i32* @fgets(i8* %101, i32 1024, i32* %102)
%104 = icmp ne i32* %103, null
br i1 %104, label %105, label %113
105: ; preds = %100
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%107 = call i64 @strcmp(i8* %106, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0))
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %105
%110 = load i32*, i32** %8
%111 = call i32 @fclose(i32* %110)
store i32 1, i32* %2
store i32 1, i32* %11
br label %116
112: ; preds = %105
br label %100
113: ; preds = %100
%114 = load i32*, i32** %8
%115 = call i32 @fclose(i32* %114)
store i32 0, i32* %2
store i32 1, i32* %11
br label %116
116: ; preds = %113, %109, %97, %71, %68, %58, %48, %38, %32
%117 = load i8*, i8** %5
%118 = load i32, i32* %2
ret i32 %118
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [45 x i8] c"/sys/class/scsi_host/host%d/device/../driver\00"
@.str.1 = [13 x i8] c"/usb-storage\00"
@.str.2 = [54 x i8] c"/sys/class/scsi_host/host%d/device/../bInterfaceClass\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [4 x i8] c"08\0A\00"
@.str.5 = [57 x i8] c"/sys/class/scsi_host/host%d/device/../bInterfaceSubClass\00"
@.str.6 = [4 x i8] c"04\0A\00"
@.str.7 = [26 x i8] c"/proc/scsi/usb-storage/%d\00"
@.str.8 = [29 x i8] c"/proc/scsi/usb-storage-%d/%d\00"
@.str.9 = [47 x i8] c" Protocol: Uniform Floppy Interface (UFI)\0A\00"
define i32 @is_usb_fdd_for_host(i32 %0) {
%2 = alloca [1024 x i8]
%3 = alloca %struct.stat
%4 = load i32, i32* @PATH_MAX
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = bitcast %struct.stat* %3 to i8*
%9 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = call i64 @stat(i8* %6, %struct.stat* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %48
12: ; preds = %1
%13 = call i32 @readlink(i8* %6, i8* %7, i32 1024)
%14 = icmp slt i32 %13, 12
br i1 %14, label %72, label %15
15: ; preds = %12
%16 = zext i32 %13 to i64
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 -12
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 12)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %72
21: ; preds = %15
%22 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%23 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %72, label %25
25: ; preds = %21
%26 = call i32* @fgets(i8* %7, i32 1024, i32* %23)
%27 = icmp eq i32* %26, null
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28, %25
%32 = call i32 @fclose(i32* %23)
br label %72
33: ; preds = %28
%34 = call i32 @fclose(i32* %23)
%35 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %0)
%36 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %72, label %38
38: ; preds = %33
%39 = call i32* @fgets(i8* %7, i32 1024, i32* %36)
%40 = icmp eq i32* %39, null
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %41, %38
%45 = call i32 @fclose(i32* %36)
br label %72
46: ; preds = %41
%47 = call i32 @fclose(i32* %36)
br label %72
48: ; preds = %1
%49 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %0)
%50 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %55, label %60
52: ; preds = %55
%53 = add nuw nsw i32 %56, 1
%54 = icmp eq i32 %53, 256
br i1 %54, label %72, label %55
55: ; preds = %48, %52
%56 = phi i32 [ %53, %52 ], [ 0, %48 ]
%57 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %56, i32 %0)
%58 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%59 = icmp eq i32* %58, null
br i1 %59, label %52, label %60
60: ; preds = %55, %48
%61 = phi i32* [ %50, %48 ], [ %58, %55 ]
br label %62
62: ; preds = %65, %60
%63 = call i32* @fgets(i8* %7, i32 1024, i32* %61)
%64 = icmp eq i32* %63, null
br i1 %64, label %70, label %65
65: ; preds = %62
%66 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %62
68: ; preds = %65
%69 = call i32 @fclose(i32* %61)
br label %72
70: ; preds = %62
%71 = call i32 @fclose(i32* %61)
br label %72
72: ; preds = %52, %31, %44, %46, %15, %12, %21, %33, %70, %68
%73 = phi i32 [ 1, %68 ], [ 0, %70 ], [ 0, %31 ], [ 0, %44 ], [ 1, %46 ], [ 0, %15 ], [ 0, %12 ], [ 0, %21 ], [ 0, %33 ], [ 0, %52 ]
ret i32 %73
}