#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*/ adios(char const *, char *);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ mts_read_conf_file(int /*<<< orphan*/ *);
void read_mts(const char *path) {
  FILE *fp;
  fp = fopen(path, "r");
  if (!fp)
    adios(path, "error opening mts.conf:");
  mts_read_conf_file(fp);
  if (ferror(fp))
    adios(path, "error reading mts.conf:");
  if (fclose(fp))
    adios(path, "error closing mts.conf:");
}


x86 assembly (clang, -O0):
<read_mts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118b <read_mts+0x3b>
mov    -0x8(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <adios@plt>
mov    -0x10(%rbp),%rdi
call   1030 <mts_read_conf_file@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     11b7 <read_mts+0x67>
mov    -0x8(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1070 <adios@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     11da <read_mts+0x8a>
mov    -0x8(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <adios@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mts>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117a <read_mts+0x2a>
lea    0xe90(%rip),%rsi
mov    %r14,%rdi
call   1070 <adios@plt>
mov    %rbx,%rdi
call   1030 <mts_read_conf_file@plt>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     119e <read_mts+0x4e>
lea    0xe84(%rip),%rsi
mov    %r14,%rdi
call   1070 <adios@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
je     11c1 <read_mts+0x71>
lea    0xe80(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <adios@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"error opening mts.conf:\00"
@.str.2 = [24 x i8] c"error reading mts.conf:\00"
@.str.3 = [24 x i8] c"error closing mts.conf:\00"
define void @read_mts(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @adios(i8* %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %8, %1
%12 = load i32*, i32** %3
%13 = call i32 @mts_read_conf_file(i32* %12)
%14 = load i32*, i32** %3
%15 = call i64 @ferror(i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8*, i8** %2
%19 = call i32 @adios(i8* %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %17, %11
%21 = load i32*, i32** %3
%22 = call i64 @fclose(i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i8*, i8** %2
%26 = call i32 @adios(i8* %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %24, %20
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"error opening mts.conf:\00"
@.str.2 = [24 x i8] c"error reading mts.conf:\00"
@.str.3 = [24 x i8] c"error closing mts.conf:\00"
define void @read_mts(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @adios(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @mts_read_conf_file(i32* %2)
%8 = tail call i64 @ferror(i32* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @adios(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
%13 = tail call i64 @fclose(i32* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @adios(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
ret void
}