#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 const *, char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ read_md_fp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void read_md(const char *in_name, const char *out_name) {
  FILE *in;
  FILE *out;
  in = fopen(in_name, "r");
  if (in == NULL) {
    perror(in_name);
    return;
  }
  out = fopen(out_name, "w");
  if (out == NULL) {
    perror(out_name);
    return;
  }
  read_md_fp(in, out);
  fclose(in);
  fclose(out);
}


x86 assembly (clang, -O0):
<read_md>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117d <read_md+0x3d>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
jmp    11c9 <read_md+0x89>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11aa <read_md+0x6a>
mov    -0x10(%rbp),%rdi
call   1060 <perror@plt>
jmp    11c9 <read_md+0x89>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <read_md_fp@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_md>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeae(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1196 <read_md+0x56>
mov    %rax,%r15
lea    0xe9c(%rip),%rsi
mov    %r14,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     119b <read_md+0x5b>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <read_md_fp@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>
mov    %rbx,%rdi
jmp    119e <read_md+0x5e>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <perror@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define void @read_md(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 @perror(i8* %12)
br label %30
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i32 @perror(i8* %20)
br label %30
22: ; preds = %14
%23 = load i32*, i32** %5
%24 = load i32*, i32** %6
%25 = call i32 @read_md_fp(i32* %23, i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
%28 = load i32*, i32** %6
%29 = call i32 @fclose(i32* %28)
br label %30
30: ; preds = %22, %19, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define void @read_md(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* %0)
br label %16
7: ; preds = %2
%8 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @perror(i8* %1)
br label %16
12: ; preds = %7
%13 = tail call i32 @read_md_fp(i32* %3, i32* %8)
%14 = tail call i32 @fclose(i32* %3)
%15 = tail call i32 @fclose(i32* %8)
br label %16
16: ; preds = %12, %10, %5
ret void
}