#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;
  int tm_mon;
  int tm_mday;
  int tm_year;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char const *const, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, char *);
size_t strlen(char const *const);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *aim_interpolate_variables(const char *const input,
                                const char *const nickname) {
  static char output[16384];
  int o = 0, gotpercent = 0;
  size_t nl, dl, tl, l, i;
  char date[15], tim[15];
  {
    int hour;
    int am = 1;
    struct tm *t;
    time_t b;
    b = time(NULL);
    t = localtime(&b);
    if (t == NULL)
      return (NULL);
    hour = t->tm_hour;
    if (hour >= 12)
      am = 0;
    if (hour > 12)
      hour -= 12;
    if (hour == 0)
      hour = 12;
    sprintf(tim, "%d:%02d:%02d %s", hour, t->tm_min, t->tm_sec,
            am == 1 ? "AM" : "PM");
    snprintf(date, 15, "%d/%d/%d", t->tm_mon + 1, t->tm_mday,
             t->tm_year + 1900);
  }
  nl = strlen(nickname);
  dl = strlen(date);
  tl = strlen(tim);
  l = strlen(input);
  for (i = 0; i < l; i++)
    switch (input[i]) {
    case '%':
      if (gotpercent == 1) {
        gotpercent = 0;
        output[o++] = '%';
        output[o++] = '%';
      } else
        gotpercent = 1;
      break;
    case 'n':
      if (gotpercent == 1) {
        gotpercent = 0;
        memcpy(&output[o], nickname, nl);
        o += nl;
      } else
        output[o++] = 'n';
      break;
    case 'd':
      if (gotpercent == 1) {
        gotpercent = 0;
        memcpy(&output[o], date, dl);
        o += dl;
      } else
        output[o++] = 'd';
      break;
    case 't':
      if (gotpercent == 1) {
        gotpercent = 0;
        memcpy(&output[o], tim, tl);
        o += tl;
      } else
        output[o++] = 't';
      break;
    default:
      if (gotpercent == 1) {
        gotpercent = 0;
        output[o++] = '%';
      }
      output[o++] = input[i];
    }
  output[o] = 0;
  return (output);
}


x86 assembly (clang, -O0):
<aim_interpolate_variables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x70(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x7c(%rbp)
lea    -0x7c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    11b9 <aim_interpolate_variables+0x59>
movq   $0x0,-0x8(%rbp)
jmp    14e9 <aim_interpolate_variables+0x389>
mov    -0x78(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xc,-0x6c(%rbp)
jl     11d3 <aim_interpolate_variables+0x73>
movl   $0x0,-0x70(%rbp)
cmpl   $0xc,-0x6c(%rbp)
jle    11e6 <aim_interpolate_variables+0x86>
mov    -0x6c(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jne    11f7 <aim_interpolate_variables+0x97>
movl   $0xc,-0x6c(%rbp)
lea    -0x66(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x78(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x70(%rbp),%esi
lea    0xdfc(%rip),%r9
lea    0xdf2(%rip),%rax
cmp    $0x1,%esi
cmove  %rax,%r9
lea    0xdd4(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x57(%rbp),%rdi
mov    -0x78(%rbp),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
mov    -0x78(%rbp),%rax
mov    0x10(%rax),%r8d
mov    -0x78(%rbp),%rax
mov    0x14(%rax),%r9d
add    $0x76c,%r9d
mov    $0xf,%esi
lea    0xdb4(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x57(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
lea    -0x66(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    14cf <aim_interpolate_variables+0x36f>
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x80(%rbp)
sub    $0x25,%eax
je     1301 <aim_interpolate_variables+0x1a1>
jmp    12ce <aim_interpolate_variables+0x16e>
mov    -0x80(%rbp),%eax
sub    $0x64,%eax
je     13b2 <aim_interpolate_variables+0x252>
jmp    12df <aim_interpolate_variables+0x17f>
mov    -0x80(%rbp),%eax
sub    $0x6e,%eax
je     1355 <aim_interpolate_variables+0x1f5>
jmp    12f0 <aim_interpolate_variables+0x190>
mov    -0x80(%rbp),%eax
sub    $0x74,%eax
je     140f <aim_interpolate_variables+0x2af>
jmp    146c <aim_interpolate_variables+0x30c>
cmpl   $0x1,-0x20(%rbp)
jne    1349 <aim_interpolate_variables+0x1e9>
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2d39(%rip),%rax
movb   $0x25,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2d20(%rip),%rax
movb   $0x25,(%rax,%rcx,1)
jmp    1350 <aim_interpolate_variables+0x1f0>
movl   $0x1,-0x20(%rbp)
jmp    14b9 <aim_interpolate_variables+0x359>
cmpl   $0x1,-0x20(%rbp)
jne    1394 <aim_interpolate_variables+0x234>
movl   $0x0,-0x20(%rbp)
movslq -0x1c(%rbp),%rax
lea    0x2cef(%rip),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x28(%rbp),%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    13ad <aim_interpolate_variables+0x24d>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2cb7(%rip),%rax
movb   $0x6e,(%rax,%rcx,1)
jmp    14b9 <aim_interpolate_variables+0x359>
cmpl   $0x1,-0x20(%rbp)
jne    13f1 <aim_interpolate_variables+0x291>
movl   $0x0,-0x20(%rbp)
movslq -0x1c(%rbp),%rax
lea    0x2c92(%rip),%rdi
add    %rax,%rdi
lea    -0x57(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x30(%rbp),%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    140a <aim_interpolate_variables+0x2aa>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2c5a(%rip),%rax
movb   $0x64,(%rax,%rcx,1)
jmp    14b9 <aim_interpolate_variables+0x359>
cmpl   $0x1,-0x20(%rbp)
jne    144e <aim_interpolate_variables+0x2ee>
movl   $0x0,-0x20(%rbp)
movslq -0x1c(%rbp),%rax
lea    0x2c35(%rip),%rdi
add    %rax,%rdi
lea    -0x66(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    1467 <aim_interpolate_variables+0x307>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2bfd(%rip),%rax
movb   $0x74,(%rax,%rcx,1)
jmp    14b9 <aim_interpolate_variables+0x359>
cmpl   $0x1,-0x20(%rbp)
jne    1496 <aim_interpolate_variables+0x336>
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2bce(%rip),%rax
movb   $0x25,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %eax,%rcx
lea    0x2baa(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    14be <aim_interpolate_variables+0x35e>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    12a3 <aim_interpolate_variables+0x143>
movslq -0x1c(%rbp),%rcx
lea    0x2b86(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2b7b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aim_interpolate_variables>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     13a6 <aim_interpolate_variables+0x246>
mov    %rax,%rbp
mov    (%rax),%eax
mov    0x4(%rbp),%ecx
lea    -0xc(%rax),%esi
cmp    $0xd,%eax
cmovl  %eax,%esi
test   %esi,%esi
mov    $0xc,%edx
cmovne %esi,%edx
cmp    $0xc,%eax
mov    0x8(%rbp),%r8d
lea    0xe55(%rip),%rax
lea    0xe4b(%rip),%r9
cmovge %rax,%r9
lea    0xe30(%rip),%rsi
mov    %rbx,0x10(%rsp)
lea    0x3a(%rsp),%r13
mov    %r13,%rdi
call   1080 <sprintf@plt>
mov    0xc(%rbp),%ecx
mov    0x10(%rbp),%r8d
add    $0x1,%ecx
mov    $0x76c,%r9d
add    0x14(%rbp),%r9d
lea    0xe19(%rip),%rdx
lea    0x49(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xf,%esi
call   1050 <snprintf@plt>
mov    %r15,0x30(%rsp)
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,0x28(%rsp)
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rax,0x20(%rsp)
mov    %r13,%rdi
mov    0x10(%rsp),%r13
call   1040 <strlen@plt>
mov    %rax,0x18(%rsp)
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     1396 <aim_interpolate_variables+0x236>
mov    %rax,%r12
xor    %r15d,%r15d
lea    0x2e02(%rip),%rbp
xor    %r14d,%r14d
xor    %ecx,%ecx
jmp    128b <aim_interpolate_variables+0x12b>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %r14d,%rcx
add    $0x1,%r14d
mov    %al,(%rcx,%rbp,1)
xor    %eax,%eax
add    $0x1,%r15
mov    %eax,%ecx
cmp    %r15,%r12
je     1396 <aim_interpolate_variables+0x236>
movzbl 0x0(%r13,%r15,1),%eax
movsbl %al,%edx
cmp    $0x6d,%edx
jg     12c0 <aim_interpolate_variables+0x160>
cmp    $0x25,%edx
je     12e0 <aim_interpolate_variables+0x180>
cmp    $0x64,%edx
jne    1320 <aim_interpolate_variables+0x1c0>
cmp    $0x1,%ecx
je     133f <aim_interpolate_variables+0x1df>
movslq %r14d,%rax
add    $0x1,%r14d
movb   $0x64,(%rax,%rbp,1)
jmp    127a <aim_interpolate_variables+0x11a>
nopl   (%rax)
cmp    $0x6e,%edx
je     1300 <aim_interpolate_variables+0x1a0>
cmp    $0x74,%edx
jne    1320 <aim_interpolate_variables+0x1c0>
cmp    $0x1,%ecx
je     1351 <aim_interpolate_variables+0x1f1>
movslq %r14d,%rax
add    $0x1,%r14d
movb   $0x74,(%rax,%rbp,1)
jmp    127a <aim_interpolate_variables+0x11a>
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    127c <aim_interpolate_variables+0x11c>
movslq %r14d,%rax
movw   $0x2525,(%rax,%rbp,1)
add    $0x2,%r14d
jmp    127a <aim_interpolate_variables+0x11a>
nopl   0x0(%rax)
cmp    $0x1,%ecx
je     1371 <aim_interpolate_variables+0x211>
movslq %r14d,%rax
add    $0x1,%r14d
movb   $0x6e,(%rax,%rbp,1)
jmp    127a <aim_interpolate_variables+0x11a>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x1,%ecx
jne    1270 <aim_interpolate_variables+0x110>
movslq %r14d,%rax
add    $0x1,%r14d
movb   $0x25,(%rax,%rbp,1)
movzbl 0x0(%r13,%r15,1),%eax
jmp    1270 <aim_interpolate_variables+0x110>
movslq %r14d,%rdi
add    %rbp,%rdi
lea    0x49(%rsp),%rsi
mov    0x20(%rsp),%rbx
jmp    1361 <aim_interpolate_variables+0x201>
movslq %r14d,%rdi
add    %rbp,%rdi
lea    0x3a(%rsp),%rsi
mov    0x18(%rsp),%rbx
mov    %rbx,%rdx
call   1060 <memcpy@plt>
add    %ebx,%r14d
jmp    127a <aim_interpolate_variables+0x11a>
movslq %r14d,%rdi
add    %rbp,%rdi
mov    0x30(%rsp),%rsi
mov    0x28(%rsp),%r13
mov    %r13,%rdx
call   1060 <memcpy@plt>
add    %r13d,%r14d
mov    0x10(%rsp),%r13
jmp    127a <aim_interpolate_variables+0x11a>
movslq %r14d,%rcx
lea    0x2cc0(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
jmp    13a8 <aim_interpolate_variables+0x248>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@aim_interpolate_variables.output = internal global [16384 x i8] zeroinitializer
@.str = [16 x i8] c"%d:%02d:%02d %s\00"
@.str.1 = [3 x i8] c"AM\00"
@.str.2 = [3 x i8] c"PM\00"
@.str.3 = [9 x i8] c"%d/%d/%d\00"
define i8* @aim_interpolate_variables(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca [15 x i8]
%14 = alloca [15 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca %struct.tm*
%18 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %16
%19 = call i32 @time(i32* null)
store i32 %19, i32* %18
%20 = call %struct.tm* @localtime(i32* %18)
store %struct.tm* %20, %struct.tm** %17
%21 = load %struct.tm*, %struct.tm** %17
%22 = icmp eq %struct.tm* %21, null
br i1 %22, label %23, label %24
23: ; preds = %2
store i8* null, i8** %3
br label %188
24: ; preds = %2
%25 = load %struct.tm*, %struct.tm** %17
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 0
%27 = load i32, i32* %26
store i32 %27, i32* %15
%28 = load i32, i32* %15
%29 = icmp sge i32 %28, 12
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 0, i32* %16
br label %31
31: ; preds = %30, %24
%32 = load i32, i32* %15
%33 = icmp sgt i32 %32, 12
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %15
%36 = sub nsw i32 %35, 12
store i32 %36, i32* %15
br label %37
37: ; preds = %34, %31
%38 = load i32, i32* %15
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 12, i32* %15
br label %41
41: ; preds = %40, %37
%42 = getelementptr inbounds [15 x i8], [15 x i8]* %14, i64 0, i64 0
%43 = load i32, i32* %15
%44 = load %struct.tm*, %struct.tm** %17
%45 = getelementptr inbounds %struct.tm, %struct.tm* %44, i32 0, i32 1
%46 = load i32, i32* %45
%47 = load %struct.tm*, %struct.tm** %17
%48 = getelementptr inbounds %struct.tm, %struct.tm* %47, i32 0, i32 2
%49 = load i32, i32* %48
%50 = load i32, i32* %16
%51 = icmp eq i32 %50, 1
%52 = zext i1 %51 to i64
%53 = select i1 %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%54 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %46, i32 %49, i8* %53)
%55 = getelementptr inbounds [15 x i8], [15 x i8]* %13, i64 0, i64 0
%56 = load %struct.tm*, %struct.tm** %17
%57 = getelementptr inbounds %struct.tm, %struct.tm* %56, i32 0, i32 3
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
%60 = load %struct.tm*, %struct.tm** %17
%61 = getelementptr inbounds %struct.tm, %struct.tm* %60, i32 0, i32 4
%62 = load i32, i32* %61
%63 = load %struct.tm*, %struct.tm** %17
%64 = getelementptr inbounds %struct.tm, %struct.tm* %63, i32 0, i32 5
%65 = load i32, i32* %64
%66 = add nsw i32 %65, 1900
%67 = call i32 @snprintf(i8* %55, i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %59, i32 %62, i32 %66)
%68 = load i8*, i8** %5
%69 = call i64 @strlen(i8* %68)
store i64 %69, i64* %8
%70 = getelementptr inbounds [15 x i8], [15 x i8]* %13, i64 0, i64 0
%71 = call i64 @strlen(i8* %70)
store i64 %71, i64* %9
%72 = getelementptr inbounds [15 x i8], [15 x i8]* %14, i64 0, i64 0
%73 = call i64 @strlen(i8* %72)
store i64 %73, i64* %10
%74 = load i8*, i8** %4
%75 = call i64 @strlen(i8* %74)
store i64 %75, i64* %11
store i64 0, i64* %12
br label %76
76: ; preds = %181, %41
%77 = load i64, i64* %12
%78 = load i64, i64* %11
%79 = icmp ult i64 %77, %78
br i1 %79, label %80, label %184
80: ; preds = %76
%81 = load i8*, i8** %4
%82 = load i64, i64* %12
%83 = getelementptr inbounds i8, i8* %81, i64 %82
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
switch i32 %85, label %163 [
i32 37, label %86
i32 110, label %100
i32 100, label %121
i32 116, label %142
]
86: ; preds = %80
%87 = load i32, i32* %7
%88 = icmp eq i32 %87, 1
br i1 %88, label %89, label %98
89: ; preds = %86
store i32 0, i32* %7
%90 = load i32, i32* %6
%91 = add nsw i32 %90, 1
store i32 %91, i32* %6
%92 = sext i32 %90 to i64
%93 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %92
store i8 37, i8* %93
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
store i32 %95, i32* %6
%96 = sext i32 %94 to i64
%97 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %96
store i8 37, i8* %97
br label %99
98: ; preds = %86
store i32 1, i32* %7
br label %99
99: ; preds = %98, %89
br label %180
100: ; preds = %80
%101 = load i32, i32* %7
%102 = icmp eq i32 %101, 1
br i1 %102, label %103, label %115
103: ; preds = %100
store i32 0, i32* %7
%104 = load i32, i32* %6
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %105
%107 = load i8*, i8** %5
%108 = load i64, i64* %8
%109 = call i32 @memcpy(i8* %106, i8* %107, i64 %108)
%110 = load i64, i64* %8
%111 = load i32, i32* %6
%112 = sext i32 %111 to i64
%113 = add i64 %112, %110
%114 = trunc i64 %113 to i32
store i32 %114, i32* %6
br label %120
115: ; preds = %100
%116 = load i32, i32* %6
%117 = add nsw i32 %116, 1
store i32 %117, i32* %6
%118 = sext i32 %116 to i64
%119 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %118
store i8 110, i8* %119
br label %120
120: ; preds = %115, %103
br label %180
121: ; preds = %80
%122 = load i32, i32* %7
%123 = icmp eq i32 %122, 1
br i1 %123, label %124, label %136
124: ; preds = %121
store i32 0, i32* %7
%125 = load i32, i32* %6
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %126
%128 = getelementptr inbounds [15 x i8], [15 x i8]* %13, i64 0, i64 0
%129 = load i64, i64* %9
%130 = call i32 @memcpy(i8* %127, i8* %128, i64 %129)
%131 = load i64, i64* %9
%132 = load i32, i32* %6
%133 = sext i32 %132 to i64
%134 = add i64 %133, %131
%135 = trunc i64 %134 to i32
store i32 %135, i32* %6
br label %141
136: ; preds = %121
%137 = load i32, i32* %6
%138 = add nsw i32 %137, 1
store i32 %138, i32* %6
%139 = sext i32 %137 to i64
%140 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %139
store i8 100, i8* %140
br label %141
141: ; preds = %136, %124
br label %180
142: ; preds = %80
%143 = load i32, i32* %7
%144 = icmp eq i32 %143, 1
br i1 %144, label %145, label %157
145: ; preds = %142
store i32 0, i32* %7
%146 = load i32, i32* %6
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %147
%149 = getelementptr inbounds [15 x i8], [15 x i8]* %14, i64 0, i64 0
%150 = load i64, i64* %10
%151 = call i32 @memcpy(i8* %148, i8* %149, i64 %150)
%152 = load i64, i64* %10
%153 = load i32, i32* %6
%154 = sext i32 %153 to i64
%155 = add i64 %154, %152
%156 = trunc i64 %155 to i32
store i32 %156, i32* %6
br label %162
157: ; preds = %142
%158 = load i32, i32* %6
%159 = add nsw i32 %158, 1
store i32 %159, i32* %6
%160 = sext i32 %158 to i64
%161 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %160
store i8 116, i8* %161
br label %162
162: ; preds = %157, %145
br label %180
163: ; preds = %80
%164 = load i32, i32* %7
%165 = icmp eq i32 %164, 1
br i1 %165, label %166, label %171
166: ; preds = %163
store i32 0, i32* %7
%167 = load i32, i32* %6
%168 = add nsw i32 %167, 1
store i32 %168, i32* %6
%169 = sext i32 %167 to i64
%170 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %169
store i8 37, i8* %170
br label %171
171: ; preds = %166, %163
%172 = load i8*, i8** %4
%173 = load i64, i64* %12
%174 = getelementptr inbounds i8, i8* %172, i64 %173
%175 = load i8, i8* %174
%176 = load i32, i32* %6
%177 = add nsw i32 %176, 1
store i32 %177, i32* %6
%178 = sext i32 %176 to i64
%179 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %178
store i8 %175, i8* %179
br label %180
180: ; preds = %171, %162, %141, %120, %99
br label %181
181: ; preds = %180
%182 = load i64, i64* %12
%183 = add i64 %182, 1
store i64 %183, i64* %12
br label %76
184: ; preds = %76
%185 = load i32, i32* %6
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %186
store i8 0, i8* %187
store i8* getelementptr inbounds ([16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 0), i8** %3
br label %188
188: ; preds = %184, %23
%189 = load i8*, i8** %3
ret i8* %189
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@aim_interpolate_variables.output = internal global [16384 x i8] zeroinitializer
@.str = [16 x i8] c"%d:%02d:%02d %s\00"
@.str.1 = [3 x i8] c"AM\00"
@.str.2 = [3 x i8] c"PM\00"
@.str.3 = [9 x i8] c"%d/%d/%d\00"
define i8* @aim_interpolate_variables(i8* nocapture %0, i8* %1) {
%3 = alloca [15 x i8]
%4 = alloca [15 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 @time(i32* null)
store i32 %9, i32* %5
%10 = call %struct.tm* @localtime(i32* %5)
%11 = icmp eq %struct.tm* %10, null
br i1 %11, label %116, label %12
12: ; preds = %2
%13 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 0
%14 = load i32, i32* %13
%15 = icmp sgt i32 %14, 11
%16 = icmp sgt i32 %14, 12
%17 = add nsw i32 %14, -12
%18 = select i1 %16, i32 %17, i32 %14
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i32 12, i32 %18
%21 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
%24 = load i32, i32* %23
%25 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%26 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %22, i32 %24, i8* %25)
%27 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 3
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
%30 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 4
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 5
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1900
%35 = call i32 @snprintf(i8* %6, i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %31, i32 %34)
%36 = call i64 @strlen(i8* dereferenceable(1) %1)
%37 = call i64 @strlen(i8* %6)
%38 = call i64 @strlen(i8* %7)
%39 = call i64 @strlen(i8* dereferenceable(1) %0)
%40 = icmp eq i64 %39, 0
br i1 %40, label %112, label %41
41: ; preds = %12
%42 = trunc i64 %38 to i32
%43 = trunc i64 %37 to i32
%44 = trunc i64 %36 to i32
br label %45
45: ; preds = %41, %107
%46 = phi i64 [ 0, %41 ], [ %110, %107 ]
%47 = phi i32 [ 0, %41 ], [ %109, %107 ]
%48 = phi i32 [ 0, %41 ], [ %108, %107 ]
%49 = getelementptr inbounds i8, i8* %0, i64 %46
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
switch i32 %51, label %94 [
i32 37, label %52
i32 110, label %61
i32 100, label %72
i32 116, label %83
]
52: ; preds = %45
%53 = icmp eq i32 %48, 1
br i1 %53, label %54, label %107
54: ; preds = %52
%55 = add nsw i32 %47, 1
%56 = sext i32 %47 to i64
%57 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %56
store i8 37, i8* %57
%58 = add nsw i32 %47, 2
%59 = sext i32 %55 to i64
%60 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %59
store i8 37, i8* %60
br label %107
61: ; preds = %45
%62 = icmp eq i32 %48, 1
br i1 %62, label %63, label %68
63: ; preds = %61
%64 = sext i32 %47 to i64
%65 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %64
%66 = call i32 @memcpy(i8* %65, i8* %1, i64 %36)
%67 = add i32 %47, %44
br label %107
68: ; preds = %61
%69 = add nsw i32 %47, 1
%70 = sext i32 %47 to i64
%71 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %70
store i8 110, i8* %71
br label %107
72: ; preds = %45
%73 = icmp eq i32 %48, 1
br i1 %73, label %74, label %79
74: ; preds = %72
%75 = sext i32 %47 to i64
%76 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %75
%77 = call i32 @memcpy(i8* %76, i8* %6, i64 %37)
%78 = add i32 %47, %43
br label %107
79: ; preds = %72
%80 = add nsw i32 %47, 1
%81 = sext i32 %47 to i64
%82 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %81
store i8 100, i8* %82
br label %107
83: ; preds = %45
%84 = icmp eq i32 %48, 1
br i1 %84, label %85, label %90
85: ; preds = %83
%86 = sext i32 %47 to i64
%87 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %86
%88 = call i32 @memcpy(i8* %87, i8* %7, i64 %38)
%89 = add i32 %47, %42
br label %107
90: ; preds = %83
%91 = add nsw i32 %47, 1
%92 = sext i32 %47 to i64
%93 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %92
store i8 116, i8* %93
br label %107
94: ; preds = %45
%95 = icmp eq i32 %48, 1
br i1 %95, label %96, label %101
96: ; preds = %94
%97 = add nsw i32 %47, 1
%98 = sext i32 %47 to i64
%99 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %98
store i8 37, i8* %99
%100 = load i8, i8* %49
br label %101
101: ; preds = %96, %94
%102 = phi i8 [ %100, %96 ], [ %50, %94 ]
%103 = phi i32 [ %97, %96 ], [ %47, %94 ]
%104 = add nsw i32 %103, 1
%105 = sext i32 %103 to i64
%106 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %105
store i8 %102, i8* %106
br label %107
107: ; preds = %52, %101, %54, %68, %63, %79, %74, %90, %85
%108 = phi i32 [ 0, %101 ], [ 0, %85 ], [ 0, %90 ], [ 0, %74 ], [ 0, %79 ], [ 0, %63 ], [ 0, %68 ], [ 0, %54 ], [ 1, %52 ]
%109 = phi i32 [ %104, %101 ], [ %89, %85 ], [ %91, %90 ], [ %78, %74 ], [ %80, %79 ], [ %67, %63 ], [ %69, %68 ], [ %58, %54 ], [ %47, %52 ]
%110 = add nuw i64 %46, 1
%111 = icmp eq i64 %110, %39
br i1 %111, label %112, label %45
112: ; preds = %107, %12
%113 = phi i32 [ 0, %12 ], [ %109, %107 ]
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 %114
store i8 0, i8* %115
br label %117
116: ; preds = %2
br label %117
117: ; preds = %116, %112
%118 = phi i8* [ getelementptr inbounds ([16384 x i8], [16384 x i8]* @aim_interpolate_variables.output, i64 0, i64 0), %112 ], [ null, %116 ]
ret i8* %118
}