#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;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *tm_now(void) {
  static char str[16] = {0};
  time_t ltime = time(NULL);
  struct tm *tm = localtime(&ltime);
  str[0] = '0' + (tm->tm_hour > 9 ? tm->tm_hour / 10 : 0);
  str[1] = '0' + (tm->tm_hour > 9 ? tm->tm_hour % 10 : tm->tm_hour);
  str[2] = ':';
  str[3] = '0' + (tm->tm_min > 9 ? tm->tm_min / 10 : 0);
  str[4] = '0' + (tm->tm_min > 9 ? tm->tm_min % 10 : tm->tm_min);
  str[5] = ':';
  str[6] = '0' + (tm->tm_sec > 9 ? tm->tm_sec / 10 : 0);
  str[7] = '0' + (tm->tm_sec > 9 ? tm->tm_sec % 10 : tm->tm_sec);
  str[8] = 0;
  return str;
}


x86 assembly (clang, -O0):
<tm_now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x9,(%rax)
jle    1164 <tm_now+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    116e <tm_now+0x4e>
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <tm_now+0x4e>
mov    -0x14(%rbp),%eax
add    $0x30,%eax
mov    %al,0x2ec6(%rip)
mov    -0x10(%rbp),%rax
cmpl   $0x9,(%rax)
jle    119d <tm_now+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
jmp    11a6 <tm_now+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x30,%eax
mov    %al,0x2e8f(%rip)
movb   $0x3a,0x2e89(%rip)
mov    -0x10(%rbp),%rax
cmpl   $0x9,0x4(%rax)
jle    11de <tm_now+0xbe>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    11e8 <tm_now+0xc8>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e8 <tm_now+0xc8>
mov    -0x1c(%rbp),%eax
add    $0x30,%eax
mov    %al,0x2e4f(%rip)
mov    -0x10(%rbp),%rax
cmpl   $0x9,0x4(%rax)
jle    1219 <tm_now+0xf9>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
jmp    1223 <tm_now+0x103>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x30,%eax
mov    %al,0x2e15(%rip)
movb   $0x3a,0x2e0f(%rip)
mov    -0x10(%rbp),%rax
cmpl   $0x9,0x8(%rax)
jle    125b <tm_now+0x13b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
jmp    1265 <tm_now+0x145>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    1265 <tm_now+0x145>
mov    -0x24(%rbp),%eax
add    $0x30,%eax
mov    %al,0x2dd5(%rip)
mov    -0x10(%rbp),%rax
cmpl   $0x9,0x8(%rax)
jle    1296 <tm_now+0x176>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
jmp    12a0 <tm_now+0x180>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%eax
mov    %al,0x2d9b(%rip)
movb   $0x0,0x2d95(%rip)
lea    0x2d86(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tm_now>:
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
mov    $0x30,%cl
cmp    $0xa,%edx
jl     1151 <tm_now+0x31>
mov    %edx,%edx
mov    $0xcccccccd,%ecx
imul   %rdx,%rcx
shr    $0x23,%rcx
add    $0x30,%cl
mov    %cl,0x2ee9(%rip)
mov    (%rax),%ecx
cmp    $0xa,%ecx
jl     117c <tm_now+0x5c>
movslq %ecx,%rdx
imul   $0x66666667,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
add    $0x30,%cl
mov    %cl,0x2ebc(%rip)
movb   $0x3a,0x2eb6(%rip)
mov    0x4(%rax),%ecx
mov    $0x30,%dl
cmp    $0xa,%ecx
jl     11a8 <tm_now+0x88>
mov    %ecx,%esi
mov    $0xcccccccd,%edx
imul   %rsi,%rdx
shr    $0x23,%rdx
add    $0x30,%dl
mov    %dl,0x2e95(%rip)
cmp    $0xa,%ecx
jl     11d1 <tm_now+0xb1>
movslq %ecx,%rdx
imul   $0x66666667,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
add    $0x30,%cl
mov    %cl,0x2e6a(%rip)
movb   $0x3a,0x2e64(%rip)
mov    0x8(%rax),%eax
mov    $0x30,%cl
cmp    $0xa,%eax
jl     11fd <tm_now+0xdd>
mov    %eax,%edx
mov    $0xcccccccd,%ecx
imul   %rdx,%rcx
shr    $0x23,%rcx
add    $0x30,%cl
mov    %cl,0x2e43(%rip)
cmp    $0xa,%eax
jl     1226 <tm_now+0x106>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x2e19(%rip)
lea    0x2e0b(%rip),%rax
movb   $0x0,0x2e0c(%rip)
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@tm_now.str = internal global [16 x i8] zeroinitializer
define i8* @tm_now() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %4, %struct.tm** %2
%5 = load %struct.tm*, %struct.tm** %2
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, 9
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load %struct.tm*, %struct.tm** %2
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sdiv i32 %12, 10
br label %15
14: ; preds = %0
br label %15
15: ; preds = %14, %9
%16 = phi i32 [ %13, %9 ], [ 0, %14 ]
%17 = add nsw i32 48, %16
%18 = trunc i32 %17 to i8
store i8 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 0)
%19 = load %struct.tm*, %struct.tm** %2
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = icmp sgt i32 %21, 9
br i1 %22, label %23, label %28
23: ; preds = %15
%24 = load %struct.tm*, %struct.tm** %2
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = srem i32 %26, 10
br label %32
28: ; preds = %15
%29 = load %struct.tm*, %struct.tm** %2
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 0
%31 = load i32, i32* %30
br label %32
32: ; preds = %28, %23
%33 = phi i32 [ %27, %23 ], [ %31, %28 ]
%34 = add nsw i32 48, %33
%35 = trunc i32 %34 to i8
store i8 %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 1)
store i8 58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 2)
%36 = load %struct.tm*, %struct.tm** %2
%37 = getelementptr inbounds %struct.tm, %struct.tm* %36, i32 0, i32 1
%38 = load i32, i32* %37
%39 = icmp sgt i32 %38, 9
br i1 %39, label %40, label %45
40: ; preds = %32
%41 = load %struct.tm*, %struct.tm** %2
%42 = getelementptr inbounds %struct.tm, %struct.tm* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = sdiv i32 %43, 10
br label %46
45: ; preds = %32
br label %46
46: ; preds = %45, %40
%47 = phi i32 [ %44, %40 ], [ 0, %45 ]
%48 = add nsw i32 48, %47
%49 = trunc i32 %48 to i8
store i8 %49, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 3)
%50 = load %struct.tm*, %struct.tm** %2
%51 = getelementptr inbounds %struct.tm, %struct.tm* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = icmp sgt i32 %52, 9
br i1 %53, label %54, label %59
54: ; preds = %46
%55 = load %struct.tm*, %struct.tm** %2
%56 = getelementptr inbounds %struct.tm, %struct.tm* %55, i32 0, i32 1
%57 = load i32, i32* %56
%58 = srem i32 %57, 10
br label %63
59: ; preds = %46
%60 = load %struct.tm*, %struct.tm** %2
%61 = getelementptr inbounds %struct.tm, %struct.tm* %60, i32 0, i32 1
%62 = load i32, i32* %61
br label %63
63: ; preds = %59, %54
%64 = phi i32 [ %58, %54 ], [ %62, %59 ]
%65 = add nsw i32 48, %64
%66 = trunc i32 %65 to i8
store i8 %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 4)
store i8 58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 5)
%67 = load %struct.tm*, %struct.tm** %2
%68 = getelementptr inbounds %struct.tm, %struct.tm* %67, i32 0, i32 2
%69 = load i32, i32* %68
%70 = icmp sgt i32 %69, 9
br i1 %70, label %71, label %76
71: ; preds = %63
%72 = load %struct.tm*, %struct.tm** %2
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 2
%74 = load i32, i32* %73
%75 = sdiv i32 %74, 10
br label %77
76: ; preds = %63
br label %77
77: ; preds = %76, %71
%78 = phi i32 [ %75, %71 ], [ 0, %76 ]
%79 = add nsw i32 48, %78
%80 = trunc i32 %79 to i8
store i8 %80, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 6)
%81 = load %struct.tm*, %struct.tm** %2
%82 = getelementptr inbounds %struct.tm, %struct.tm* %81, i32 0, i32 2
%83 = load i32, i32* %82
%84 = icmp sgt i32 %83, 9
br i1 %84, label %85, label %90
85: ; preds = %77
%86 = load %struct.tm*, %struct.tm** %2
%87 = getelementptr inbounds %struct.tm, %struct.tm* %86, i32 0, i32 2
%88 = load i32, i32* %87
%89 = srem i32 %88, 10
br label %94
90: ; preds = %77
%91 = load %struct.tm*, %struct.tm** %2
%92 = getelementptr inbounds %struct.tm, %struct.tm* %91, i32 0, i32 2
%93 = load i32, i32* %92
br label %94
94: ; preds = %90, %85
%95 = phi i32 [ %89, %85 ], [ %93, %90 ]
%96 = add nsw i32 48, %95
%97 = trunc i32 %96 to i8
store i8 %97, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 7)
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 8)
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@tm_now.str = internal global [16 x i8] zeroinitializer
define i8* @tm_now() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 9
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = udiv i32 %6, 10
%10 = trunc i32 %9 to i8
%11 = add i8 %10, 48
br label %12
12: ; preds = %0, %8
%13 = phi i8 [ %11, %8 ], [ 48, %0 ]
store i8 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 0)
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 9
%16 = srem i32 %14, 10
%17 = select i1 %15, i32 %16, i32 %14
%18 = trunc i32 %17 to i8
%19 = add i8 %18, 48
store i8 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 1)
store i8 58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 2)
%20 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%21 = load i32, i32* %20
%22 = icmp sgt i32 %21, 9
br i1 %22, label %23, label %27
23: ; preds = %12
%24 = udiv i32 %21, 10
%25 = trunc i32 %24 to i8
%26 = add i8 %25, 48
br label %27
27: ; preds = %12, %23
%28 = phi i8 [ %26, %23 ], [ 48, %12 ]
store i8 %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 3)
%29 = srem i32 %21, 10
%30 = select i1 %22, i32 %29, i32 %21
%31 = trunc i32 %30 to i8
%32 = add i8 %31, 48
store i8 %32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 4)
store i8 58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 5)
%33 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%34 = load i32, i32* %33
%35 = icmp sgt i32 %34, 9
br i1 %35, label %36, label %40
36: ; preds = %27
%37 = udiv i32 %34, 10
%38 = trunc i32 %37 to i8
%39 = add i8 %38, 48
br label %40
40: ; preds = %27, %36
%41 = phi i8 [ %39, %36 ], [ 48, %27 ]
store i8 %41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 6)
%42 = srem i32 %34, 10
%43 = select i1 %35, i32 %42, i32 %34
%44 = trunc i32 %43 to i8
%45 = add i8 %44, 48
store i8 %45, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 7)
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 8)
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @tm_now.str, i64 0, i64 0)
}