#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 dummy;
};
struct timespec {
  int /*<<< orphan*/ tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ LC_TIME;
char *calloc(int, int);
int clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ free(char *);
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
size_t strlen(char *);
char *flu_tstamp(struct timespec *ts, int utc, char format) {
  if (ts == NULL) {
    struct timespec tss;
    int i = clock_gettime(CLOCK_REALTIME, &tss);
    if (i != 0)
      return NULL;
    ts = &tss;
  }
  if (strchr("zZrgT", format))
    utc = 1;
  struct tm *tm = utc ? gmtime(&ts->tv_sec) : localtime(&ts->tv_sec);
  if (tm == NULL)
    return NULL;
  char *r = calloc(32, sizeof(char));
  if (format == 'z' || format == 'Z') {
    strftime(r, 32, "%Y-%m-%dT%H:%M:%SZ", tm);
    return r;
  }
  if (format == 'T') {
    strftime(r, 32, "%Y%m%dT%H%M%SZ", tm);
    return r;
  }
  if (format == 'r' || format == 'g' || format == '2') {
    char *loc = strdup(setlocale(LC_TIME, NULL));
    setlocale(LC_TIME, "en_US");
    if (format == '2')
      strftime(r, 32, "%a, %d %b %Y %T %z", tm);
    else
      strftime(r, 32, "%a, %d %b %Y %T UTC", tm);
    setlocale(LC_TIME, loc);
    free(loc);
    if (format == 'g')
      strcpy(r + strlen(r) - 3, "GMT");
    return r;
  }
  strftime(r, 32, "%Y%m%d.%H%M%S", tm);
  size_t l = strlen(r);
  if (format == 'd') {
    *(r + l - 7) = '\0';
    return r;
  }
  if (format == 'h') {
    *(r + l - 2) = '\0';
    return r;
  }
  if (format == 's') {
    return r;
  }
  *(r + l) = '.';
  sprintf(r + l + 1, "%09li", ts->tv_nsec);
  size_t off = 9;
  if (format == 'u')
    off = 6;
  else if (format == 'm')
    off = 3;
  *(r + l + 1 + off) = '\0';
  return r;
}


x86 assembly (clang, -O0):
<flu_tstamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %al,-0x15(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1213 <flu_tstamp+0x53>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1060 <clock_gettime@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     120b <flu_tstamp+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
lea    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xde6(%rip),%rdi
movsbl -0x15(%rbp),%esi
call   1080 <strchr@plt>
cmp    $0x0,%rax
je     1234 <flu_tstamp+0x74>
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1254 <flu_tstamp+0x94>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   10c0 <gmtime@plt>
mov    %rax,-0x58(%rbp)
jmp    1265 <flu_tstamp+0xa5>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1040 <localtime@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1285 <flu_tstamp+0xc5>
movq   $0x0,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
mov    $0x20,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x38(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x7a,%eax
je     12b2 <flu_tstamp+0xf2>
movsbl -0x15(%rbp),%eax
cmp    $0x5a,%eax
jne    12d8 <flu_tstamp+0x118>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xd40(%rip),%rdx
call   10b0 <strftime@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
movsbl -0x15(%rbp),%eax
cmp    $0x54,%eax
jne    130b <flu_tstamp+0x14b>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xd20(%rip),%rdx
call   10b0 <strftime@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
movsbl -0x15(%rbp),%eax
cmp    $0x72,%eax
je     1332 <flu_tstamp+0x172>
movsbl -0x15(%rbp),%eax
cmp    $0x67,%eax
je     1332 <flu_tstamp+0x172>
movsbl -0x15(%rbp),%eax
cmp    $0x32,%eax
jne    1405 <flu_tstamp+0x245>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <setlocale@plt>
mov    %eax,%edi
call   10e0 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
call   10a0 <setlocale@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x32,%eax
jne    138f <flu_tstamp+0x1cf>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xca9(%rip),%rdx
call   10b0 <strftime@plt>
jmp    13a8 <flu_tstamp+0x1e8>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xc9e(%rip),%rdx
call   10b0 <strftime@plt>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rsi
call   10a0 <setlocale@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x67,%eax
jne    13f8 <flu_tstamp+0x238>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x60(%rbp),%rdi
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xc62(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xc40(%rip),%rdx
call   10b0 <strftime@plt>
mov    -0x38(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,-0x48(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x64,%eax
jne    1452 <flu_tstamp+0x292>
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
movb   $0x0,-0x7(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
movsbl -0x15(%rbp),%eax
cmp    $0x68,%eax
jne    1479 <flu_tstamp+0x2b9>
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
movb   $0x0,-0x2(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
movsbl -0x15(%rbp),%eax
cmp    $0x73,%eax
jne    1493 <flu_tstamp+0x2d3>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1512 <flu_tstamp+0x352>
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
add    -0x48(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xbaf(%rip),%rsi
call   10d0 <sprintf@plt>
movq   $0x9,-0x50(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x75,%eax
jne    14df <flu_tstamp+0x31f>
movq   $0x6,-0x50(%rbp)
jmp    14f9 <flu_tstamp+0x339>
movsbl -0x15(%rbp),%eax
cmp    $0x6d,%eax
jne    14f4 <flu_tstamp+0x334>
movq   $0x3,-0x50(%rbp)
jmp    14f9 <flu_tstamp+0x339>
mov    -0x38(%rbp),%rax
add    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flu_tstamp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%rbx
test   %rdi,%rdi
je     123e <flu_tstamp+0x7e>
movsbl %r15b,%esi
lea    0xe1c(%rip),%rdi
call   1080 <strchr@plt>
lea    0x4(%rbx),%rdi
test   %ebp,%ebp
jne    11fd <flu_tstamp+0x3d>
test   %rax,%rax
jne    11fd <flu_tstamp+0x3d>
call   1040 <localtime@plt>
jmp    1202 <flu_tstamp+0x42>
call   10c0 <gmtime@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1258 <flu_tstamp+0x98>
mov    $0x20,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,%r14
mov    %r15d,%eax
and    $0xdf,%al
cmp    $0x5a,%al
jne    126b <flu_tstamp+0xab>
lea    0xdda(%rip),%rdx
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rbp,%rcx
call   10b0 <strftime@plt>
jmp    125b <flu_tstamp+0x9b>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <clock_gettime@plt>
test   %eax,%eax
je     11d9 <flu_tstamp+0x19>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x66,%r15b
jg     128a <flu_tstamp+0xca>
cmp    $0x32,%r15b
je     129a <flu_tstamp+0xda>
cmp    $0x54,%r15b
jne    132b <flu_tstamp+0x16b>
lea    0xd91(%rip),%rdx
jmp    122c <flu_tstamp+0x6c>
cmp    $0x67,%r15b
je     129a <flu_tstamp+0xda>
cmp    $0x72,%r15b
jne    132b <flu_tstamp+0x16b>
mov    0x2d47(%rip),%r12
mov    (%r12),%edi
xor    %esi,%esi
call   10a0 <setlocale@plt>
mov    %eax,%edi
call   10e0 <strdup@plt>
mov    %rax,%rbx
mov    (%r12),%edi
lea    0xd67(%rip),%rsi
call   10a0 <setlocale@plt>
cmp    $0x32,%r15b
lea    0xd5d(%rip),%rax
lea    0xd69(%rip),%rdx
cmove  %rax,%rdx
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rbp,%rcx
call   10b0 <strftime@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
call   10a0 <setlocale@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
cmp    $0x67,%r15b
jne    125b <flu_tstamp+0x9b>
mov    %r14,%rdi
call   1070 <strlen@plt>
lea    (%r14,%rax,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xd34(%rip),%rsi
call   1050 <strcpy@plt>
jmp    125b <flu_tstamp+0x9b>
lea    0xd27(%rip),%rdx
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rbp,%rcx
call   10b0 <strftime@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
cmp    $0x73,%r15b
je     125b <flu_tstamp+0x9b>
cmp    $0x68,%r15b
je     136b <flu_tstamp+0x1ab>
cmp    $0x64,%r15b
jne    1376 <flu_tstamp+0x1b6>
movb   $0x0,-0x7(%r14,%rax,1)
jmp    125b <flu_tstamp+0x9b>
movb   $0x0,-0x2(%r14,%rax,1)
jmp    125b <flu_tstamp+0x9b>
lea    (%r14,%rax,1),%rbp
movb   $0x2e,(%r14,%rax,1)
lea    (%r14,%rax,1),%rdi
add    $0x1,%rdi
mov    (%rbx),%edx
lea    0xcd7(%rip),%rsi
call   10d0 <sprintf@plt>
cmp    $0x6d,%r15b
mov    $0x3,%eax
mov    $0x9,%ecx
cmove  %rax,%rcx
cmp    $0x75,%r15b
mov    $0x6,%eax
cmovne %rcx,%rax
movb   $0x0,0x1(%rax,%rbp,1)
jmp    125b <flu_tstamp+0x9b>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.tm = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [6 x i8] c"zZrgT\00"
@.str.1 = [19 x i8] c"%Y-%m-%dT%H:%M:%SZ\00"
@.str.2 = [15 x i8] c"%Y%m%dT%H%M%SZ\00"
@LC_TIME = global i32 0
@.str.3 = [6 x i8] c"en_US\00"
@.str.4 = [19 x i8] c"%a, %d %b %Y %T %z\00"
@.str.5 = [20 x i8] c"%a, %d %b %Y %T UTC\00"
@.str.6 = [4 x i8] c"GMT\00"
@.str.7 = [14 x i8] c"%Y%m%d.%H%M%S\00"
@.str.8 = [6 x i8] c"%09li\00"
define i8* @flu_tstamp(%struct.timespec* %0, i32 %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca %struct.timespec*
%6 = alloca i32
%7 = alloca i8
%8 = alloca %struct.timespec
%9 = alloca i32
%10 = alloca %struct.tm*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
store %struct.timespec* %0, %struct.timespec** %5
store i32 %1, i32* %6
store i8 %2, i8* %7
%15 = load %struct.timespec*, %struct.timespec** %5
%16 = icmp eq %struct.timespec* %15, null
br i1 %16, label %17, label %24
17: ; preds = %3
%18 = load i32, i32* @CLOCK_REALTIME
%19 = call i32 @clock_gettime(i32 %18, %struct.timespec* %8)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i8* null, i8** %4
br label %176
23: ; preds = %17
store %struct.timespec* %8, %struct.timespec** %5
br label %24
24: ; preds = %23, %3
%25 = load i8, i8* %7
%26 = call i64 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %6
br label %29
29: ; preds = %28, %24
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load %struct.timespec*, %struct.timespec** %5
%34 = getelementptr inbounds %struct.timespec, %struct.timespec* %33, i32 0, i32 1
%35 = call %struct.tm* @gmtime(i32* %34)
br label %40
36: ; preds = %29
%37 = load %struct.timespec*, %struct.timespec** %5
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %37, i32 0, i32 1
%39 = call %struct.tm* @localtime(i32* %38)
br label %40
40: ; preds = %36, %32
%41 = phi %struct.tm* [ %35, %32 ], [ %39, %36 ]
store %struct.tm* %41, %struct.tm** %10
%42 = load %struct.tm*, %struct.tm** %10
%43 = icmp eq %struct.tm* %42, null
br i1 %43, label %44, label %45
44: ; preds = %40
store i8* null, i8** %4
br label %176
45: ; preds = %40
%46 = call i8* @calloc(i32 32, i32 1)
store i8* %46, i8** %11
%47 = load i8, i8* %7
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 122
br i1 %49, label %54, label %50
50: ; preds = %45
%51 = load i8, i8* %7
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 90
br i1 %53, label %54, label %59
54: ; preds = %50, %45
%55 = load i8*, i8** %11
%56 = load %struct.tm*, %struct.tm** %10
%57 = call i32 @strftime(i8* %55, i32 32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %56)
%58 = load i8*, i8** %11
store i8* %58, i8** %4
br label %176
59: ; preds = %50
%60 = load i8, i8* %7
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 84
br i1 %62, label %63, label %68
63: ; preds = %59
%64 = load i8*, i8** %11
%65 = load %struct.tm*, %struct.tm** %10
%66 = call i32 @strftime(i8* %64, i32 32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %65)
%67 = load i8*, i8** %11
store i8* %67, i8** %4
br label %176
68: ; preds = %59
%69 = load i8, i8* %7
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 114
br i1 %71, label %80, label %72
72: ; preds = %68
%73 = load i8, i8* %7
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 103
br i1 %75, label %80, label %76
76: ; preds = %72
%77 = load i8, i8* %7
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 50
br i1 %79, label %80, label %115
80: ; preds = %76, %72, %68
%81 = load i32, i32* @LC_TIME
%82 = call i32 @setlocale(i32 %81, i8* null)
%83 = call i8* @strdup(i32 %82)
store i8* %83, i8** %12
%84 = load i32, i32* @LC_TIME
%85 = call i32 @setlocale(i32 %84, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%86 = load i8, i8* %7
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 50
br i1 %88, label %89, label %93
89: ; preds = %80
%90 = load i8*, i8** %11
%91 = load %struct.tm*, %struct.tm** %10
%92 = call i32 @strftime(i8* %90, i32 32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %91)
br label %97
93: ; preds = %80
%94 = load i8*, i8** %11
%95 = load %struct.tm*, %struct.tm** %10
%96 = call i32 @strftime(i8* %94, i32 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %95)
br label %97
97: ; preds = %93, %89
%98 = load i32, i32* @LC_TIME
%99 = load i8*, i8** %12
%100 = call i32 @setlocale(i32 %98, i8* %99)
%101 = load i8*, i8** %12
%102 = call i32 @free(i8* %101)
%103 = load i8, i8* %7
%104 = sext i8 %103 to i32
%105 = icmp eq i32 %104, 103
br i1 %105, label %106, label %113
106: ; preds = %97
%107 = load i8*, i8** %11
%108 = load i8*, i8** %11
%109 = call i64 @strlen(i8* %108)
%110 = getelementptr inbounds i8, i8* %107, i64 %109
%111 = getelementptr inbounds i8, i8* %110, i64 -3
%112 = call i32 @strcpy(i8* %111, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %113
113: ; preds = %106, %97
%114 = load i8*, i8** %11
store i8* %114, i8** %4
br label %176
115: ; preds = %76
%116 = load i8*, i8** %11
%117 = load %struct.tm*, %struct.tm** %10
%118 = call i32 @strftime(i8* %116, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %117)
%119 = load i8*, i8** %11
%120 = call i64 @strlen(i8* %119)
store i64 %120, i64* %13
%121 = load i8, i8* %7
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 100
br i1 %123, label %124, label %130
124: ; preds = %115
%125 = load i8*, i8** %11
%126 = load i64, i64* %13
%127 = getelementptr inbounds i8, i8* %125, i64 %126
%128 = getelementptr inbounds i8, i8* %127, i64 -7
store i8 0, i8* %128
%129 = load i8*, i8** %11
store i8* %129, i8** %4
br label %176
130: ; preds = %115
%131 = load i8, i8* %7
%132 = sext i8 %131 to i32
%133 = icmp eq i32 %132, 104
br i1 %133, label %134, label %140
134: ; preds = %130
%135 = load i8*, i8** %11
%136 = load i64, i64* %13
%137 = getelementptr inbounds i8, i8* %135, i64 %136
%138 = getelementptr inbounds i8, i8* %137, i64 -2
store i8 0, i8* %138
%139 = load i8*, i8** %11
store i8* %139, i8** %4
br label %176
140: ; preds = %130
%141 = load i8, i8* %7
%142 = sext i8 %141 to i32
%143 = icmp eq i32 %142, 115
br i1 %143, label %144, label %146
144: ; preds = %140
%145 = load i8*, i8** %11
store i8* %145, i8** %4
br label %176
146: ; preds = %140
%147 = load i8*, i8** %11
%148 = load i64, i64* %13
%149 = getelementptr inbounds i8, i8* %147, i64 %148
store i8 46, i8* %149
%150 = load i8*, i8** %11
%151 = load i64, i64* %13
%152 = getelementptr inbounds i8, i8* %150, i64 %151
%153 = getelementptr inbounds i8, i8* %152, i64 1
%154 = load %struct.timespec*, %struct.timespec** %5
%155 = getelementptr inbounds %struct.timespec, %struct.timespec* %154, i32 0, i32 0
%156 = load i32, i32* %155
%157 = call i32 @sprintf(i8* %153, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %156)
store i64 9, i64* %14
%158 = load i8, i8* %7
%159 = sext i8 %158 to i32
%160 = icmp eq i32 %159, 117
br i1 %160, label %161, label %162
161: ; preds = %146
store i64 6, i64* %14
br label %168
162: ; preds = %146
%163 = load i8, i8* %7
%164 = sext i8 %163 to i32
%165 = icmp eq i32 %164, 109
br i1 %165, label %166, label %167
166: ; preds = %162
store i64 3, i64* %14
br label %167
167: ; preds = %166, %162
br label %168
168: ; preds = %167, %161
%169 = load i8*, i8** %11
%170 = load i64, i64* %13
%171 = getelementptr inbounds i8, i8* %169, i64 %170
%172 = getelementptr inbounds i8, i8* %171, i64 1
%173 = load i64, i64* %14
%174 = getelementptr inbounds i8, i8* %172, i64 %173
store i8 0, i8* %174
%175 = load i8*, i8** %11
store i8* %175, i8** %4
br label %176
176: ; preds = %168, %144, %134, %124, %113, %63, %54, %44, %22
%177 = load i8*, i8** %4
ret i8* %177
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.tm = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [6 x i8] c"zZrgT\00"
@.str.1 = [19 x i8] c"%Y-%m-%dT%H:%M:%SZ\00"
@.str.2 = [15 x i8] c"%Y%m%dT%H%M%SZ\00"
@LC_TIME = global i32 0
@.str.3 = [6 x i8] c"en_US\00"
@.str.4 = [19 x i8] c"%a, %d %b %Y %T %z\00"
@.str.5 = [20 x i8] c"%a, %d %b %Y %T UTC\00"
@.str.6 = [4 x i8] c"GMT\00"
@.str.7 = [14 x i8] c"%Y%m%d.%H%M%S\00"
@.str.8 = [6 x i8] c"%09li\00"
define i8* @flu_tstamp(%struct.timespec* %0, i32 %1, i8 signext %2) {
%4 = alloca %struct.timespec
%5 = icmp eq %struct.timespec* %0, null
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = bitcast %struct.timespec* %4 to i8*
%8 = load i32, i32* @CLOCK_REALTIME
%9 = call i32 @clock_gettime(i32 %8, %struct.timespec* %4)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %72
11: ; preds = %6, %3
%12 = phi %struct.timespec* [ %4, %6 ], [ %0, %3 ]
%13 = call i64 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%14 = icmp eq i64 %13, 0
%15 = icmp eq i32 %1, 0
%16 = and i1 %15, %14
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i64 0, i32 1
br i1 %16, label %20, label %18
18: ; preds = %11
%19 = call %struct.tm* @gmtime(i32* %17)
br label %22
20: ; preds = %11
%21 = call %struct.tm* @localtime(i32* %17)
br label %22
22: ; preds = %20, %18
%23 = phi %struct.tm* [ %19, %18 ], [ %21, %20 ]
%24 = icmp eq %struct.tm* %23, null
br i1 %24, label %72, label %25
25: ; preds = %22
%26 = call dereferenceable_or_null(32) i8* @calloc(i32 32, i32 1)
%27 = and i8 %2, -33
%28 = icmp eq i8 %27, 90
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @strftime(i8* %26, i32 32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %23)
br label %72
31: ; preds = %25
switch i8 %2, label %52 [
i8 84, label %32
i8 114, label %34
i8 103, label %34
i8 50, label %34
]
32: ; preds = %31
%33 = call i32 @strftime(i8* %26, i32 32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %23)
br label %72
34: ; preds = %31, %31, %31
%35 = icmp eq i8 %2, 103
%36 = icmp eq i8 %2, 50
%37 = load i32, i32* @LC_TIME
%38 = call i32 @setlocale(i32 %37, i8* null)
%39 = call i8* @strdup(i32 %38)
%40 = load i32, i32* @LC_TIME
%41 = call i32 @setlocale(i32 %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%42 = select i1 %36, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0)
%43 = call i32 @strftime(i8* %26, i32 32, i8* %42, %struct.tm* %23)
%44 = load i32, i32* @LC_TIME
%45 = call i32 @setlocale(i32 %44, i8* %39)
%46 = call i32 @free(i8* %39)
br i1 %35, label %47, label %72
47: ; preds = %34
%48 = call i64 @strlen(i8* dereferenceable(1) %26)
%49 = getelementptr inbounds i8, i8* %26, i64 %48
%50 = getelementptr inbounds i8, i8* %49, i64 -3
%51 = call i32 @strcpy(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %72
52: ; preds = %31
%53 = call i32 @strftime(i8* %26, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %23)
%54 = call i64 @strlen(i8* dereferenceable(1) %26)
switch i8 %2, label %61 [
i8 100, label %55
i8 104, label %58
i8 115, label %72
]
55: ; preds = %52
%56 = getelementptr inbounds i8, i8* %26, i64 %54
%57 = getelementptr inbounds i8, i8* %56, i64 -7
store i8 0, i8* %57
br label %72
58: ; preds = %52
%59 = getelementptr inbounds i8, i8* %26, i64 %54
%60 = getelementptr inbounds i8, i8* %59, i64 -2
store i8 0, i8* %60
br label %72
61: ; preds = %52
%62 = getelementptr inbounds i8, i8* %26, i64 %54
store i8 46, i8* %62
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i64 0, i32 0
%65 = load i32, i32* %64
%66 = call i32 @sprintf(i8* %63, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %65)
%67 = icmp eq i8 %2, 109
%68 = select i1 %67, i64 3, i64 9
%69 = icmp eq i8 %2, 117
%70 = select i1 %69, i64 6, i64 %68
%71 = getelementptr inbounds i8, i8* %63, i64 %70
store i8 0, i8* %71
br label %72
72: ; preds = %6, %22, %55, %58, %61, %52, %34, %47, %32, %29
%73 = phi i8* [ null, %6 ], [ null, %22 ], [ %26, %55 ], [ %26, %58 ], [ %26, %61 ], [ %26, %52 ], [ %26, %34 ], [ %26, %47 ], [ %26, %32 ], [ %26, %29 ]
ret i8* %73
}