#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_year;
  int tm_mon;
  int tm_mday;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int /*<<< orphan*/,
                           int /*<<< orphan*/, ...);
int /*<<< orphan*/ strncpy(char *, char *, int);
void setMicomTime(time_t theGMTTime, char *destString, int seconds) {
  struct tm *now_tm;
  char tmpString[13];
  now_tm = localtime(&theGMTTime);
  if (seconds) {
    sprintf(tmpString, "%02d%02d%02d%02d%02d%02d", now_tm->tm_year - 100,
            now_tm->tm_mon + 1, now_tm->tm_mday, now_tm->tm_hour,
            now_tm->tm_min, now_tm->tm_sec);
    strncpy(destString, tmpString, 12);
  } else {
    sprintf(tmpString, "%02d%02d%02d%02d%02d", now_tm->tm_year - 100,
            now_tm->tm_mon + 1, now_tm->tm_mday, now_tm->tm_hour,
            now_tm->tm_min);
    strncpy(destString, tmpString, 10);
  }
}


x86 assembly (clang, -O0):
<setMicomTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11bc <setMicomTime+0x8c>
lea    -0x2d(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
sub    $0x64,%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r10d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe6a(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2d(%rbp),%rsi
mov    $0xc,%edx
call   1040 <strncpy@plt>
jmp    120d <setMicomTime+0xdd>
lea    -0x2d(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
sub    $0x64,%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%eax
lea    0xe13(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2d(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strncpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setMicomTime>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
add    $0xffffff9c,%edx
add    $0x1,%ecx
mov    0x8(%rax),%r8d
mov    0x10(%rax),%r9d
mov    0xc(%rax),%ebx
test   %ebp,%ebp
je     1188 <setMicomTime+0x58>
mov    0x14(%rax),%ebp
lea    0xe91(%rip),%rsi
lea    0x13(%rsp),%rdi
xor    %eax,%eax
push   %rbp
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
mov    $0xc,%edx
jmp    11a9 <setMicomTime+0x79>
sub    $0x8,%rsp
lea    0xe71(%rip),%rsi
lea    0x1b(%rsp),%rdi
xor    %eax,%eax
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
mov    $0xa,%edx
lea    0x13(%rsp),%rsi
mov    %r14,%rdi
call   1040 <strncpy@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"%02d%02d%02d%02d%02d%02d\00"
@.str.1 = [21 x i8] c"%02d%02d%02d%02d%02d\00"
define void @setMicomTime(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.tm*
%8 = alloca [13 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %9, %struct.tm** %7
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %38
12: ; preds = %3
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%14 = load %struct.tm*, %struct.tm** %7
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %16, 100
%18 = load %struct.tm*, %struct.tm** %7
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
%22 = load %struct.tm*, %struct.tm** %7
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 2
%24 = load i32, i32* %23
%25 = load %struct.tm*, %struct.tm** %7
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 4
%27 = load i32, i32* %26
%28 = load %struct.tm*, %struct.tm** %7
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 3
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %7
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 5
%33 = load i32, i32* %32
%34 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %21, i32 %24, i32 %27, i32 %30, i32 %33)
%35 = load i8*, i8** %5
%36 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%37 = call i32 @strncpy(i8* %35, i8* %36, i32 12)
br label %61
38: ; preds = %3
%39 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%40 = load %struct.tm*, %struct.tm** %7
%41 = getelementptr inbounds %struct.tm, %struct.tm* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = sub nsw i32 %42, 100
%44 = load %struct.tm*, %struct.tm** %7
%45 = getelementptr inbounds %struct.tm, %struct.tm* %44, i32 0, i32 1
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
%48 = load %struct.tm*, %struct.tm** %7
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i32 0, i32 2
%50 = load i32, i32* %49
%51 = load %struct.tm*, %struct.tm** %7
%52 = getelementptr inbounds %struct.tm, %struct.tm* %51, i32 0, i32 4
%53 = load i32, i32* %52
%54 = load %struct.tm*, %struct.tm** %7
%55 = getelementptr inbounds %struct.tm, %struct.tm* %54, i32 0, i32 3
%56 = load i32, i32* %55
%57 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %47, i32 %50, i32 %53, i32 %56)
%58 = load i8*, i8** %5
%59 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%60 = call i32 @strncpy(i8* %58, i8* %59, i32 10)
br label %61
61: ; preds = %38, %12
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"%02d%02d%02d%02d%02d%02d\00"
@.str.1 = [21 x i8] c"%02d%02d%02d%02d%02d\00"
define void @setMicomTime(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca [13 x i8]
store i32 %0, i32* %4
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%7 = call %struct.tm* @localtime(i32* %4)
%8 = icmp eq i32 %2, 0
%9 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, -100
%12 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 4
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 3
%20 = load i32, i32* %19
br i1 %8, label %25, label %21
21: ; preds = %3
%22 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 5
%23 = load i32, i32* %22
%24 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %14, i32 %16, i32 %18, i32 %20, i32 %23)
br label %27
25: ; preds = %3
%26 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14, i32 %16, i32 %18, i32 %20)
br label %27
27: ; preds = %25, %21
%28 = phi i32 [ 10, %25 ], [ 12, %21 ]
%29 = call i32 @strncpy(i8* %1, i8* %6, i32 %28)
ret void
}