#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void xml_add_case(FILE *xh, int status, const char *ptest_dir, int timeouted,
                  int duration) {
  fprintf(xh, "\t<testcase classname='%s' name='run-ptest'>\n", ptest_dir);
  fprintf(xh, "\t\t<duration>%d</duration>\n", duration);
  if (status != 0) {
    fprintf(xh, "\t\t<failure type='exit_code'");
    fprintf(xh, " message='run-ptest exited with code: %d'>", status);
    fprintf(xh, "</failure>\n");
  }
  if (timeouted)
    fprintf(xh, "\t\t<failure type='timeout'/>\n");
  fprintf(xh, "\t</testcase>\n");
}


x86 assembly (clang, -O0):
<xml_add_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xedf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0xc(%rbp)
je     1198 <xml_add_case+0x88>
mov    -0x8(%rbp),%rdi
lea    0xede(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xee5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xefe(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11b4 <xml_add_case+0xa4>
mov    -0x8(%rbp),%rdi
lea    0xeee(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xef9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xml_add_case>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xec6(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xee5(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15d,%r15d
je     119f <xml_add_case+0x7f>
lea    0xee8(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xeeb(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xf02(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
test   %r14d,%r14d
je     11bd <xml_add_case+0x9d>
lea    0xef0(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xef4(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"\09<testcase classname='%s' name='run-ptest'>\0A\00"
@.str.1 = [27 x i8] c"\09\09<duration>%d</duration>\0A\00"
@.str.2 = [28 x i8] c"\09\09<failure type='exit_code'\00"
@.str.3 = [43 x i8] c" message='run-ptest exited with code: %d'>\00"
@.str.4 = [12 x i8] c"</failure>\0A\00"
@.str.5 = [29 x i8] c"\09\09<failure type='timeout'/>\0A\00"
@.str.6 = [14 x i8] c"\09</testcase>\0A\00"
define void @xml_add_case(i32* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32*, i32** %6
%12 = load i8*, i8** %8
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32*, i32** %6
%15 = load i32, i32* %10
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %5
%20 = load i32*, i32** %6
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %6
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %19, %5
%28 = load i32, i32* %9
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32*, i32** %6
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %30, %27
%34 = load i32*, i32** %6
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"\09<testcase classname='%s' name='run-ptest'>\0A\00"
@.str.1 = [27 x i8] c"\09\09<duration>%d</duration>\0A\00"
@.str.2 = [28 x i8] c"\09\09<failure type='exit_code'\00"
@.str.3 = [43 x i8] c" message='run-ptest exited with code: %d'>\00"
@.str.4 = [12 x i8] c"</failure>\0A\00"
@.str.5 = [29 x i8] c"\09\09<failure type='timeout'/>\0A\00"
@.str.6 = [14 x i8] c"\09</testcase>\0A\00"
define void @xml_add_case(i32* nocapture %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%8 = icmp eq i32 %1, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i64 27, i64 1, i32* %0)
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i64 11, i64 1, i32* %0)
br label %13
13: ; preds = %9, %5
%14 = icmp eq i32 %3, 0
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i64 28, i64 1, i32* %0)
br label %17
17: ; preds = %15, %13
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 13, i64 1, i32* %0)
ret void
}