#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
FILE *cmio_in_open_info(const char (*info_filename)[80],
                        const char (*restart_filename)[80]) {
  FILE *restart_fp = fopen(restart_filename[0], "r");
  FILE *info_fp = fopen(info_filename[0], "r");
  if ((restart_fp == NULL && info_fp) || (restart_fp && info_fp == NULL)) {
    if (restart_fp) {
      fputs("cio_min: Restart file exists, but info doesn't!\n", stderr);
      fclose(restart_fp);
    }
    if (info_fp) {
      fputs("cio_min: Info file exists, but restart doesn't!\n", stderr);
      fclose(info_fp);
    }
    return NULL;
  }
  if (restart_fp) {
    fclose(restart_fp);
    restart_fp = NULL;
  }
  if (info_fp) {
    fclose(info_fp);
  }
  info_fp = fopen(info_filename[0], "a");
  return info_fp;
}


x86 assembly (clang, -O0):
<cmio_in_open_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117e <cmio_in_open_info+0x4e>
cmpq   $0x0,-0x28(%rbp)
jne    1194 <cmio_in_open_info+0x64>
cmpq   $0x0,-0x20(%rbp)
je     11f3 <cmio_in_open_info+0xc3>
cmpq   $0x0,-0x28(%rbp)
jne    11f3 <cmio_in_open_info+0xc3>
cmpq   $0x0,-0x20(%rbp)
je     11bd <cmio_in_open_info+0x8d>
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
lea    0xe53(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x0,-0x28(%rbp)
je     11e6 <cmio_in_open_info+0xb6>
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
lea    0xe5b(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    123f <cmio_in_open_info+0x10f>
cmpq   $0x0,-0x20(%rbp)
je     120f <cmio_in_open_info+0xdf>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1223 <cmio_in_open_info+0xf3>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmio_in_open_info>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xec1(%rip),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
test   %rbx,%rbx
jne    1165 <cmio_in_open_info+0x35>
test   %r15,%r15
jne    116f <cmio_in_open_info+0x3f>
test   %rbx,%rbx
je     11bb <cmio_in_open_info+0x8b>
test   %r15,%r15
jne    11bb <cmio_in_open_info+0x8b>
test   %rbx,%rbx
je     1191 <cmio_in_open_info+0x61>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    0xe7e(%rip),%rdi
call   1040 <fputs@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %r15,%r15
je     11b3 <cmio_in_open_info+0x83>
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
lea    0xe8d(%rip),%rdi
call   1040 <fputs@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
test   %rbx,%rbx
je     11c8 <cmio_in_open_info+0x98>
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %r15,%r15
je     11d5 <cmio_in_open_info+0xa5>
mov    %r15,%rdi
call   1030 <fclose@plt>
lea    0xe88(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fopen@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [49 x i8] c"cio_min: Restart file exists, but info doesn't!\0A\00"
@stderr = global i32 0
@.str.2 = [49 x i8] c"cio_min: Info file exists, but restart doesn't!\0A\00"
@.str.3 = [2 x i8] c"a\00"
define i32* @cmio_in_open_info([80 x i8]* %0, [80 x i8]* %1) {
%3 = alloca i32*
%4 = alloca [80 x i8]*
%5 = alloca [80 x i8]*
%6 = alloca i32*
%7 = alloca i32*
store [80 x i8]* %0, [80 x i8]** %4
store [80 x i8]* %1, [80 x i8]** %5
%8 = load [80 x i8]*, [80 x i8]** %5
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load [80 x i8]*, [80 x i8]** %4
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %7
%16 = load i32*, i32** %6
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32*, i32** %7
%20 = icmp ne i32* %19, null
br i1 %20, label %27, label %21
21: ; preds = %18, %2
%22 = load i32*, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %44
24: ; preds = %21
%25 = load i32*, i32** %7
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %44
27: ; preds = %24, %18
%28 = load i32*, i32** %6
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = call i32 @fputs(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
br label %35
35: ; preds = %30, %27
%36 = load i32*, i32** %7
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = call i32 @fputs(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i32*, i32** %7
%42 = call i32 @fclose(i32* %41)
br label %43
43: ; preds = %38, %35
store i32* null, i32** %3
br label %62
44: ; preds = %24, %21
%45 = load i32*, i32** %6
%46 = icmp ne i32* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32*, i32** %6
%49 = call i32 @fclose(i32* %48)
store i32* null, i32** %6
br label %50
50: ; preds = %47, %44
%51 = load i32*, i32** %7
%52 = icmp ne i32* %51, null
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32*, i32** %7
%55 = call i32 @fclose(i32* %54)
br label %56
56: ; preds = %53, %50
%57 = load [80 x i8]*, [80 x i8]** %4
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %57, i64 0
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %58, i64 0, i64 0
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %60, i32** %7
%61 = load i32*, i32** %7
store i32* %61, i32** %3
br label %62
62: ; preds = %56, %43
%63 = load i32*, i32** %3
ret i32* %63
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [49 x i8] c"cio_min: Restart file exists, but info doesn't!\0A\00"
@stderr = global i32 0
@.str.2 = [49 x i8] c"cio_min: Info file exists, but restart doesn't!\0A\00"
@.str.3 = [2 x i8] c"a\00"
define noalias i32* @cmio_in_open_info([80 x i8]* nocapture %0, [80 x i8]* nocapture %1) {
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %0, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %4, null
%8 = icmp ne i32* %6, null
%9 = and i1 %7, %8
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = icmp ne i32* %4, null
%12 = icmp eq i32* %6, null
%13 = and i1 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10, %2
br i1 %7, label %19, label %15
15: ; preds = %14
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = tail call i32 @fclose(i32* %4)
br label %19
19: ; preds = %15, %14
br i1 %8, label %20, label %32
20: ; preds = %19
%21 = load i32, i32* @stderr
%22 = tail call i32 @fputs(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = tail call i32 @fclose(i32* %6)
br label %32
24: ; preds = %10
br i1 %11, label %25, label %27
25: ; preds = %24
%26 = tail call i32 @fclose(i32* %4)
br label %27
27: ; preds = %25, %24
br i1 %8, label %28, label %30
28: ; preds = %27
%29 = tail call i32 @fclose(i32* %6)
br label %30
30: ; preds = %28, %27
%31 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %19, %20, %30
%33 = phi i32* [ %31, %30 ], [ null, %20 ], [ null, %19 ]
ret i32* %33
}