#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
long fscanf(int /*<<< orphan*/ *, char *, long *);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int getDiscardInfo(const char *suffix, size_t *alignment_offset,
                   size_t *discard_max_bytes, size_t *discard_granularity,
                   size_t *discard_zeroes_data) {
  *discard_max_bytes = 0;
  *discard_granularity = 0;
  *discard_zeroes_data = 0;
  *alignment_offset = 0;
  char s[1000];
  sprintf(s, "/sys/block/%s/alignment_offset", suffix);
  FILE *fp = fopen(s, "rt");
  long ret = 0, d = 0;
  if (fp) {
    ret = fscanf(fp, "%ld", &d);
    if (ret == 1) {
      *alignment_offset = d;
    }
    if (fp) {
      fclose(fp);
      fp = NULL;
    }
  }
  sprintf(s, "/sys/block/%s/queue/discard_max_bytes", suffix);
  fp = fopen(s, "rt");
  ret = 0;
  d = 0;
  if (fp) {
    ret = fscanf(fp, "%ld", &d);
    if (ret == 1) {
      *discard_max_bytes = d;
    }
    fclose(fp);
    fp = NULL;
  }
  ret = 0;
  d = 0;
  sprintf(s, "/sys/block/%s/queue/discard_granularity", suffix);
  fp = fopen(s, "rt");
  if (fp) {
    ret = fscanf(fp, "%ld", &d);
    if (ret == 1) {
      *discard_granularity = d;
    }
    fclose(fp);
    fp = NULL;
  }
  ret = 0;
  d = 0;
  sprintf(s, "/sys/block/%s/queue/discard_zeroes_data", suffix);
  fp = fopen(s, "rt");
  if (fp) {
    ret = fscanf(fp, "%ld", &d);
    if (ret == 1) {
      *discard_zeroes_data = d;
    }
    fclose(fp);
    fp = NULL;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getDiscardInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe63(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x418(%rbp)
movq   $0x0,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
cmpq   $0x0,-0x418(%rbp)
je     1247 <getDiscardInfo+0x107>
mov    -0x418(%rbp),%rdi
lea    0xe34(%rip),%rsi
lea    -0x428(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x1,-0x420(%rbp)
01
jne    121d <getDiscardInfo+0xdd>
mov    -0x428(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x418(%rbp)
je     1242 <getDiscardInfo+0x102>
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x418(%rbp)
jmp    1247 <getDiscardInfo+0x107>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdcd(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x418(%rbp)
movq   $0x0,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
cmpq   $0x0,-0x418(%rbp)
je     12f0 <getDiscardInfo+0x1b0>
mov    -0x418(%rbp),%rdi
lea    0xd78(%rip),%rsi
lea    -0x428(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x1,-0x420(%rbp)
01
jne    12d9 <getDiscardInfo+0x199>
mov    -0x428(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x418(%rbp)
movq   $0x0,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xd34(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xcf4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
je     1399 <getDiscardInfo+0x259>
mov    -0x418(%rbp),%rdi
lea    0xccf(%rip),%rsi
lea    -0x428(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x1,-0x420(%rbp)
01
jne    1382 <getDiscardInfo+0x242>
mov    -0x428(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x418(%rbp)
movq   $0x0,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xcb3(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xc4b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
je     1442 <getDiscardInfo+0x302>
mov    -0x418(%rbp),%rdi
lea    0xc26(%rip),%rsi
lea    -0x428(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x1,-0x420(%rbp)
01
jne    142b <getDiscardInfo+0x2eb>
mov    -0x428(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x418(%rbp)
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDiscardInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r13
movq   $0x0,(%rdx)
movq   $0x0,(%rcx)
movq   $0x0,(%r8)
movq   $0x0,(%rsi)
lea    0xe7d(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rdx
call   1060 <sprintf@plt>
lea    0xe85(%rip),%rsi
mov    %rbp,%rdi
call   1050 <fopen@plt>
movq   $0x0,0x8(%rsp)
test   %rax,%rax
je     11dd <getDiscardInfo+0x9d>
mov    %rax,%rbp
lea    0xe68(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%rax
jne    11d5 <getDiscardInfo+0x95>
mov    0x8(%rsp),%rax
mov    %rax,(%rbx)
mov    %rbp,%rdi
call   1030 <fclose@plt>
lea    0xe42(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rdx
call   1060 <sprintf@plt>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
movq   $0x0,0x8(%rsp)
test   %rax,%rax
je     123f <getDiscardInfo+0xff>
mov    %rax,%rbx
lea    0xe07(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%rax
jne    1237 <getDiscardInfo+0xf7>
mov    0x8(%rsp),%rax
mov    %rax,(%r12)
mov    %rbx,%rdi
call   1030 <fclose@plt>
movq   $0x0,0x8(%rsp)
lea    0xdfd(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rdx
call   1060 <sprintf@plt>
lea    0xdb9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     12a0 <getDiscardInfo+0x160>
mov    %rax,%rbx
lea    0xda5(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%rax
jne    1298 <getDiscardInfo+0x158>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
mov    %rbx,%rdi
call   1030 <fclose@plt>
movq   $0x0,0x8(%rsp)
lea    0xdc4(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rdx
call   1060 <sprintf@plt>
lea    0xd58(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     1301 <getDiscardInfo+0x1c1>
mov    %rax,%rbx
lea    0xd44(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%rax
jne    12f9 <getDiscardInfo+0x1b9>
mov    0x8(%rsp),%rax
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"/sys/block/%s/alignment_offset\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [38 x i8] c"/sys/block/%s/queue/discard_max_bytes\00"
@.str.4 = [40 x i8] c"/sys/block/%s/queue/discard_granularity\00"
@.str.5 = [40 x i8] c"/sys/block/%s/queue/discard_zeroes_data\00"
define i32 @getDiscardInfo(i8* %0, i64* %1, i64* %2, i64* %3, i64* %4) {
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca [1000 x i8]
%12 = alloca i32*
%13 = alloca i64
%14 = alloca i64
store i8* %0, i8** %6
store i64* %1, i64** %7
store i64* %2, i64** %8
store i64* %3, i64** %9
store i64* %4, i64** %10
%15 = load i64*, i64** %8
store i64 0, i64* %15
%16 = load i64*, i64** %9
store i64 0, i64* %16
%17 = load i64*, i64** %10
store i64 0, i64* %17
%18 = load i64*, i64** %7
store i64 0, i64* %18
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %12
store i64 0, i64* %13
store i64 0, i64* %14
%24 = load i32*, i32** %12
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %41
26: ; preds = %5
%27 = load i32*, i32** %12
%28 = call i64 @fscanf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %14)
store i64 %28, i64* %13
%29 = load i64, i64* %13
%30 = icmp eq i64 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i64, i64* %14
%33 = load i64*, i64** %7
store i64 %32, i64* %33
br label %34
34: ; preds = %31, %26
%35 = load i32*, i32** %12
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32*, i32** %12
%39 = call i32 @fclose(i32* %38)
store i32* null, i32** %12
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40, %5
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%43 = load i8*, i8** %6
%44 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %46, i32** %12
store i64 0, i64* %13
store i64 0, i64* %14
%47 = load i32*, i32** %12
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %60
49: ; preds = %41
%50 = load i32*, i32** %12
%51 = call i64 @fscanf(i32* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %14)
store i64 %51, i64* %13
%52 = load i64, i64* %13
%53 = icmp eq i64 %52, 1
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i64, i64* %14
%56 = load i64*, i64** %8
store i64 %55, i64* %56
br label %57
57: ; preds = %54, %49
%58 = load i32*, i32** %12
%59 = call i32 @fclose(i32* %58)
store i32* null, i32** %12
br label %60
60: ; preds = %57, %41
store i64 0, i64* %13
store i64 0, i64* %14
%61 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%62 = load i8*, i8** %6
%63 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %62)
%64 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %65, i32** %12
%66 = load i32*, i32** %12
%67 = icmp ne i32* %66, null
br i1 %67, label %68, label %79
68: ; preds = %60
%69 = load i32*, i32** %12
%70 = call i64 @fscanf(i32* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %14)
store i64 %70, i64* %13
%71 = load i64, i64* %13
%72 = icmp eq i64 %71, 1
br i1 %72, label %73, label %76
73: ; preds = %68
%74 = load i64, i64* %14
%75 = load i64*, i64** %9
store i64 %74, i64* %75
br label %76
76: ; preds = %73, %68
%77 = load i32*, i32** %12
%78 = call i32 @fclose(i32* %77)
store i32* null, i32** %12
br label %79
79: ; preds = %76, %60
store i64 0, i64* %13
store i64 0, i64* %14
%80 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%81 = load i8*, i8** %6
%82 = call i32 @sprintf(i8* %80, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %81)
%83 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%84 = call i32* @fopen(i8* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %84, i32** %12
%85 = load i32*, i32** %12
%86 = icmp ne i32* %85, null
br i1 %86, label %87, label %98
87: ; preds = %79
%88 = load i32*, i32** %12
%89 = call i64 @fscanf(i32* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %14)
store i64 %89, i64* %13
%90 = load i64, i64* %13
%91 = icmp eq i64 %90, 1
br i1 %91, label %92, label %95
92: ; preds = %87
%93 = load i64, i64* %14
%94 = load i64*, i64** %10
store i64 %93, i64* %94
br label %95
95: ; preds = %92, %87
%96 = load i32*, i32** %12
%97 = call i32 @fclose(i32* %96)
store i32* null, i32** %12
br label %98
98: ; preds = %95, %79
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"/sys/block/%s/alignment_offset\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [38 x i8] c"/sys/block/%s/queue/discard_max_bytes\00"
@.str.4 = [40 x i8] c"/sys/block/%s/queue/discard_granularity\00"
@.str.5 = [40 x i8] c"/sys/block/%s/queue/discard_zeroes_data\00"
define i32 @getDiscardInfo(i8* %0, i64* nocapture writeonly %1, i64* nocapture writeonly %2, i64* nocapture writeonly %3, i64* nocapture writeonly %4) {
%6 = alloca [1000 x i8]
%7 = alloca i64
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %1
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%12 = icmp eq i32* %10, null
br i1 %12, label %20, label %13
13: ; preds = %5
%14 = call i64 @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %7)
%15 = icmp eq i64 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i64, i64* %7
store i64 %17, i64* %1
br label %18
18: ; preds = %13, %16
%19 = call i32 @fclose(i32* %10)
br label %20
20: ; preds = %18, %5
%21 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%22 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %7
%23 = icmp eq i32* %22, null
br i1 %23, label %31, label %24
24: ; preds = %20
%25 = call i64 @fscanf(i32* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %7)
%26 = icmp eq i64 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = load i64, i64* %7
store i64 %28, i64* %2
br label %29
29: ; preds = %27, %24
%30 = call i32 @fclose(i32* %22)
br label %31
31: ; preds = %29, %20
store i64 0, i64* %7
%32 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%33 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %42, label %35
35: ; preds = %31
%36 = call i64 @fscanf(i32* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %7)
%37 = icmp eq i64 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i64, i64* %7
store i64 %39, i64* %3
br label %40
40: ; preds = %38, %35
%41 = call i32 @fclose(i32* %33)
br label %42
42: ; preds = %40, %31
store i64 0, i64* %7
%43 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%44 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %53, label %46
46: ; preds = %42
%47 = call i64 @fscanf(i32* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %7)
%48 = icmp eq i64 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = load i64, i64* %7
store i64 %50, i64* %4
br label %51
51: ; preds = %49, %46
%52 = call i32 @fclose(i32* %44)
br label %53
53: ; preds = %51, %42
ret i32 0
}