#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 */
float atof(char *);
int atoi(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *translateTime(char *time) {
  char hourStr[5];
  char minStr[3];
  char secStr[3];
  int h = atoi(time);
  sprintf(hourStr, "%d", h);
  float aux = atof(time);
  aux -= (float)h;
  aux *= 60.0;
  int m = (int)aux;
  sprintf(minStr, "%d", m);
  aux -= (float)m;
  aux *= 60.0;
  int s = (int)aux;
  sprintf(secStr, "%d", s);
  char *dest = (char *)malloc(2 + strlen(hourStr) + 1 + strlen(minStr) + 1 +
                              strlen(secStr) + 1 + 1);
  strcat(strcat(strcat(strcat(strcat(strcat(strcpy(dest, "PT"), hourStr), "H"),
                              minStr),
                       "M"),
                secStr),
         "S");
  return dest;
}


x86 assembly (clang, -O0):
<translateTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0xd(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe72(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x1c(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe33(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvttss2si -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe18(%rip),%rsi
call   1090 <sprintf@plt>
cvtsi2ssl -0x20(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xde7(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvttss2si -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x13(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xdcc(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0xd(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x2,%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
lea    -0x13(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xd6e(%rip),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    -0xd(%rbp),%rsi
call   1080 <strcat@plt>
mov    %eax,%edi
lea    0xd58(%rip),%rsi
call   1080 <strcat@plt>
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    %eax,%edi
lea    0xd41(%rip),%rsi
call   1080 <strcat@plt>
mov    %eax,%edi
lea    -0x13(%rbp),%rsi
call   1080 <strcat@plt>
mov    %eax,%edi
lea    0xd2a(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<translateTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0xe75(%rip),%r13
lea    0xb(%rsp),%r14
mov    %r14,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <atof@plt>
cvtsi2ss %ebp,%xmm1
subss  %xmm1,%xmm0
mulss  0xe47(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
cvttss2si %xmm0,%edx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %r13,%rsi
call   1090 <sprintf@plt>
movaps 0x10(%rsp),%xmm1
cvttps2dq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
subss  %xmm0,%xmm1
mulss  0xe16(%rip),%xmm1
cvttss2si %xmm1,%edx
lea    0x5(%rsp),%r12
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   1050 <strlen@plt>
add    %rbx,%rbp
lea    (%rax,%rbp,1),%rdi
add    $0x6,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xdd1(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xdbb(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1080 <strcat@plt>
lea    0xda5(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1080 <strcat@plt>
lea    0xd8f(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"PT\00"
@.str.2 = [2 x i8] c"H\00"
@.str.3 = [2 x i8] c"M\00"
@.str.4 = [2 x i8] c"S\00"
define i8* @translateTime(i8* %0) {
%2 = alloca i8*
%3 = alloca [5 x i8]
%4 = alloca [3 x i8]
%5 = alloca [3 x i8]
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* %6
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %2
%17 = call float @atof(i8* %16)
store float %17, float* %7
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to float
%20 = load float, float* %7
%21 = fsub float %20, %19
store float %21, float* %7
%22 = load float, float* %7
%23 = fpext float %22 to double
%24 = fmul double %23, 6.000000e+01
%25 = fptrunc double %24 to float
store float %25, float* %7
%26 = load float, float* %7
%27 = fptosi float %26 to i32
store i32 %27, i32* %8
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%29 = load i32, i32* %8
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %8
%32 = sitofp i32 %31 to float
%33 = load float, float* %7
%34 = fsub float %33, %32
store float %34, float* %7
%35 = load float, float* %7
%36 = fpext float %35 to double
%37 = fmul double %36, 6.000000e+01
%38 = fptrunc double %37 to float
store float %38, float* %7
%39 = load float, float* %7
%40 = fptosi float %39 to i32
store i32 %40, i32* %9
%41 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%42 = load i32, i32* %9
%43 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%45 = call i64 @strlen(i8* %44)
%46 = add nsw i64 2, %45
%47 = add nsw i64 %46, 1
%48 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%49 = call i64 @strlen(i8* %48)
%50 = add nsw i64 %47, %49
%51 = add nsw i64 %50, 1
%52 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%53 = call i64 @strlen(i8* %52)
%54 = add nsw i64 %51, %53
%55 = add nsw i64 %54, 1
%56 = add nsw i64 %55, 1
%57 = call i64 @malloc(i64 %56)
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %10
%59 = load i8*, i8** %10
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%62 = call i32 @strcat(i32 %60, i8* %61)
%63 = call i32 @strcat(i32 %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%64 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%65 = call i32 @strcat(i32 %63, i8* %64)
%66 = call i32 @strcat(i32 %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%67 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%68 = call i32 @strcat(i32 %66, i8* %67)
%69 = call i32 @strcat(i32 %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%70 = load i8*, i8** %10
ret i8* %70
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"PT\00"
@.str.2 = [2 x i8] c"H\00"
@.str.3 = [2 x i8] c"M\00"
@.str.4 = [2 x i8] c"S\00"
define i8* @translateTime(i8* nocapture %0) {
%2 = alloca [5 x i8]
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%8 = tail call i32 @atoi(i8* %0)
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = tail call float @atof(i8* %0)
%11 = sitofp i32 %8 to float
%12 = fsub float %10, %11
%13 = fmul float %12, 6.000000e+01
%14 = fptosi float %13 to i32
%15 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = sitofp i32 %14 to float
%17 = fsub float %13, %16
%18 = fmul float %17, 6.000000e+01
%19 = fptosi float %18 to i32
%20 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i64 @strlen(i8* %5)
%22 = call i64 @strlen(i8* %6)
%23 = call i64 @strlen(i8* %7)
%24 = add i64 %21, 6
%25 = add i64 %24, %22
%26 = add i64 %25, %23
%27 = tail call i64 @malloc(i64 %26)
%28 = inttoptr i64 %27 to i8*
%29 = tail call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @strcat(i32 %29, i8* %5)
%31 = call i32 @strcat(i32 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @strcat(i32 %31, i8* %6)
%33 = call i32 @strcat(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @strcat(i32 %33, i8* %7)
%35 = call i32 @strcat(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i8* %28
}