#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 */
struct tm {
  int tm_mon;
  int tm_mday;
  int tm_year;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void bgpdump_time2str(struct tm *date, char *time_str) {
  char tmp_str[10];
  if (date->tm_mon + 1 < 10)
    sprintf(tmp_str, "0%d/", date->tm_mon + 1);
  else
    sprintf(tmp_str, "%d/", date->tm_mon + 1);
  strcpy(time_str, tmp_str);
  if (date->tm_mday < 10)
    sprintf(tmp_str, "0%d/", date->tm_mday);
  else
    sprintf(tmp_str, "%d/", date->tm_mday);
  strcat(time_str, tmp_str);
  if (date->tm_year % 100 < 10)
    sprintf(tmp_str, "0%d ", date->tm_year % 100);
  else
    sprintf(tmp_str, "%d ", date->tm_year % 100);
  strcat(time_str, tmp_str);
  if (date->tm_hour < 10)
    sprintf(tmp_str, "0%d:", date->tm_hour);
  else
    sprintf(tmp_str, "%d:", date->tm_hour);
  strcat(time_str, tmp_str);
  if (date->tm_min < 10)
    sprintf(tmp_str, "0%d:", date->tm_min);
  else
    sprintf(tmp_str, "%d:", date->tm_min);
  strcat(time_str, tmp_str);
  if (date->tm_sec < 10)
    sprintf(tmp_str, "0%d", date->tm_sec);
  else
    sprintf(tmp_str, "%d", date->tm_sec);
  strcat(time_str, tmp_str);
}


x86 assembly (clang, -O0):
<bgpdump_time2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    $0xa,%eax
jge    1170 <bgpdump_time2str+0x40>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
add    $0x1,%edx
lea    0xe9a(%rip),%rsi
call   1050 <sprintf@plt>
jmp    1189 <bgpdump_time2str+0x59>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
add    $0x1,%edx
lea    0xe7d(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
cmpl   $0xa,0x4(%rax)
jge    11c0 <bgpdump_time2str+0x90>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe4a(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11d7 <bgpdump_time2str+0xa7>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe2f(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0xa,%edx
jge    1220 <bgpdump_time2str+0xf0>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
lea    0xdef(%rip),%rsi
call   1050 <sprintf@plt>
jmp    123f <bgpdump_time2str+0x10f>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
lea    0xdcc(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rax
cmpl   $0xa,0xc(%rax)
jge    1276 <bgpdump_time2str+0x146>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edx
lea    0xd9e(%rip),%rsi
call   1050 <sprintf@plt>
jmp    128d <bgpdump_time2str+0x15d>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edx
lea    0xd83(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rax
cmpl   $0xa,0x10(%rax)
jge    12c4 <bgpdump_time2str+0x194>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edx
lea    0xd50(%rip),%rsi
call   1050 <sprintf@plt>
jmp    12db <bgpdump_time2str+0x1ab>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edx
lea    0xd35(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rax
cmpl   $0xa,0x14(%rax)
jge    1312 <bgpdump_time2str+0x1e2>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edx
lea    0xd07(%rip),%rsi
call   1050 <sprintf@plt>
jmp    1329 <bgpdump_time2str+0x1f9>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edx
lea    0xcec(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bgpdump_time2str>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rdi),%eax
lea    0x1(%rax),%edx
cmp    $0x9,%eax
lea    0xeae(%rip),%r13
lea    0xea8(%rip),%rbx
mov    %rbx,%rsi
cmovl  %r13,%rsi
lea    0x6(%rsp),%r15
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    0x4(%r12),%edx
cmp    $0xa,%edx
cmovl  %r13,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movslq 0x8(%r12),%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
cmp    $0xa,%edx
lea    0xe43(%rip),%rax
lea    0xe3d(%rip),%rsi
cmovl  %rax,%rsi
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    0xc(%r12),%edx
cmp    $0xa,%edx
lea    0xe1b(%rip),%r13
lea    0xe15(%rip),%rbx
mov    %rbx,%rsi
cmovl  %r13,%rsi
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    0x10(%r12),%edx
cmp    $0xa,%edx
cmovl  %r13,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    0x14(%r12),%edx
cmp    $0xa,%edx
lea    0xdce(%rip),%rax
lea    0xdc8(%rip),%rsi
cmovl  %rax,%rsi
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"0%d/\00"
@.str.1 = [4 x i8] c"%d/\00"
@.str.2 = [5 x i8] c"0%d \00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [5 x i8] c"0%d:\00"
@.str.5 = [4 x i8] c"%d:\00"
@.str.6 = [4 x i8] c"0%d\00"
@.str.7 = [3 x i8] c"%d\00"
define void @bgpdump_time2str(%struct.tm* %0, i8* %1) {
%3 = alloca %struct.tm*
%4 = alloca i8*
%5 = alloca [10 x i8]
store %struct.tm* %0, %struct.tm** %3
store i8* %1, i8** %4
%6 = load %struct.tm*, %struct.tm** %3
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%13 = load %struct.tm*, %struct.tm** %3
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
%17 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %25
18: ; preds = %2
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
%24 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %18, %11
%26 = load i8*, i8** %4
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = load %struct.tm*, %struct.tm** %3
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 1
%31 = load i32, i32* %30
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %39
33: ; preds = %25
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%35 = load %struct.tm*, %struct.tm** %3
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %45
39: ; preds = %25
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%41 = load %struct.tm*, %struct.tm** %3
%42 = getelementptr inbounds %struct.tm, %struct.tm* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %39, %33
%46 = load i8*, i8** %4
%47 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%48 = call i32 @strcat(i8* %46, i8* %47)
%49 = load %struct.tm*, %struct.tm** %3
%50 = getelementptr inbounds %struct.tm, %struct.tm* %49, i32 0, i32 2
%51 = load i32, i32* %50
%52 = srem i32 %51, 100
%53 = icmp slt i32 %52, 10
br i1 %53, label %54, label %61
54: ; preds = %45
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%56 = load %struct.tm*, %struct.tm** %3
%57 = getelementptr inbounds %struct.tm, %struct.tm* %56, i32 0, i32 2
%58 = load i32, i32* %57
%59 = srem i32 %58, 100
%60 = call i32 @sprintf(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %59)
br label %68
61: ; preds = %45
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%63 = load %struct.tm*, %struct.tm** %3
%64 = getelementptr inbounds %struct.tm, %struct.tm* %63, i32 0, i32 2
%65 = load i32, i32* %64
%66 = srem i32 %65, 100
%67 = call i32 @sprintf(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %61, %54
%69 = load i8*, i8** %4
%70 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%71 = call i32 @strcat(i8* %69, i8* %70)
%72 = load %struct.tm*, %struct.tm** %3
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 3
%74 = load i32, i32* %73
%75 = icmp slt i32 %74, 10
br i1 %75, label %76, label %82
76: ; preds = %68
%77 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%78 = load %struct.tm*, %struct.tm** %3
%79 = getelementptr inbounds %struct.tm, %struct.tm* %78, i32 0, i32 3
%80 = load i32, i32* %79
%81 = call i32 @sprintf(i8* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %80)
br label %88
82: ; preds = %68
%83 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%84 = load %struct.tm*, %struct.tm** %3
%85 = getelementptr inbounds %struct.tm, %struct.tm* %84, i32 0, i32 3
%86 = load i32, i32* %85
%87 = call i32 @sprintf(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %82, %76
%89 = load i8*, i8** %4
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%91 = call i32 @strcat(i8* %89, i8* %90)
%92 = load %struct.tm*, %struct.tm** %3
%93 = getelementptr inbounds %struct.tm, %struct.tm* %92, i32 0, i32 4
%94 = load i32, i32* %93
%95 = icmp slt i32 %94, 10
br i1 %95, label %96, label %102
96: ; preds = %88
%97 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%98 = load %struct.tm*, %struct.tm** %3
%99 = getelementptr inbounds %struct.tm, %struct.tm* %98, i32 0, i32 4
%100 = load i32, i32* %99
%101 = call i32 @sprintf(i8* %97, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %100)
br label %108
102: ; preds = %88
%103 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%104 = load %struct.tm*, %struct.tm** %3
%105 = getelementptr inbounds %struct.tm, %struct.tm* %104, i32 0, i32 4
%106 = load i32, i32* %105
%107 = call i32 @sprintf(i8* %103, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %106)
br label %108
108: ; preds = %102, %96
%109 = load i8*, i8** %4
%110 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%111 = call i32 @strcat(i8* %109, i8* %110)
%112 = load %struct.tm*, %struct.tm** %3
%113 = getelementptr inbounds %struct.tm, %struct.tm* %112, i32 0, i32 5
%114 = load i32, i32* %113
%115 = icmp slt i32 %114, 10
br i1 %115, label %116, label %122
116: ; preds = %108
%117 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%118 = load %struct.tm*, %struct.tm** %3
%119 = getelementptr inbounds %struct.tm, %struct.tm* %118, i32 0, i32 5
%120 = load i32, i32* %119
%121 = call i32 @sprintf(i8* %117, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %120)
br label %128
122: ; preds = %108
%123 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%124 = load %struct.tm*, %struct.tm** %3
%125 = getelementptr inbounds %struct.tm, %struct.tm* %124, i32 0, i32 5
%126 = load i32, i32* %125
%127 = call i32 @sprintf(i8* %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %126)
br label %128
128: ; preds = %122, %116
%129 = load i8*, i8** %4
%130 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%131 = call i32 @strcat(i8* %129, i8* %130)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"0%d/\00"
@.str.1 = [4 x i8] c"%d/\00"
@.str.2 = [5 x i8] c"0%d \00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [5 x i8] c"0%d:\00"
@.str.5 = [4 x i8] c"%d:\00"
@.str.6 = [4 x i8] c"0%d\00"
@.str.7 = [3 x i8] c"%d\00"
define void @bgpdump_time2str(%struct.tm* nocapture %0, i8* %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1
%8 = icmp slt i32 %6, 9
%9 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %9, i32 %7)
%11 = call i32 @strcpy(i8* %1, i8* %4)
%12 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%13 = load i32, i32* %12
%14 = icmp slt i32 %13, 10
%15 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%16 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %15, i32 %13)
%17 = call i32 @strcat(i8* %1, i8* %4)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%19 = load i32, i32* %18
%20 = srem i32 %19, 100
%21 = icmp slt i32 %20, 10
%22 = select i1 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%23 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %22, i32 %20)
%24 = call i32 @strcat(i8* %1, i8* %4)
%25 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%26 = load i32, i32* %25
%27 = icmp slt i32 %26, 10
%28 = select i1 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%29 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %28, i32 %26)
%30 = call i32 @strcat(i8* %1, i8* %4)
%31 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%32 = load i32, i32* %31
%33 = icmp slt i32 %32, 10
%34 = select i1 %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%35 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %34, i32 %32)
%36 = call i32 @strcat(i8* %1, i8* %4)
%37 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%38 = load i32, i32* %37
%39 = icmp slt i32 %38, 10
%40 = select i1 %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0)
%41 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %40, i32 %38)
%42 = call i32 @strcat(i8* %1, i8* %4)
ret void
}