#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ stderr;
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void print_time(const char *name, long time) {
  long time_ms = (time + 500000) / 1000000;
  {
    long minutes = time_ms / 60000;
    double seconds = (time_ms % 60000) * 1e-3;
    int len = strlen(name);
    char buffer[31];
    memset(buffer, ' ', 30);
    buffer[30] = '\0';
    if (len < 31)
      strncpy(buffer, name, len);
    fprintf(stderr, "%s", name);
    while (len < 30) {
      len += 1;
      fprintf(stderr, " ");
    }
    fprintf(stderr, "%ldm%.3fs\n", minutes, seconds);
  }
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x7a120,%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xea60,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xea60,%ecx
cqto
idiv   %rcx
cvtsi2sd %rdx,%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x20,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
movb   $0x0,-0x32(%rbp)
cmpl   $0x1f,-0x2c(%rbp)
jge    11db <print_time+0x9b>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpl   $0x1e,-0x2c(%rbp)
jge    1225 <print_time+0xe5>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    11f6 <print_time+0xb6>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
lea    0xdcf(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x7a120,%r14
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    $0x20,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
movb   $0x0,0x1e(%rsp)
cmp    $0x1f,%ebp
jge    11d3 <print_time+0x93>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    0x2e52(%rip),%r15
mov    (%r15),%edi
lea    0xe70(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
cmp    $0x1e,%ebp
je     11ed <print_time+0xad>
add    $0xffffffe2,%ebp
lea    0xe5a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
inc    %ebp
jne    11c0 <print_time+0x80>
jmp    11ed <print_time+0xad>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
movabs $0x431bde82d7b634db,%rcx
de 1b 43
mov    %r14,%rax
imul   %rcx
mov    %rdx,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rcx
add    %rax,%rcx
movabs $0x45e7b272f608770f,%rdx
b2 e7 45
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xe,%rdx
add    %rax,%rdx
imul   $0xea60,%rdx,%rax
sub    %rax,%rcx
cvtsi2sd %rcx,%xmm0
mulsd  0xdbd(%rip),%xmm0
movabs $0x12533fe68fd3d1d,%rcx
33 25 01
mov    %r14,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1c,%rdx
add    %rax,%rdx
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [11 x i8] c"%ldm%.3fs\0A\00"
define void @print_time(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca double
%8 = alloca i32
%9 = alloca [31 x i8]
store i8* %0, i8** %3
store i64 %1, i64* %4
%10 = load i64, i64* %4
%11 = add nsw i64 %10, 500000
%12 = sdiv i64 %11, 1000000
store i64 %12, i64* %5
%13 = load i64, i64* %5
%14 = sdiv i64 %13, 60000
store i64 %14, i64* %6
%15 = load i64, i64* %5
%16 = srem i64 %15, 60000
%17 = sitofp i64 %16 to double
%18 = fmul double %17, 1.000000e-03
store double %18, double* %7
%19 = load i8*, i8** %3
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %8
%21 = getelementptr inbounds [31 x i8], [31 x i8]* %9, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i8 signext 32, i32 30)
%23 = getelementptr inbounds [31 x i8], [31 x i8]* %9, i64 0, i64 30
store i8 0, i8* %23
%24 = load i32, i32* %8
%25 = icmp slt i32 %24, 31
br i1 %25, label %26, label %31
26: ; preds = %2
%27 = getelementptr inbounds [31 x i8], [31 x i8]* %9, i64 0, i64 0
%28 = load i8*, i8** %3
%29 = load i32, i32* %8
%30 = call i32 @strncpy(i8* %27, i8* %28, i32 %29)
br label %31
31: ; preds = %26, %2
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %3
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %38, %31
%36 = load i32, i32* %8
%37 = icmp slt i32 %36, 30
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %35
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = load i64, i64* %6
%46 = load double, double* %7
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %45, double %46)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [11 x i8] c"%ldm%.3fs\0A\00"
define void @print_time(i8* %0, i64 %1) {
%3 = alloca [31 x i8]
%4 = add nsw i64 %1, 500000
%5 = tail call i32 @strlen(i8* %0)
%6 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i8 signext 32, i32 30)
%8 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 30
store i8 0, i8* %8
%9 = icmp slt i32 %5, 31
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
13: ; preds = %2
%14 = call i32 @strncpy(i8* %6, i8* %0, i32 %5)
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = icmp eq i32 %5, 30
br i1 %17, label %24, label %18
18: ; preds = %13, %18
%19 = phi i32 [ %20, %18 ], [ %5, %13 ]
%20 = add i32 %19, 1
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32 %20, 30
br i1 %23, label %24, label %18
24: ; preds = %18, %10, %13
%25 = sdiv i64 %4, 1000000
%26 = srem i64 %25, 60000
%27 = sitofp i64 %26 to double
%28 = fmul double %27, 1.000000e-03
%29 = sdiv i64 %4, 60000000000
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %29, double %28)
ret void
}