#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*/ check_symmetry();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
unsigned int read_old_parameter_file(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ write_new_parameter_file(int /*<<< orphan*/ *, unsigned int);
void convert_parameter_file(const char *iname, const char *oname,
                            unsigned int options) {
  FILE *ifile, *ofile;
  unsigned int old_options = 0;
  int skip_input_header = 0;
  if (options & 2097152U) {
    if (oname == NULL)
      oname = iname;
    skip_input_header = 1;
  } else {
    if (iname == NULL) {
      ifile = stdin;
      skip_input_header = 1;
    } else if (!(ifile = fopen(iname, "r"))) {
      fprintf(stderr, "convert_epars: can't open file %s\n", iname);
      return;
    }
    old_options = read_old_parameter_file(ifile, skip_input_header);
    if (ifile != stdin)
      fclose(ifile);
    check_symmetry();
  }
  if (options & 524288U)
    options = old_options;
  if (oname == NULL)
    ofile = stdout;
  else if (!(ofile = fopen(oname, "a+"))) {
    fprintf(stderr, "convert_epars: can't open file %s for writing\n", oname);
    return;
  }
  write_new_parameter_file(ofile, options);
  if (ofile != stdout)
    fclose(ofile);
}


x86 assembly (clang, -O0):
<convert_parameter_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
and    $0x200000,%eax
cmp    $0x0,%eax
je     11b1 <convert_parameter_file+0x51>
cmpq   $0x0,-0x10(%rbp)
jne    11a5 <convert_parameter_file+0x45>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    124a <convert_parameter_file+0xea>
cmpq   $0x0,-0x8(%rbp)
jne    11d6 <convert_parameter_file+0x76>
mov    0x2e25(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1217 <convert_parameter_file+0xb7>
mov    -0x8(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1212 <convert_parameter_file+0xb2>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdfa(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12e9 <convert_parameter_file+0x189>
jmp    1217 <convert_parameter_file+0xb7>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1070 <read_old_parameter_file@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%rax
je     1243 <convert_parameter_file+0xe3>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x0,%al
call   1030 <check_symmetry@plt>
mov    -0x14(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     1261 <convert_parameter_file+0x101>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    127f <convert_parameter_file+0x11f>
mov    0x2d5d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <convert_parameter_file+0x160>
mov    -0x10(%rbp),%rdi
lea    0xd9b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12bb <convert_parameter_file+0x15b>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd77(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12e9 <convert_parameter_file+0x189>
jmp    12c0 <convert_parameter_file+0x160>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <write_new_parameter_file@plt>
mov    -0x28(%rbp),%rax
mov    0x2cf9(%rip),%rcx
cmp    (%rcx),%rax
je     12e9 <convert_parameter_file+0x189>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_parameter_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
test   $0x200000,%edx
jne    119b <convert_parameter_file+0x3b>
test   %rbx,%rbx
je     11a6 <convert_parameter_file+0x46>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1251 <convert_parameter_file+0xf1>
mov    %rax,%r15
xor    %esi,%esi
jmp    11b5 <convert_parameter_file+0x55>
test   %r14,%r14
cmove  %rbx,%r14
xor    %ebx,%ebx
jmp    11da <convert_parameter_file+0x7a>
mov    0x2e3b(%rip),%rax
mov    (%rax),%r15
mov    $0x1,%esi
mov    %r15,%rdi
call   1070 <read_old_parameter_file@plt>
mov    %eax,%ebx
mov    0x2e22(%rip),%rax
cmp    (%rax),%r15
je     11d3 <convert_parameter_file+0x73>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   1030 <check_symmetry@plt>
test   $0x80000,%ebp
cmove  %ebp,%ebx
test   %r14,%r14
je     1214 <convert_parameter_file+0xb4>
lea    0xe36(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    121e <convert_parameter_file+0xbe>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
mov    %r14,%rdx
jmp    1264 <convert_parameter_file+0x104>
mov    0x2db5(%rip),%rax
mov    (%rax),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <write_new_parameter_file@plt>
mov    0x2da1(%rip),%rax
cmp    (%rax),%rbp
je     1246 <convert_parameter_file+0xe6>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"convert_epars: can't open file %s\0A\00"
@stdout = global i32* null
@.str.2 = [3 x i8] c"a+\00"
@.str.3 = [47 x i8] c"convert_epars: can't open file %s for writing\0A\00"
define void @convert_parameter_file(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %6
%12 = and i32 %11, 2097152
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = load i8*, i8** %4
store i8* %18, i8** %5
br label %19
19: ; preds = %17, %14
store i32 1, i32* %10
br label %46
20: ; preds = %3
%21 = load i8*, i8** %4
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32*, i32** @stdin
store i32* %24, i32** %7
store i32 1, i32* %10
br label %34
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %7
%28 = icmp ne i32* %27, null
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %4
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %76
33: ; preds = %25
br label %34
34: ; preds = %33, %23
%35 = load i32*, i32** %7
%36 = load i32, i32* %10
%37 = call i32 @read_old_parameter_file(i32* %35, i32 %36)
store i32 %37, i32* %9
%38 = load i32*, i32** %7
%39 = load i32*, i32** @stdin
%40 = icmp ne i32* %38, %39
br i1 %40, label %41, label %44
41: ; preds = %34
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %41, %34
%45 = call i32 (...) @check_symmetry()
br label %46
46: ; preds = %44, %19
%47 = load i32, i32* %6
%48 = and i32 %47, 524288
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = load i32, i32* %9
store i32 %51, i32* %6
br label %52
52: ; preds = %50, %46
%53 = load i8*, i8** %5
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = load i32*, i32** @stdout
store i32* %56, i32** %8
br label %66
57: ; preds = %52
%58 = load i8*, i8** %5
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %59, i32** %8
%60 = icmp ne i32* %59, null
br i1 %60, label %65, label %61
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %5
%64 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %63)
br label %76
65: ; preds = %57
br label %66
66: ; preds = %65, %55
%67 = load i32*, i32** %8
%68 = load i32, i32* %6
%69 = call i32 @write_new_parameter_file(i32* %67, i32 %68)
%70 = load i32*, i32** %8
%71 = load i32*, i32** @stdout
%72 = icmp ne i32* %70, %71
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = load i32*, i32** %8
%75 = call i32 @fclose(i32* %74)
br label %76
76: ; preds = %29, %61, %73, %66
ret void
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"convert_epars: can't open file %s\0A\00"
@stdout = global i32* null
@.str.2 = [3 x i8] c"a+\00"
@.str.3 = [47 x i8] c"convert_epars: can't open file %s for writing\0A\00"
define void @convert_parameter_file(i8* %0, i8* %1, i32 %2) {
%4 = and i32 %2, 2097152
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = icmp eq i8* %1, null
%8 = select i1 %7, i8* %0, i8* %1
br label %29
9: ; preds = %3
%10 = icmp eq i8* %0, null
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = load i32*, i32** @stdin
br label %19
13: ; preds = %9
%14 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %51
19: ; preds = %13, %11
%20 = phi i32* [ %12, %11 ], [ %14, %13 ]
%21 = phi i32 [ 1, %11 ], [ 0, %13 ]
%22 = tail call i32 @read_old_parameter_file(i32* %20, i32 %21)
%23 = load i32*, i32** @stdin
%24 = icmp eq i32* %20, %23
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = tail call i32 @fclose(i32* %20)
br label %27
27: ; preds = %25, %19
%28 = tail call i32 (...) @check_symmetry()
br label %29
29: ; preds = %27, %6
%30 = phi i8* [ %8, %6 ], [ %1, %27 ]
%31 = phi i32 [ 0, %6 ], [ %22, %27 ]
%32 = and i32 %2, 524288
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i32 %2, i32 %31
%35 = icmp eq i8* %30, null
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = load i32*, i32** @stdout
br label %44
38: ; preds = %29
%39 = tail call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %51
44: ; preds = %38, %36
%45 = phi i32* [ %37, %36 ], [ %39, %38 ]
%46 = tail call i32 @write_new_parameter_file(i32* %45, i32 %34)
%47 = load i32*, i32** @stdout
%48 = icmp eq i32* %45, %47
br i1 %48, label %51, label %49
49: ; preds = %44
%50 = tail call i32 @fclose(i32* %45)
br label %51
51: ; preds = %44, %49, %41, %16
ret void
}