#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*/ time_t;
typedef int /*<<< orphan*/ start_str;
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
scalar_t__ difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int format_iso8601(char *, int, int /*<<< orphan*/);
char *make_message(char *, char *, int);
int complete_name(int64_t start, int64_t end, char **result) {
  time_t start_time = (time_t)start;
  time_t end_time = (time_t)end;
  int duration = (int)(difftime(end_time, start_time) + 0.5);
  char start_str[200];
  int ret = format_iso8601(start_str, sizeof(start_str), start);
  if (ret)
    return ret;
  *result = make_message("%s--PT%dS", start_str, duration);
  return 1;
}


x86 assembly (clang, -O0):
<complete_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <difftime@plt>
cvtsi2sd %rax,%xmm0
movsd  0xe97(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0xc8,%esi
call   1050 <format_iso8601@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0x0,-0xf4(%rbp)
je     11a9 <complete_name+0x79>
mov    -0xf4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d0 <complete_name+0xa0>
lea    -0xf0(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xe4e(%rip),%rdi
call   1040 <make_message@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<complete_name>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rdx,%r14
mov    %edi,%ebp
mov    %esi,%edi
mov    %ebp,%esi
call   1030 <difftime@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %ebp,%edx
call   1050 <format_iso8601@plt>
test   %eax,%eax
jne    1187 <complete_name+0x57>
cvtsi2sd %rbx,%xmm0
addsd  0xe94(%rip),%xmm0
cvttsd2si %xmm0,%edx
lea    0xe91(%rip),%rdi
mov    %rsp,%rsi
call   1040 <make_message@plt>
mov    %rax,(%r14)
mov    $0x1,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s--PT%dS\00"
define i32 @complete_name(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [200 x i8]
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%13 = load i32, i32* %5
store i32 %13, i32* %8
%14 = load i32, i32* %6
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = load i32, i32* %8
%17 = call i64 @difftime(i32 %15, i32 %16)
%18 = sitofp i64 %17 to double
%19 = fadd double %18, 5.000000e-01
%20 = fptosi double %19 to i32
store i32 %20, i32* %10
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i32 @format_iso8601(i8* %21, i32 200, i32 %22)
store i32 %23, i32* %12
%24 = load i32, i32* %12
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %3
%27 = load i32, i32* %12
store i32 %27, i32* %4
br label %33
28: ; preds = %3
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%30 = load i32, i32* %10
%31 = call i8* @make_message(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %29, i32 %30)
%32 = load i8**, i8*** %7
store i8* %31, i8** %32
store i32 1, i32* %4
br label %33
33: ; preds = %28, %26
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s--PT%dS\00"
define i32 @complete_name(i32 %0, i32 %1, i8** nocapture writeonly %2) {
%4 = alloca [200 x i8]
%5 = tail call i64 @difftime(i32 %1, i32 %0)
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = call i32 @format_iso8601(i8* %6, i32 200, i32 %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = sitofp i64 %5 to double
%11 = fadd double %10, 5.000000e-01
%12 = fptosi double %11 to i32
%13 = call i8* @make_message(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %12)
store i8* %13, i8** %2
br label %14
14: ; preds = %3, %9
%15 = phi i32 [ 1, %9 ], [ %7, %3 ]
ret i32 %15
}