#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 char wchar_t;
typedef int /*<<< orphan*/ wbuf;
typedef int /*<<< orphan*/ tm;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
};
typedef int /*<<< orphan*/ *locale_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ LC_ALL_MASK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(struct tm *, char, int);
int /*<<< orphan*/ *newlocale(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(char *, char *);
size_t strftime(char *, int, char *, struct tm *);
scalar_t__ strftime_l(char *, int, char *, struct tm *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *uselocale(int /*<<< orphan*/ *);
scalar_t__ wcscmp(char *, char *);
scalar_t__ wcsftime_l(char *, int, char *, struct tm *, int /*<<< orphan*/ *);
int main(void) {
  locale_t l;
  locale_t old;
  struct tm tm;
  char buf[1000];
  wchar_t wbuf[1000];
  int result = 0;
  size_t n;
  l = newlocale(LC_ALL_MASK, "de_DE.ISO-8859-1", NULL);
  if (l == NULL) {
    puts("newlocale failed");
    exit(1);
  }
  memset(&tm, '\0', sizeof(tm));
  tm.tm_year = 102;
  tm.tm_mon = 2;
  tm.tm_mday = 1;
  if (strftime(buf, sizeof(buf), "%e %^B %Y", &tm) == 0) {
    puts("initial strftime failed");
    exit(1);
  }
  if (strcmp(buf, " 1 MARCH 2002") != 0) {
    printf("initial strftime: expected \"%s\", got \"%s\"\n", " 1 MARCH 2002",
           buf);
    result = 1;
  } else
    printf("got \"%s\"\n", buf);
  if (strftime_l(buf, sizeof(buf), "%e %^B %Y", &tm, l) == 0) {
    puts("strftime_l failed");
    result = 1;
  } else if (strcmp(buf, " 1 M\xc4RZ 2002") != 0) {
    printf("strftime_l: expected \"%s\", got \"%s\"\n", " 1 M\xc4RZ 2002", buf);
    result = 1;
  } else {
    setlocale(LC_ALL, "de_DE.ISO-8859-1");
    printf("got \"%s\"\n", buf);
    setlocale(LC_ALL, "C");
  }
  if (wcsftime_l(wbuf, sizeof(wbuf) / sizeof(wbuf[0]), L"%e %^B %Y", &tm, l) ==
      0) {
    puts("wcsftime_l failed");
    result = 1;
  } else if (wcscmp(wbuf, L" 1 M\x00c4RZ 2002") != 0) {
    printf("wcsftime_l: expected \"%ls\", got \"%ls\"\n", L" 1 M\x00c4RZ 2002",
           wbuf);
    result = 1;
  } else {
    setlocale(LC_ALL, "de_DE.ISO-8859-1");
    printf("got \"%ls\"\n", wbuf);
    setlocale(LC_ALL, "C");
  }
  old = uselocale(l);
  n = strftime(buf, sizeof(buf), "%e %^B %Y", &tm);
  (void)uselocale(old);
  if (n == 0) {
    puts("strftime after first uselocale failed");
    result = 1;
  } else if (strcmp(buf, " 1 M\xc4RZ 2002") != 0) {
    printf("strftime in non-C locale: expected \"%s\", got \"%s\"\n",
           " 1 M\xc4RZ 2002", buf);
    result = 1;
  } else {
    setlocale(LC_ALL, "de_DE.ISO-8859-1");
    printf("got \"%s\"\n", buf);
    setlocale(LC_ALL, "C");
  }
  if (strftime(buf, sizeof(buf), "%e %^B %Y", &tm) == 0) {
    puts("strftime after second uselocale failed");
    result = 1;
  } else if (strcmp(buf, " 1 MARCH 2002") != 0) {
    printf("initial strftime: expected \"%s\", got \"%s\"\n", " 1 MARCH 2002",
           buf);
    result = 1;
  } else
    printf("got \"%s\"\n", buf);
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x804(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <newlocale@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    121a <main+0x5a>
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
movl   $0x66,-0x28(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x3e8,%esi
lea    0xdd0(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   10d0 <strftime@plt>
cmp    $0x0,%rax
jne    127b <main+0xbb>
lea    0xdc0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x410(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12c3 <main+0x103>
lea    -0x410(%rbp),%rdx
lea    0xdac(%rip),%rdi
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x804(%rbp)
jmp    12d8 <main+0x118>
lea    -0x410(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%r8
mov    $0x3e8,%esi
lea    0xd33(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   10b0 <strftime_l@plt>
cmp    $0x0,%rax
jne    131d <main+0x15d>
lea    0xd74(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x804(%rbp)
jmp    13a9 <main+0x1e9>
lea    -0x410(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1365 <main+0x1a5>
lea    -0x410(%rbp),%rdx
lea    0xd54(%rip),%rdi
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x804(%rbp)
jmp    13a4 <main+0x1e4>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
call   10c0 <setlocale@plt>
lea    -0x410(%rbp),%rsi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
call   10c0 <setlocale@plt>
jmp    13a9 <main+0x1e9>
lea    -0x800(%rbp),%rdi
mov    -0x10(%rbp),%r8
mov    $0x3e8,%esi
lea    0xdbc(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   10a0 <wcsftime_l@plt>
cmp    $0x0,%rax
jne    13ee <main+0x22e>
lea    0xce9(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x804(%rbp)
jmp    147a <main+0x2ba>
lea    -0x800(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%rax
je     1436 <main+0x276>
lea    -0x800(%rbp),%rdx
lea    0xcbc(%rip),%rdi
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x804(%rbp)
jmp    1475 <main+0x2b5>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
lea    0xbba(%rip),%rsi
call   10c0 <setlocale@plt>
lea    -0x800(%rbp),%rsi
lea    0xc98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
lea    0xc51(%rip),%rsi
call   10c0 <setlocale@plt>
jmp    147a <main+0x2ba>
mov    -0x10(%rbp),%rdi
call   1090 <uselocale@plt>
mov    %rax,-0x18(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x3e8,%esi
lea    0xb88(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   10d0 <strftime@plt>
mov    %rax,-0x810(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <uselocale@plt>
cmpq   $0x0,-0x810(%rbp)
jne    14dc <main+0x31c>
lea    0xc34(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x804(%rbp)
jmp    1568 <main+0x3a8>
lea    -0x410(%rbp),%rdi
lea    0xba5(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1524 <main+0x364>
lea    -0x410(%rbp),%rdx
lea    0xc1b(%rip),%rdi
lea    0xb81(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x804(%rbp)
jmp    1563 <main+0x3a3>
mov    0x2aad(%rip),%rax
mov    (%rax),%edi
lea    0xacc(%rip),%rsi
call   10c0 <setlocale@plt>
lea    -0x410(%rbp),%rsi
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2a83(%rip),%rax
mov    (%rax),%edi
lea    0xb63(%rip),%rsi
call   10c0 <setlocale@plt>
jmp    1568 <main+0x3a8>
lea    -0x410(%rbp),%rdi
mov    $0x3e8,%esi
lea    0xaa7(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   10d0 <strftime@plt>
cmp    $0x0,%rax
jne    15a9 <main+0x3e9>
lea    0xbc0(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x804(%rbp)
jmp    160b <main+0x44b>
lea    -0x410(%rbp),%rdi
lea    0xa8d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     15f1 <main+0x431>
lea    -0x410(%rbp),%rdx
lea    0xa7e(%rip),%rdi
lea    0xa69(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x804(%rbp)
jmp    1606 <main+0x446>
lea    -0x410(%rbp),%rsi
lea    0xb4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    160b <main+0x44b>
mov    -0x804(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x7f0,%rsp
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
xor    %edx,%edx
call   1060 <newlocale@plt>
test   %rax,%rax
je     151e <main+0x35e>
mov    %rax,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
movabs $0x200000066,%rax
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
lea    0xe05(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x3e8,%esi
mov    %rbp,%rcx
call   10d0 <strftime@plt>
test   %rax,%rax
je     1527 <main+0x367>
lea    0xe05(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1270 <main+0xb0>
lea    0xdfd(%rip),%rdi
lea    0xde8(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
jmp    1286 <main+0xc6>
lea    0xed4(%rip),%rdi
xor    %r14d,%r14d
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd95(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    %rsp,%rcx
mov    $0x3e8,%esi
mov    %rbx,%r8
call   10b0 <strftime_l@plt>
test   %rax,%rax
je     12df <main+0x11f>
lea    0xde1(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12f3 <main+0x133>
lea    0xdd8(%rip),%rdi
lea    0xdc4(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
jmp    132b <main+0x16b>
lea    0xd97(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    132b <main+0x16b>
mov    0x2cde(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xcfc(%rip),%rsi
call   10c0 <setlocale@plt>
lea    0xe3b(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%edi
lea    0xd9b(%rip),%rsi
call   10c0 <setlocale@plt>
lea    0xe4a(%rip),%rdx
lea    0x400(%rsp),%rdi
mov    %rsp,%rcx
mov    $0x3e8,%esi
mov    %rbx,%r8
call   10a0 <wcsftime_l@plt>
test   %rax,%rax
je     138d <main+0x1cd>
lea    0xe4e(%rip),%rsi
lea    0x400(%rsp),%rdi
call   1030 <wcscmp@plt>
test   %rax,%rax
je     13a1 <main+0x1e1>
lea    0xd66(%rip),%rdi
lea    0xe2e(%rip),%rsi
lea    0x400(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
jmp    13dc <main+0x21c>
lea    0xd2f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    13dc <main+0x21c>
mov    0x2c30(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc4e(%rip),%rsi
call   10c0 <setlocale@plt>
lea    0xd33(%rip),%rdi
lea    0x400(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%edi
lea    0xcea(%rip),%rsi
call   10c0 <setlocale@plt>
mov    %rbx,%rdi
call   1090 <uselocale@plt>
mov    %rax,%rbx
lea    0xc34(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    %rsp,%rcx
mov    $0x3e8,%esi
call   10d0 <strftime@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1090 <uselocale@plt>
test   %rbp,%rbp
je     1448 <main+0x288>
lea    0xc78(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     145c <main+0x29c>
lea    0xcf5(%rip),%rdi
lea    0xc5b(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
jmp    1492 <main+0x2d2>
lea    0xcad(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    1492 <main+0x2d2>
mov    0x2b75(%rip),%rbx
mov    (%rbx),%edi
lea    0xb94(%rip),%rsi
call   10c0 <setlocale@plt>
lea    0xcd3(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%edi
lea    0xc34(%rip),%rsi
call   10c0 <setlocale@plt>
lea    0xb89(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    %rsp,%rcx
mov    $0x3e8,%esi
call   10d0 <strftime@plt>
test   %rax,%rax
je     14e8 <main+0x328>
lea    0xb8d(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     14fc <main+0x33c>
lea    0xb85(%rip),%rdi
lea    0xb70(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
jmp    150f <main+0x34f>
lea    0xc66(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    150f <main+0x34f>
lea    0xc48(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x7f0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xaec(%rip),%rdi
jmp    152e <main+0x36e>
lea    0xafe(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@LC_ALL_MASK = global i32 0
@.str = [17 x i8] c"de_DE.ISO-8859-1\00"
@.str.1 = [17 x i8] c"newlocale failed\00"
@.str.2 = [10 x i8] c"%e %^B %Y\00"
@.str.3 = [24 x i8] c"initial strftime failed\00"
@.str.4 = [14 x i8] c" 1 MARCH 2002\00"
@.str.5 = [43 x i8] c"initial strftime: expected \22%s\22, got \22%s\22\0A\00"
@.str.6 = [10 x i8] c"got \22%s\22\0A\00"
@.str.7 = [18 x i8] c"strftime_l failed\00"
@.str.8 = [13 x i8] c" 1 M\C4RZ 2002\00"
@.str.9 = [37 x i8] c"strftime_l: expected \22%s\22, got \22%s\22\0A\00"
@LC_ALL = global i32 0
@.str.10 = [2 x i8] c"C\00"
@.str.11 = [10 x i32] [i32 37, i32 101, i32 32, i32 37, i32 94, i32 66, i32 32, i32 37, i32 89, i32 0]
@.str.12 = [18 x i8] c"wcsftime_l failed\00"
@.str.13 = [13 x i32] [i32 32, i32 49, i32 32, i32 77, i32 196, i32 82, i32 90, i32 32, i32 50, i32 48, i32 48, i32 50, i32 0]
@.str.14 = [39 x i8] c"wcsftime_l: expected \22%ls\22, got \22%ls\22\0A\00"
@.str.15 = [11 x i8] c"got \22%ls\22\0A\00"
@.str.16 = [38 x i8] c"strftime after first uselocale failed\00"
@.str.17 = [51 x i8] c"strftime in non-C locale: expected \22%s\22, got \22%s\22\0A\00"
@.str.18 = [39 x i8] c"strftime after second uselocale failed\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca %struct.tm
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %7
%9 = load i32, i32* @LC_ALL_MASK
%10 = call i32* @newlocale(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* null)
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = call i32 @memset(%struct.tm* %4, i8 signext 0, i32 12)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 102, i32* %18
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i32 2, i32* %19
%20 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
store i32 1, i32* %20
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%22 = call i64 @strftime(i8* %21, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %16
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %32)
store i32 1, i32* %7
br label %37
34: ; preds = %27
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %31
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%39 = load i32*, i32** %2
%40 = call i64 @strftime_l(i8* %38, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %4, i32* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %7
br label %59
44: ; preds = %37
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%50 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %49)
store i32 1, i32* %7
br label %58
51: ; preds = %44
%52 = load i32, i32* @LC_ALL
%53 = call i32 @setlocale(i32 %52, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%54 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%55 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @LC_ALL
%57 = call i32 @setlocale(i32 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %58
58: ; preds = %51, %48
br label %59
59: ; preds = %58, %42
%60 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%61 = load i32*, i32** %2
%62 = call i64 @wcsftime_l(i8* %60, i32 1000, i8* bitcast ([10 x i32]* @.str.11 to i8*), %struct.tm* %4, i32* %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %7
br label %81
66: ; preds = %59
%67 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%68 = call i64 @wcscmp(i8* %67, i8* bitcast ([13 x i32]* @.str.13 to i8*))
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%72 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8* bitcast ([13 x i32]* @.str.13 to i8*), i8* %71)
store i32 1, i32* %7
br label %80
73: ; preds = %66
%74 = load i32, i32* @LC_ALL
%75 = call i32 @setlocale(i32 %74, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%76 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%77 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i8* %76)
%78 = load i32, i32* @LC_ALL
%79 = call i32 @setlocale(i32 %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %80
80: ; preds = %73, %70
br label %81
81: ; preds = %80, %64
%82 = load i32*, i32** %2
%83 = call i32* @uselocale(i32* %82)
store i32* %83, i32** %3
%84 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%85 = call i64 @strftime(i8* %84, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %4)
store i64 %85, i64* %8
%86 = load i32*, i32** %3
%87 = call i32* @uselocale(i32* %86)
%88 = load i64, i64* %8
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %81
%91 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.16, i64 0, i64 0))
store i32 1, i32* %7
br label %107
92: ; preds = %81
%93 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%98 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %97)
store i32 1, i32* %7
br label %106
99: ; preds = %92
%100 = load i32, i32* @LC_ALL
%101 = call i32 @setlocale(i32 %100, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%102 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%103 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %102)
%104 = load i32, i32* @LC_ALL
%105 = call i32 @setlocale(i32 %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %106
106: ; preds = %99, %96
br label %107
107: ; preds = %106, %90
%108 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%109 = call i64 @strftime(i8* %108, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %4)
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %107
%112 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.18, i64 0, i64 0))
store i32 1, i32* %7
br label %124
113: ; preds = %107
%114 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%115 = call i64 @strcmp(i8* %114, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %113
%118 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%119 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %118)
store i32 1, i32* %7
br label %123
120: ; preds = %113
%121 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%122 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %121)
br label %123
123: ; preds = %120, %117
br label %124
124: ; preds = %123, %111
%125 = load i32, i32* %7
ret i32 %125
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@LC_ALL_MASK = global i32 0
@.str = [17 x i8] c"de_DE.ISO-8859-1\00"
@.str.1 = [17 x i8] c"newlocale failed\00"
@.str.2 = [10 x i8] c"%e %^B %Y\00"
@.str.3 = [24 x i8] c"initial strftime failed\00"
@.str.4 = [14 x i8] c" 1 MARCH 2002\00"
@.str.5 = [43 x i8] c"initial strftime: expected \22%s\22, got \22%s\22\0A\00"
@.str.6 = [10 x i8] c"got \22%s\22\0A\00"
@.str.7 = [18 x i8] c"strftime_l failed\00"
@.str.8 = [13 x i8] c" 1 M\C4RZ 2002\00"
@.str.9 = [37 x i8] c"strftime_l: expected \22%s\22, got \22%s\22\0A\00"
@LC_ALL = global i32 0
@.str.10 = [2 x i8] c"C\00"
@.str.11 = [10 x i32] [i32 37, i32 101, i32 32, i32 37, i32 94, i32 66, i32 32, i32 37, i32 89, i32 0]
@.str.12 = [18 x i8] c"wcsftime_l failed\00"
@.str.13 = [13 x i32] [i32 32, i32 49, i32 32, i32 77, i32 196, i32 82, i32 90, i32 32, i32 50, i32 48, i32 48, i32 50, i32 0]
@.str.14 = [39 x i8] c"wcsftime_l: expected \22%ls\22, got \22%ls\22\0A\00"
@.str.15 = [11 x i8] c"got \22%ls\22\0A\00"
@.str.16 = [38 x i8] c"strftime after first uselocale failed\00"
@.str.17 = [51 x i8] c"strftime in non-C locale: expected \22%s\22, got \22%s\22\0A\00"
@.str.18 = [39 x i8] c"strftime after second uselocale failed\00"
define i32 @main() {
%1 = alloca %struct.tm
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = bitcast %struct.tm* %1 to i8*
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @LC_ALL_MASK
%8 = tail call i32* @newlocale(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* null)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = call i32 @memset(%struct.tm* %1, i8 signext 0, i32 12)
%15 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i32 102, i32* %15
%16 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i32 2, i32* %16
%17 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i32 1, i32* %17
%18 = call i64 @strftime(i8* %5, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %13
%24 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %30
28: ; preds = %23
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %5)
br label %30
30: ; preds = %28, %26
%31 = phi i32 [ 1, %26 ], [ 0, %28 ]
%32 = call i64 @strftime_l(i8* %5, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %1, i32* %8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %47
36: ; preds = %30
%37 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %5)
br label %47
41: ; preds = %36
%42 = load i32, i32* @LC_ALL
%43 = call i32 @setlocale(i32 %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%45 = load i32, i32* @LC_ALL
%46 = call i32 @setlocale(i32 %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %47
47: ; preds = %39, %41, %34
%48 = phi i32 [ 1, %34 ], [ 1, %39 ], [ %31, %41 ]
%49 = call i64 @wcsftime_l(i8* %6, i32 1000, i8* bitcast ([10 x i32]* @.str.11 to i8*), %struct.tm* %1, i32* %8)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %64
53: ; preds = %47
%54 = call i64 @wcscmp(i8* %6, i8* bitcast ([13 x i32]* @.str.13 to i8*))
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %53
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8* bitcast ([13 x i32]* @.str.13 to i8*), i8* %6)
br label %64
58: ; preds = %53
%59 = load i32, i32* @LC_ALL
%60 = call i32 @setlocale(i32 %59, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%61 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i8* %6)
%62 = load i32, i32* @LC_ALL
%63 = call i32 @setlocale(i32 %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %64
64: ; preds = %56, %58, %51
%65 = phi i32 [ 1, %51 ], [ 1, %56 ], [ %48, %58 ]
%66 = call i32* @uselocale(i32* %8)
%67 = call i64 @strftime(i8* %5, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %1)
%68 = call i32* @uselocale(i32* %66)
%69 = icmp eq i64 %67, 0
br i1 %69, label %70, label %72
70: ; preds = %64
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.16, i64 0, i64 0))
br label %83
72: ; preds = %64
%73 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %5)
br label %83
77: ; preds = %72
%78 = load i32, i32* @LC_ALL
%79 = call i32 @setlocale(i32 %78, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%80 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%81 = load i32, i32* @LC_ALL
%82 = call i32 @setlocale(i32 %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %83
83: ; preds = %75, %77, %70
%84 = phi i32 [ 1, %70 ], [ 1, %75 ], [ %65, %77 ]
%85 = call i64 @strftime(i8* %5, i32 1000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %1)
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.18, i64 0, i64 0))
br label %96
89: ; preds = %83
%90 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %94, label %92
92: ; preds = %89
%93 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %96
94: ; preds = %89
%95 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %5)
br label %96
96: ; preds = %92, %94, %87
%97 = phi i32 [ 1, %87 ], [ 1, %92 ], [ %84, %94 ]
ret i32 %97
}