#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 *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int getNumRequests(const char *suf) {
  if (suf == NULL) {
    return 0;
  }
  char s[200];
  int nr = 0;
  FILE *fp = NULL;
  if (suf) {
    sprintf(s, "/sys/block/%s/queue/nr_requests", suf);
    fp = fopen(s, "rt");
    if (!fp) {
      goto wvret;
    }
    if (fscanf(fp, "%d", &nr) == 1) {
    }
  }
wvret:
  if (fp)
    fclose(fp);
  return nr;
}


x86 assembly (clang, -O0):
<getNumRequests>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <getNumRequests+0x26>
movl   $0x0,-0x4(%rbp)
jmp    121f <getNumRequests+0xdf>
movl   $0x0,-0xe4(%rbp)
movq   $0x0,-0xf0(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f7 <getNumRequests+0xb7>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe68(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0xf0(%rbp)
cmpq   $0x0,-0xf0(%rbp)
jne    11ca <getNumRequests+0x8a>
jmp    11fc <getNumRequests+0xbc>
mov    -0xf0(%rbp),%rdi
lea    0xe4b(%rip),%rsi
lea    -0xe4(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11f2 <getNumRequests+0xb2>
jmp    11f2 <getNumRequests+0xb2>
jmp    11f7 <getNumRequests+0xb7>
jmp    11fc <getNumRequests+0xbc>
cmpq   $0x0,-0xf0(%rbp)
je     1216 <getNumRequests+0xd6>
mov    -0xf0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xe4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumRequests>:
test   %rdi,%rdi
je     11a5 <getNumRequests+0x65>
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%rdx
movl   $0x0,0xc(%rsp)
lea    0xea1(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a8 <getNumRequests+0x68>
mov    %rax,%rbx
lea    0xe99(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0xc(%rsp),%eax
jmp    11aa <getNumRequests+0x6a>
xor    %eax,%eax
ret
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"/sys/block/%s/queue/nr_requests\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @getNumRequests(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [200 x i8]
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %37
10: ; preds = %1
store i32 0, i32* %5
store i32* null, i32** %6
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp ne i32* %19, null
br i1 %20, label %22, label %21
21: ; preds = %13
br label %29
22: ; preds = %13
%23 = load i32*, i32** %6
%24 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %22
br label %27
27: ; preds = %26, %22
br label %28
28: ; preds = %27, %10
br label %29
29: ; preds = %28, %21
%30 = load i32*, i32** %6
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %5
store i32 %36, i32* %2
br label %37
37: ; preds = %35, %9
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [32 x i8] c"/sys/block/%s/queue/nr_requests\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @getNumRequests(i8* %0) {
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = icmp eq i8* %0, null
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %5
%12 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%13 = call i32 @fclose(i32* %9)
%14 = load i32, i32* %3
br label %15
15: ; preds = %5, %11
%16 = phi i32 [ 0, %5 ], [ %14, %11 ]
br label %17
17: ; preds = %1, %15
%18 = phi i32 [ %16, %15 ], [ 0, %1 ]
ret i32 %18
}