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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
char *calloc(int, int);
struct tm *localtime(scalar_t__ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ time(scalar_t__ *);
int get_local_time(char **buffer, int mode) {
  char buf_tmp[50];
  int size;
  time_t temps;
  struct tm *tm;
  if ((time(&temps)) == (time_t)-1) {
    perror("time");
    return -1;
  }
  if ((tm = localtime(&temps)) == NULL) {
    perror("localtime");
    return -1;
  }
  if (mode == 0)
    sprintf(buf_tmp, "[localtime = %02d/%02d/%02d - %02d:%02d:%02d - (%s)]",
            tm->tm_mday, tm->tm_mon + 1, tm->tm_year % 100, tm->tm_hour,
            tm->tm_min, tm->tm_sec,
            (tm->tm_isdst > 0)    ? "Eté"
            : (tm->tm_isdst == 0) ? "Hiver"
                                  : "Undef");
  else if (mode == 1)
    sprintf(buf_tmp, "%02d%02d%02d_%02d%02d%02d", tm->tm_year % 100,
            tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
  assert(*buffer == NULL);
  size = strlen(buf_tmp);
  if ((*buffer = calloc(size + 1, sizeof(char))) == NULL) {
    perror("calloc");
    return -1;
  }
  strcpy(*buffer, buf_tmp);
  return size;
}


x86 assembly (clang, -O0):
<get_local_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x60(%rbp),%rdi
call   1080 <time@plt>
cmp    $0xffffffffffffffff,%rax
jne    11bd <get_local_time+0x3d>
lea    0xe59(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a3 <get_local_time+0x223>
lea    -0x60(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
jne    11ec <get_local_time+0x6c>
lea    0xe25(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a3 <get_local_time+0x223>
cmpl   $0x0,-0x14(%rbp)
jne    12d3 <get_local_time+0x153>
lea    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x78(%rbp)
mov    -0x68(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x68(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x70(%rbp)
mov    -0x68(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jle    1269 <get_local_time+0xe9>
lea    0xde2(%rip),%rax
mov    %rax,-0x90(%rbp)
jmp    128e <get_local_time+0x10e>
mov    -0x68(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xdd2(%rip),%rax
lea    0xdc5(%rip),%rcx
cmp    $0x0,%rdx
cmove  %rcx,%rax
mov    %rax,-0x90(%rbp)
mov    -0x6c(%rbp),%r10d
mov    -0x70(%rbp),%r11d
mov    -0x74(%rbp),%r9d
mov    -0x78(%rbp),%r8d
mov    -0x7c(%rbp),%ecx
mov    -0x80(%rbp),%edx
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rax
lea    0xd51(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    1333 <get_local_time+0x1b3>
cmpl   $0x1,-0x14(%rbp)
jne    132e <get_local_time+0x1ae>
lea    -0x50(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x68(%rbp),%rax
mov    (%rax),%r8d
mov    -0x68(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x68(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x68(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xd31(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    1333 <get_local_time+0x1b3>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    138d <get_local_time+0x20d>
lea    0xcee(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a3 <get_local_time+0x223>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_local_time>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x8(%rsp),%rdi
call   1080 <time@plt>
cmp    $0xffffffffffffffff,%rax
je     12c8 <get_local_time+0x148>
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     12d1 <get_local_time+0x151>
cmp    $0x1,%ebx
je     1236 <get_local_time+0xb6>
test   %ebx,%ebx
jne    1281 <get_local_time+0x101>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
add    $0x1,%ecx
movslq 0x8(%rax),%r8
imul   $0x51eb851f,%r8,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x25,%rsi
add    %edi,%esi
imul   $0x64,%esi,%esi
sub    %esi,%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
cmpq   $0x0,0x18(%rax)
lea    0xe4a(%rip),%rsi
lea    0xe49(%rip),%rdi
cmove  %rsi,%rdi
mov    0x14(%rax),%r11d
lea    0xe2f(%rip),%rbx
cmovle %rdi,%rbx
sub    $0x8,%rsp
lea    0xdeb(%rip),%rsi
lea    0x18(%rsp),%rdi
xor    %eax,%eax
push   %rbx
push   %r11
push   %r10
call   10a0 <sprintf@plt>
add    $0x20,%rsp
jmp    1281 <get_local_time+0x101>
movslq 0x8(%rax),%rdx
imul   $0x51eb851f,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rcx
add    %esi,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%edx
mov    (%rax),%r8d
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
mov    0x14(%rax),%ebx
lea    0xde2(%rip),%rsi
lea    0x10(%rsp),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
call   10a0 <sprintf@plt>
add    $0x10,%rsp
xor    %edi,%edi
cmpq   $0x0,(%r14)
sete   %dil
call   1070 <assert@plt>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0x1(%rbx),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     12da <get_local_time+0x15a>
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd36(%rip),%rdi
jmp    12e1 <get_local_time+0x161>
lea    0xd28(%rip),%rdi
jmp    12e1 <get_local_time+0x161>
lea    0xd89(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%ebx
jmp    12be <get_local_time+0x13e>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
@.str = [5 x i8] c"time\00"
@.str.1 = [10 x i8] c"localtime\00"
@.str.2 = [53 x i8] c"[localtime = %02d/%02d/%02d - %02d:%02d:%02d - (%s)]\00"
@.str.3 = [5 x i8] c"Et\C3\A9\00"
@.str.4 = [6 x i8] c"Hiver\00"
@.str.5 = [6 x i8] c"Undef\00"
@.str.6 = [26 x i8] c"%02d%02d%02d_%02d%02d%02d\00"
@.str.7 = [7 x i8] c"calloc\00"
define i32 @get_local_time(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [50 x i8]
%7 = alloca i32
%8 = alloca i64
%9 = alloca %struct.tm*
store i8** %0, i8*** %4
store i32 %1, i32* %5
%10 = call i64 @time(i64* %8)
%11 = icmp eq i64 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %107
14: ; preds = %2
%15 = call %struct.tm* @localtime(i64* %8)
store %struct.tm* %15, %struct.tm** %9
%16 = icmp eq %struct.tm* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %107
19: ; preds = %14
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %59
22: ; preds = %19
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%24 = load %struct.tm*, %struct.tm** %9
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %9
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
%31 = load %struct.tm*, %struct.tm** %9
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 2
%33 = load i32, i32* %32
%34 = srem i32 %33, 100
%35 = load %struct.tm*, %struct.tm** %9
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 3
%37 = load i32, i32* %36
%38 = load %struct.tm*, %struct.tm** %9
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 4
%40 = load i32, i32* %39
%41 = load %struct.tm*, %struct.tm** %9
%42 = getelementptr inbounds %struct.tm, %struct.tm* %41, i32 0, i32 5
%43 = load i32, i32* %42
%44 = load %struct.tm*, %struct.tm** %9
%45 = getelementptr inbounds %struct.tm, %struct.tm* %44, i32 0, i32 6
%46 = load i64, i64* %45
%47 = icmp sgt i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %22
br label %56
49: ; preds = %22
%50 = load %struct.tm*, %struct.tm** %9
%51 = getelementptr inbounds %struct.tm, %struct.tm* %50, i32 0, i32 6
%52 = load i64, i64* %51
%53 = icmp eq i64 %52, 0
%54 = zext i1 %53 to i64
%55 = select i1 %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
br label %56
56: ; preds = %49, %48
%57 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %48 ], [ %55, %49 ]
%58 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, i32, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %30, i32 %34, i32 %37, i32 %40, i32 %43, i8* %57)
br label %86
59: ; preds = %19
%60 = load i32, i32* %5
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %85
62: ; preds = %59
%63 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%64 = load %struct.tm*, %struct.tm** %9
%65 = getelementptr inbounds %struct.tm, %struct.tm* %64, i32 0, i32 2
%66 = load i32, i32* %65
%67 = srem i32 %66, 100
%68 = load %struct.tm*, %struct.tm** %9
%69 = getelementptr inbounds %struct.tm, %struct.tm* %68, i32 0, i32 1
%70 = load i32, i32* %69
%71 = add nsw i32 %70, 1
%72 = load %struct.tm*, %struct.tm** %9
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = load %struct.tm*, %struct.tm** %9
%76 = getelementptr inbounds %struct.tm, %struct.tm* %75, i32 0, i32 3
%77 = load i32, i32* %76
%78 = load %struct.tm*, %struct.tm** %9
%79 = getelementptr inbounds %struct.tm, %struct.tm* %78, i32 0, i32 4
%80 = load i32, i32* %79
%81 = load %struct.tm*, %struct.tm** %9
%82 = getelementptr inbounds %struct.tm, %struct.tm* %81, i32 0, i32 5
%83 = load i32, i32* %82
%84 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, i32, ...) @sprintf(i8* %63, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %67, i32 %71, i32 %74, i32 %77, i32 %80, i32 %83)
br label %85
85: ; preds = %62, %59
br label %86
86: ; preds = %85, %56
%87 = load i8**, i8*** %4
%88 = load i8*, i8** %87
%89 = icmp eq i8* %88, null
%90 = zext i1 %89 to i32
%91 = call i32 @assert(i32 %90)
%92 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%93 = call i32 @strlen(i8* %92)
store i32 %93, i32* %7
%94 = load i32, i32* %7
%95 = add nsw i32 %94, 1
%96 = call i8* @calloc(i32 %95, i32 1)
%97 = load i8**, i8*** %4
store i8* %96, i8** %97
%98 = icmp eq i8* %96, null
br i1 %98, label %99, label %101
99: ; preds = %86
%100 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %107
101: ; preds = %86
%102 = load i8**, i8*** %4
%103 = load i8*, i8** %102
%104 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%105 = call i32 @strcpy(i8* %103, i8* %104)
%106 = load i32, i32* %7
store i32 %106, i32* %3
br label %107
107: ; preds = %101, %99, %17, %12
%108 = load i32, i32* %3
ret i32 %108
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
@.str = [5 x i8] c"time\00"
@.str.1 = [10 x i8] c"localtime\00"
@.str.2 = [53 x i8] c"[localtime = %02d/%02d/%02d - %02d:%02d:%02d - (%s)]\00"
@.str.3 = [5 x i8] c"Et\C3\A9\00"
@.str.4 = [6 x i8] c"Hiver\00"
@.str.5 = [6 x i8] c"Undef\00"
@.str.6 = [26 x i8] c"%02d%02d%02d_%02d%02d%02d\00"
@.str.7 = [7 x i8] c"calloc\00"
define i32 @get_local_time(i8** nocapture %0, i32 %1) {
%3 = alloca [50 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = bitcast i64* %4 to i8*
%7 = call i64 @time(i64* %4)
%8 = icmp eq i64 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %68
11: ; preds = %2
%12 = call %struct.tm* @localtime(i64* %4)
%13 = icmp eq %struct.tm* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %68
16: ; preds = %11
switch i32 %1, label %55 [
i32 0, label %17
i32 1, label %39
]
17: ; preds = %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 2
%24 = load i32, i32* %23
%25 = srem i32 %24, 100
%26 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 3
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 4
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 5
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 6
%33 = load i64, i64* %32
%34 = icmp sgt i64 %33, 0
%35 = icmp eq i64 %33, 0
%36 = select i1 %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%37 = select i1 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %36
%38 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, i32, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22, i32 %25, i32 %27, i32 %29, i32 %31, i8* %37)
br label %55
39: ; preds = %16
%40 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 2
%41 = load i32, i32* %40
%42 = srem i32 %41, 100
%43 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 1
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
%46 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 0
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 3
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 4
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 0, i32 5
%53 = load i32, i32* %52
%54 = call i32 (i8*, i8*, i32, i32, i32, i32, i32, i32, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %42, i32 %45, i32 %47, i32 %49, i32 %51, i32 %53)
br label %55
55: ; preds = %16, %39, %17
%56 = load i8*, i8** %0
%57 = icmp eq i8* %56, null
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @strlen(i8* %5)
%61 = add nsw i32 %60, 1
%62 = call i8* @calloc(i32 %61, i32 1)
store i8* %62, i8** %0
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %66
64: ; preds = %55
%65 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %68
66: ; preds = %55
%67 = call i32 @strcpy(i8* %62, i8* %5)
br label %68
68: ; preds = %66, %64, %14, %9
%69 = phi i32 [ -1, %9 ], [ -1, %14 ], [ -1, %64 ], [ %60, %66 ]
ret i32 %69
}