#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 *, ...);
scalar_t__ readMDPFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int readMDP(char *filename) {
  FILE *file;
  if (filename == NULL) {
    fprintf(stderr, "<NULL> MDP filename.\n");
    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    117a <readMDP+0x3a>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1209 <readMDP+0xc9>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bf <readMDP+0x7f>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1209 <readMDP+0xc9>
mov    -0x18(%rbp),%rdi
call   1060 <readMDPFile@plt>
cmp    $0x0,%rax
jne    11f9 <readMDP+0xb9>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1209 <readMDP+0xc9>
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   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     117b <readMDP+0x3b>
mov    %rdi,%rbx
lea    0xec4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1196 <readMDP+0x56>
mov    %rax,%rbp
mov    %rax,%rdi
call   1060 <readMDPFile@plt>
test   %rax,%rax
je     11a8 <readMDP+0x68>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    $0x1,%ebp
jmp    11c4 <readMDP+0x84>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11c4 <readMDP+0x84>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
jmp    11b8 <readMDP+0x78>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"<NULL> MDP filename.\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 %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %29
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %3
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %16)
store i32 0, i32* %2
br label %29
18: ; preds = %10
%19 = load i32*, i32** %4
%20 = call i64 @readMDPFile(i32* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %3
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %24)
store i32 0, i32* %2
br label %29
26: ; preds = %18
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
store i32 1, i32* %2
br label %29
29: ; preds = %26, %22, %14, %7
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"<NULL> MDP filename.\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 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
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 (i32, i8*, ...) @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 (i32, i8*, ...) @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
}