#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 *);
size_t fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
char *strdup(char *);
char *queueType(char *path) {
  if (path) {
  }
  FILE *fp = fopen("/sys/block/sda/device/queue_type", "rt");
  if (fp == NULL) {
    perror("problem opening");
  }
  char instr[100];
  size_t r = fscanf(fp, "%s", instr);
  fclose(fp);
  if (r != 1) {
    return strdup("n/a");
  }
  return strdup(instr);
}


x86 assembly (clang, -O0):
<queueType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116f <queueType+0x1f>
jmp    116f <queueType+0x1f>
lea    0xe8a(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119d <queueType+0x4d>
lea    0xe8c(%rip),%rdi
call   1060 <perror@plt>
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xe88(%rip),%rsi
call   1040 <fscanf@plt>
mov    %rax,-0x88(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x1,-0x88(%rbp)
01
je     11e4 <queueType+0x94>
lea    0xe61(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11f1 <queueType+0xa1>
lea    -0x80(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queueType>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xea2(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ae <queueType+0x5e>
lea    0xebb(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1040 <fscanf@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
cmp    $0x1,%r14
jne    119a <queueType+0x4a>
mov    %rsp,%rdi
jmp    11a1 <queueType+0x51>
lea    0xe96(%rip),%rdi
call   1070 <strdup@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe6f(%rip),%rdi
call   1060 <perror@plt>
jmp    1172 <queueType+0x22>

LLVM IR (-O0):
@.str = [33 x i8] c"/sys/block/sda/device/queue_type\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [16 x i8] c"problem opening\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"n/a\00"
define i8* @queueType(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [100 x i8]
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
br label %10
10: ; preds = %9, %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = load i32*, i32** %4
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
store i64 %19, i64* %6
%20 = load i32*, i32** %4
%21 = call i32 @fclose(i32* %20)
%22 = load i64, i64* %6
%23 = icmp ne i64 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i8* %25, i8** %2
br label %29
26: ; preds = %16
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%28 = call i8* @strdup(i8* %27)
store i8* %28, i8** %2
br label %29
29: ; preds = %26, %24
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
@.str = [33 x i8] c"/sys/block/sda/device/queue_type\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [16 x i8] c"problem opening\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"n/a\00"
define noalias i8* @queueType(i8* nocapture readnone %0) {
%2 = alloca [100 x i8]
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = call i32 @fclose(i32* %3)
%11 = icmp eq i64 %9, 1
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %16
14: ; preds = %7
%15 = call i8* @strdup(i8* %8)
br label %16
16: ; preds = %14, %12
%17 = phi i8* [ %13, %12 ], [ %15, %14 ]
ret i8* %17
}