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

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int mktime(struct tm *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
char *setlocale(int /*<<< orphan*/, char const *);
int main(void) {
  const char *locales[] = {NULL, "", "C"};
  size_t i = 0;
  struct tm atm;
  time_t t;
  atm.tm_sec = 0;
  atm.tm_min = 0;
  atm.tm_hour = 0;
  atm.tm_mday = 1;
  atm.tm_mon = 1 - 1;
  atm.tm_year = 1970 - 1900;
  atm.tm_isdst = -1;
  for (i = 0; i < sizeof(locales) / sizeof(locales[0]); i++) {
    printf("Local is: %s\n", setlocale(LC_ALL, locales[i]));
    t = mktime(&atm);
    if (t == -1)
      puts("Illegal time.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2caa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2ca7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2ca4(%rip),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x1,-0x50(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x46,-0x48(%rbp)
movl   $0xffffffff,-0x44(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x3,-0x28(%rbp)
jae    121d <main+0xdd>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rsi
call   1060 <setlocale@plt>
mov    %rax,%rsi
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
jne    1207 <main+0xc7>
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
jmp    120c <main+0xcc>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11b4 <main+0x74>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e78(%rip),%rbx
mov    (%rbx),%edi
xor    %esi,%esi
call   1060 <setlocale@plt>
lea    0xe9a(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1050 <mktime@plt>
cmp    $0xffffffff,%eax
jne    1199 <main+0x59>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edi
lea    0xe7d(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe64(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1050 <mktime@plt>
cmp    $0xffffffff,%eax
jne    11cf <main+0x8f>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edi
lea    0xe38(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe2e(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1050 <mktime@plt>
cmp    $0xffffffff,%eax
jne    1205 <main+0xc5>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i64, i64, i64 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"C\00"
@__const.main.locales = [3 x i8*] [i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [14 x i8] c"Local is: %s\0A\00"
@LC_ALL = global i32 0
@.str.3 = [14 x i8] c"Illegal time.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8*]
%3 = alloca i64
%4 = alloca %struct.tm
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [3 x i8*]* %2 to i8*
store i64 0, i64* %3
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 6
store i64 0, i64* %7
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 5
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 4
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 1, i32* %10
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i32 0, i32* %11
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
store i32 70, i32* %12
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 3
store i32 -1, i32* %13
store i64 0, i64* %3
br label %14
14: ; preds = %30, %0
%15 = load i64, i64* %3
%16 = icmp ult i64 %15, 3
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load i32, i32* @LC_ALL
%19 = load i64, i64* %3
%20 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = call i8* @setlocale(i32 %18, i8* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @mktime(%struct.tm* %4)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %17
br label %30
30: ; preds = %29
%31 = load i64, i64* %3
%32 = add i64 %31, 1
store i64 %32, i64* %3
br label %14
33: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i64, i64, i64 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"C\00"
@.str.2 = [14 x i8] c"Local is: %s\0A\00"
@LC_ALL = global i32 0
@.str.3 = [14 x i8] c"Illegal time.\00"
define i32 @main() {
%1 = alloca %struct.tm
%2 = bitcast %struct.tm* %1 to i8*
%3 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
%4 = bitcast i64* %3 to i8*
%5 = bitcast %struct.tm* %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 0, i32 70, i32 -1>, <4 x i32>* %5
%6 = load i32, i32* @LC_ALL
%7 = tail call i8* @setlocale(i32 %6, i8* null)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 @mktime(%struct.tm* %1)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %0, %11
%14 = load i32, i32* @LC_ALL
%15 = tail call i8* @setlocale(i32 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i32 @mktime(%struct.tm* %1)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %13
%22 = load i32, i32* @LC_ALL
%23 = tail call i8* @setlocale(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = call i32 @mktime(%struct.tm* %1)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %21
ret i32 0
}