#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ readMDPFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int readMDP(char *filename) {
  FILE *file;
  if (filename == NULL) {
    fprintf(stderr, "<NULL> MDP filename: %s.\n", filename);
    return (0);
  }
  if ((file = fopen(filename, "r")) == NULL) {
    fprintf(stderr, "Cannot open the MDP file: %s.\n", filename);
    return (0);
  }
  if (readMDPFile(file) == 0) {
    fprintf(stderr, "MDP file '%s' was not successfully parsed!\n", filename);
    return (0);
  }
  fclose(file);
  return (1);
}


x86 assembly (clang, -O0):
<readMDP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <readMDP+0x3c>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1207 <readMDP+0xc7>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bf <readMDP+0x7f>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1207 <readMDP+0xc7>
mov    -0x18(%rbp),%rdi
call   1060 <readMDPFile@plt>
cmp    $0x0,%rax
jne    11f7 <readMDP+0xb7>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe55(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1207 <readMDP+0xc7>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readMDP>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     117c <readMDP+0x3c>
mov    %rdi,%rbx
lea    0xec7(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1197 <readMDP+0x57>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <readMDPFile@plt>
test   %rax,%rax
je     11a9 <readMDP+0x69>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0x1,%ebx
jmp    11c3 <readMDP+0x83>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1040 <fprintf@plt>
jmp    11c3 <readMDP+0x83>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
jmp    11b9 <readMDP+0x79>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"<NULL> MDP filename: %s.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Cannot open the MDP file: %s.\0A\00"
@.str.3 = [44 x i8] c"MDP file '%s' was not successfully parsed!\0A\00"
define i32 @readMDP(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %3
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %2
br label %30
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %3
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %17)
store i32 0, i32* %2
br label %30
19: ; preds = %11
%20 = load i32*, i32** %4
%21 = call i64 @readMDPFile(i32* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %3
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %25)
store i32 0, i32* %2
br label %30
27: ; preds = %19
%28 = load i32*, i32** %4
%29 = call i32 @fclose(i32* %28)
store i32 1, i32* %2
br label %30
30: ; preds = %27, %23, %15, %7
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"<NULL> MDP filename: %s.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Cannot open the MDP file: %s.\0A\00"
@.str.3 = [44 x i8] c"MDP file '%s' was not successfully parsed!\0A\00"
define i32 @readMDP(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* null)
br label %20
6: ; preds = %1
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %20
12: ; preds = %6
%13 = tail call i64 @readMDPFile(i32* %7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %20
18: ; preds = %12
%19 = tail call i32 @fclose(i32* %7)
br label %20
20: ; preds = %18, %15, %9, %3
%21 = phi i32 [ 0, %3 ], [ 0, %9 ], [ 0, %15 ], [ 1, %18 ]
ret i32 %21
}