#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 */

/* Variables and functions */
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
int S_IROTH;
int S_IRUSR;
int S_IWOTH;
int S_IWUSR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int open(char *, int, int);
int /*<<< orphan*/ stderr;
char *str_to_lower_case(char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int open_xml_(char *XML_file) {
  char *XML_open =
      "<?xml version=\"1.0\" encoding=\"utf-8\"?> "
      "\n<sphinx:docset>\n<sphinx:schema>\n<sphinx:field "
      "name=\"CONTENT_FIELD\" type=\"string\" />\n<sphinx:field "
      "name=\"PATH_INFO_FIELD\" type=\"string\" />\n<sphinx:attr "
      "name=\"PATH_INFO\" type=\"string\" />\n<sphinx:attr name=\"TIMESTAMP\" "
      "type=\"timestamp\" />\n<sphinx:attr name=\"CONTENT_LENGTH\" "
      "type=\"int\" />\n</sphinx:schema>\n\n";
  int fd = 0;
  int bwrite = 0;
  char *XML_open_lower = NULL;
  XML_open_lower = str_to_lower_case(XML_open);
  fd = open(XML_file, O_WRONLY | O_CREAT | O_TRUNC,
            S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
  if (fd <= 0) {
    fprintf(stderr, "error open %s file", XML_file);
    return -1;
  }
  bwrite = write(fd, XML_open_lower, strlen(XML_open_lower));
  free(XML_open_lower);
  return fd;
}


x86 assembly (clang, -O0):
<open_xml_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe8d(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <str_to_lower_case@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    0x2e4a(%rip),%rax
or     (%rax),%esi
mov    0x2e39(%rip),%rax
or     (%rax),%esi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    0x2dd7(%rip),%rax
or     (%rax),%edx
mov    0x2de6(%rip),%rax
or     (%rax),%edx
mov    0x2dfd(%rip),%rax
or     (%rax),%edx
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1214 <open_xml_+0xb4>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xf54(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    124b <open_xml_+0xeb>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_xml_>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xe92(%rip),%rdi
call   1080 <str_to_lower_case@plt>
mov    0x2e2e(%rip),%rcx
mov    0x2e77(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    0x2e64(%rip),%rcx
or     (%rcx),%esi
mov    0x2e2b(%rip),%rcx
mov    0x2e04(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2e11(%rip),%rcx
or     (%rcx),%edx
mov    %rax,%rbx
mov    0x2e25(%rip),%rax
or     (%rax),%edx
mov    %r14,%rdi
call   1070 <open@plt>
test   %eax,%eax
jle    11e1 <open_xml_+0x81>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11fe <open_xml_+0x9e>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xf66(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [343 x i8] c"<?xml version=\221.0\22 encoding=\22utf-8\22?> \0A<sphinx:docset>\0A<sphinx:schema>\0A<sphinx:field name=\22CONTENT_FIELD\22 type=\22string\22 />\0A<sphinx:field name=\22PATH_INFO_FIELD\22 type=\22string\22 />\0A<sphinx:attr name=\22PATH_INFO\22 type=\22string\22 />\0A<sphinx:attr name=\22TIMESTAMP\22 type=\22timestamp\22 />\0A<sphinx:attr name=\22CONTENT_LENGTH\22 type=\22int\22 />\0A</sphinx:schema>\0A\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"error open %s file\00"
define i32 @open_xml_(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i8* getelementptr inbounds ([343 x i8], [343 x i8]* @.str, i64 0, i64 0), i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i8* null, i8** %7
%8 = load i8*, i8** %4
%9 = call i8* @str_to_lower_case(i8* %8)
store i8* %9, i8** %7
%10 = load i8*, i8** %3
%11 = load i32, i32* @O_WRONLY
%12 = load i32, i32* @O_CREAT
%13 = or i32 %11, %12
%14 = load i32, i32* @O_TRUNC
%15 = or i32 %13, %14
%16 = load i32, i32* @S_IROTH
%17 = load i32, i32* @S_IWOTH
%18 = or i32 %16, %17
%19 = load i32, i32* @S_IRUSR
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IWUSR
%22 = or i32 %20, %21
%23 = call i32 @open(i8* %10, i32 %15, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %1
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %3
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %28)
store i32 -1, i32* %2
br label %39
30: ; preds = %1
%31 = load i32, i32* %5
%32 = load i8*, i8** %7
%33 = load i8*, i8** %7
%34 = call i32 @strlen(i8* %33)
%35 = call i32 @write(i32 %31, i8* %32, i32 %34)
store i32 %35, i32* %6
%36 = load i8*, i8** %7
%37 = call i32 @free(i8* %36)
%38 = load i32, i32* %5
store i32 %38, i32* %2
br label %39
39: ; preds = %30, %26
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [343 x i8] c"<?xml version=\221.0\22 encoding=\22utf-8\22?> \0A<sphinx:docset>\0A<sphinx:schema>\0A<sphinx:field name=\22CONTENT_FIELD\22 type=\22string\22 />\0A<sphinx:field name=\22PATH_INFO_FIELD\22 type=\22string\22 />\0A<sphinx:attr name=\22PATH_INFO\22 type=\22string\22 />\0A<sphinx:attr name=\22TIMESTAMP\22 type=\22timestamp\22 />\0A<sphinx:attr name=\22CONTENT_LENGTH\22 type=\22int\22 />\0A</sphinx:schema>\0A\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"error open %s file\00"
define i32 @open_xml_(i8* %0) {
%2 = tail call i8* @str_to_lower_case(i8* getelementptr inbounds ([343 x i8], [343 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IROTH
%9 = load i32, i32* @S_IWOTH
%10 = or i32 %9, %8
%11 = load i32, i32* @S_IRUSR
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IWUSR
%14 = or i32 %12, %13
%15 = tail call i32 @open(i8* %0, i32 %7, i32 %14)
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %24
20: ; preds = %1
%21 = tail call i32 @strlen(i8* %2)
%22 = tail call i32 @write(i32 %15, i8* %2, i32 %21)
%23 = tail call i32 @free(i8* %2)
br label %24
24: ; preds = %20, %17
%25 = phi i32 [ -1, %17 ], [ %15, %20 ]
ret i32 %25
}