#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 */
size_t INT_MAX;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
void getPhyLogSizes(const char *suffix, size_t *phy, size_t *max_io_bytes,
                    size_t *log) {
  *phy = 512;
  *log = 512;
  *max_io_bytes = INT_MAX;
  if (suffix) {
    char s[1000];
    sprintf(s, "/sys/block/%s/queue/physical_block_size", suffix);
    int d, ret;
    FILE *fp = fopen(s, "rt");
    if (!fp) {
    } else {
      ret = fscanf(fp, "%d", &d);
      if (ret == 1) {
        *phy = d;
      }
      if (fp) {
        fclose(fp);
        fp = NULL;
      }
    }
    sprintf(s, "/sys/block/%s/queue/max_sectors_kb", suffix);
    fp = fopen(s, "rt");
    if (!fp) {
    } else {
      ret = fscanf(fp, "%d", &d);
      if (ret == 1) {
        *max_io_bytes = d * 1024;
      }
      if (fp) {
        fclose(fp);
        fp = NULL;
      }
    }
    sprintf(s, "/sys/block/%s/queue/logical_block_size", suffix);
    fp = fopen(s, "rt");
    if (!fp) {
      *log = 512;
    } else {
      ret = fscanf(fp, "%d", &d);
      if (ret == 1) {
        *log = d;
      }
      if (fp) {
        fclose(fp);
        fp = NULL;
      }
    }
  }
}


x86 assembly (clang, -O0):
<getPhyLogSizes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x200,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x200,(%rax)
mov    0x2e70(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x8(%rbp)
je     139d <getPhyLogSizes+0x25d>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe61(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    11d1 <getPhyLogSizes+0x91>
jmp    1236 <getPhyLogSizes+0xf6>
mov    -0x420(%rbp),%rdi
lea    0xe4c(%rip),%rsi
lea    -0x414(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x1,-0x418(%rbp)
jne    120c <getPhyLogSizes+0xcc>
movslq -0x414(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x420(%rbp)
je     1231 <getPhyLogSizes+0xf1>
mov    -0x420(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x420(%rbp)
jmp    1236 <getPhyLogSizes+0xf6>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xde6(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    127a <getPhyLogSizes+0x13a>
jmp    12e4 <getPhyLogSizes+0x1a4>
mov    -0x420(%rbp),%rdi
lea    0xda3(%rip),%rsi
lea    -0x414(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x1,-0x418(%rbp)
jne    12ba <getPhyLogSizes+0x17a>
mov    -0x414(%rbp),%eax
shl    $0xa,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x420(%rbp)
je     12df <getPhyLogSizes+0x19f>
mov    -0x420(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x420(%rbp)
jmp    12e4 <getPhyLogSizes+0x1a4>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xd5b(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xd1f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    1333 <getPhyLogSizes+0x1f3>
mov    -0x20(%rbp),%rax
movq   $0x200,(%rax)
jmp    1398 <getPhyLogSizes+0x258>
mov    -0x420(%rbp),%rdi
lea    0xcea(%rip),%rsi
lea    -0x414(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x1,-0x418(%rbp)
jne    136e <getPhyLogSizes+0x22e>
movslq -0x414(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x420(%rbp)
je     1393 <getPhyLogSizes+0x253>
mov    -0x420(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x420(%rbp)
jmp    1398 <getPhyLogSizes+0x258>
jmp    139d <getPhyLogSizes+0x25d>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPhyLogSizes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
movq   $0x200,(%rsi)
movq   $0x200,(%rcx)
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rdx)
test   %rdi,%rdi
je     1293 <getPhyLogSizes+0x153>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
lea    0xe79(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
call   1060 <sprintf@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d8 <getPhyLogSizes+0x98>
mov    %rax,%rbx
lea    0xe76(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11d0 <getPhyLogSizes+0x90>
movslq 0xc(%rsp),%rax
mov    %rax,0x0(%r13)
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe4f(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
call   1060 <sprintf@plt>
lea    0xe32(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     1233 <getPhyLogSizes+0xf3>
mov    %rax,%rbx
lea    0xe1e(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    122b <getPhyLogSizes+0xeb>
movslq 0xc(%rsp),%rax
shl    $0xa,%rax
mov    %rax,(%r15)
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe17(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
call   1060 <sprintf@plt>
lea    0xdd7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     128c <getPhyLogSizes+0x14c>
mov    %rax,%rbx
lea    0xdc3(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1282 <getPhyLogSizes+0x142>
movslq 0xc(%rsp),%rax
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1293 <getPhyLogSizes+0x153>
movq   $0x200,(%r14)
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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