#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*/ errno;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
FILE *xml_create(int test_count, char *xml_filename) {
  FILE *xh;
  if ((xh = fopen(xml_filename, "w"))) {
    fprintf(xh, "<?xml version='1.0' encoding='UTF-8'?>\n");
    fprintf(xh, "<testsuite name='ptest' tests='%d'>\n", test_count);
  } else {
    fprintf(stderr, "XML File could not be created. %s.\n", strerror(errno));
    return NULL;
  }
  return xh;
}


x86 assembly (clang, -O0):
<xml_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     118d <xml_create+0x5d>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
mov    -0xc(%rbp),%edx
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c8 <xml_create+0x98>
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d0 <xml_create+0xa0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xml_create>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %edi,%ebp
lea    0xec1(%rip),%rsi
mov    %rax,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1173 <xml_create+0x43>
lea    0xeac(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xec4(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    119d <xml_create+0x6d>
mov    0x2e66(%rip),%rax
mov    (%rax),%ebp
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xebe(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [40 x i8] c"<?xml version='1.0' encoding='UTF-8'?>\0A\00"
@.str.2 = [37 x i8] c"<testsuite name='ptest' tests='%d'>\0A\00"
@stderr = global i32 0
@.str.3 = [36 x i8] c"XML File could not be created. %s.\0A\00"
@errno = global i32 0
define i32* @xml_create(i32 %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32*, i32** %6
%12 = ptrtoint i32* %11 to i32
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32*, i32** %6
%15 = ptrtoint i32* %14 to i32
%16 = load i32, i32* %4
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %21)
store i32* null, i32** %3
br label %25
23: ; preds = %10
%24 = load i32*, i32** %6
store i32* %24, i32** %3
br label %25
25: ; preds = %23, %18
%26 = load i32*, i32** %3
ret i32* %26
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [40 x i8] c"<?xml version='1.0' encoding='UTF-8'?>\0A\00"
@.str.2 = [37 x i8] c"<testsuite name='ptest' tests='%d'>\0A\00"
@stderr = global i32 0
@.str.3 = [36 x i8] c"XML File could not be created. %s.\0A\00"
@errno = global i32 0
define i32* @xml_create(i32 %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = ptrtoint i32* %3 to i64
%7 = trunc i64 %6 to i32
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %5, %10
ret i32* %3
}