#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*/ tm;
struct tm {
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_wday;
  int tm_yday;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ *strptime(char *, char *, struct tm *);
int do_test(void) {
  int result = 0;
  struct tm tm;
  memset(&tm, 0xaa, sizeof(tm));
  if (strptime("2007", "%Y", &tm) == NULL ||
      strptime("12", "%d", &tm) == NULL || strptime("Feb", "%b", &tm) == NULL ||
      strptime("13", "%M", &tm) == NULL || strptime("21", "%S", &tm) == NULL ||
      strptime("16", "%H", &tm) == NULL) {
    puts("strptimes failed");
    result = 1;
  }
  if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16 ||
      tm.tm_mday != 12 || tm.tm_mon != 1 || tm.tm_year != 107 ||
      tm.tm_wday != 1 || tm.tm_yday != 42) {
    puts("unexpected tm content");
    result = 1;
  }
  if (strptime("8", "%d", &tm) == NULL) {
    puts("strptime failed");
    result = 1;
  }
  if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16 ||
      tm.tm_mday != 8 || tm.tm_mon != 1 || tm.tm_year != 107 ||
      tm.tm_wday != 4 || tm.tm_yday != 38) {
    puts("unexpected tm content");
    result = 1;
  }
  if (result == 0)
    puts("all OK");
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0xaa,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    0xea7(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
je     1218 <do_test+0xe8>
lea    0xe8e(%rip),%rdi
lea    0xe8a(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
je     1218 <do_test+0xe8>
lea    0xe73(%rip),%rdi
lea    0xe70(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
je     1218 <do_test+0xe8>
lea    0xe59(%rip),%rdi
lea    0xe55(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
je     1218 <do_test+0xe8>
lea    0xe3e(%rip),%rdi
lea    0xe3a(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
je     1218 <do_test+0xe8>
lea    0xe23(%rip),%rdi
lea    0xe1f(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
jne    122b <do_test+0xfb>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0x15,-0x28(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0xd,-0x24(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0x10,-0x20(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0xc,-0x1c(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0x1,-0x18(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0x6b,-0x14(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0x1,-0x10(%rbp)
jne    127b <do_test+0x14b>
cmpl   $0x2a,-0xc(%rbp)
je     128e <do_test+0x15e>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
lea    0xdb9(%rip),%rdi
lea    0xd6f(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%rax
jne    12c2 <do_test+0x192>
lea    0xd9a(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0x15,-0x28(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0xd,-0x24(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0x10,-0x20(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0x8,-0x1c(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0x1,-0x18(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0x6b,-0x14(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0x4,-0x10(%rbp)
jne    1312 <do_test+0x1e2>
cmpl   $0x26,-0xc(%rbp)
je     1325 <do_test+0x1f5>
lea    0xd1f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    133b <do_test+0x20b>
lea    0xd2a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbx
sub    $0x20,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xaa,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    0xeef(%rip),%rdi
lea    0xeed(%rip),%rsi
mov    %rbx,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
je     11f2 <do_test+0xc2>
lea    0xed8(%rip),%rdi
lea    0xed4(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
je     11f2 <do_test+0xc2>
lea    0xec3(%rip),%rdi
lea    0xec0(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
je     11f2 <do_test+0xc2>
lea    0xeaf(%rip),%rdi
lea    0xeab(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
je     11f2 <do_test+0xc2>
lea    0xe9a(%rip),%rdi
lea    0xe96(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
je     11f2 <do_test+0xc2>
lea    0xe85(%rip),%rdi
lea    0xe81(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strptime@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    1203 <do_test+0xd3>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
movdqa (%rsp),%xmm0
movdqa 0x10(%rsp),%xmm1
pcmpeqd 0xdea(%rip),%xmm1
pcmpeqd %xmm2,%xmm2
pxor   %xmm2,%xmm1
pcmpeqd 0xdea(%rip),%xmm0
pxor   %xmm2,%xmm0
packssdw %xmm1,%xmm0
pmovmskb %xmm0,%eax
test   %eax,%eax
je     1247 <do_test+0x117>
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xe40(%rip),%rdi
lea    0xdf6(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
jne    1273 <do_test+0x143>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
movdqa (%rsp),%xmm0
movdqa 0x10(%rsp),%xmm1
pcmpeqd 0xd9a(%rip),%xmm1
pcmpeqd %xmm2,%xmm2
pxor   %xmm2,%xmm1
pcmpeqd 0xd9a(%rip),%xmm0
pxor   %xmm2,%xmm0
packssdw %xmm1,%xmm0
pmovmskb %xmm0,%eax
test   %eax,%eax
je     12b4 <do_test+0x184>
lea    0xdcb(%rip),%rdi
call   1030 <puts@plt>
jmp    12b8 <do_test+0x188>
test   %ebx,%ebx
je     12c0 <do_test+0x190>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xdd9(%rip),%rdi
jmp    12ad <do_test+0x17d>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"2007\00"
@.str.1 = [3 x i8] c"%Y\00"
@.str.2 = [3 x i8] c"12\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"Feb\00"
@.str.5 = [3 x i8] c"%b\00"
@.str.6 = [3 x i8] c"13\00"
@.str.7 = [3 x i8] c"%M\00"
@.str.8 = [3 x i8] c"21\00"
@.str.9 = [3 x i8] c"%S\00"
@.str.10 = [3 x i8] c"16\00"
@.str.11 = [3 x i8] c"%H\00"
@.str.12 = [17 x i8] c"strptimes failed\00"
@.str.13 = [22 x i8] c"unexpected tm content\00"
@.str.14 = [2 x i8] c"8\00"
@.str.15 = [16 x i8] c"strptime failed\00"
@.str.16 = [7 x i8] c"all OK\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca %struct.tm
store i32 0, i32* %1
%3 = call i32 @memset(%struct.tm* %2, i32 170, i32 32)
%4 = call i32* @strptime(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %2)
%5 = icmp eq i32* %4, null
br i1 %5, label %21, label %6
6: ; preds = %0
%7 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %2)
%8 = icmp eq i32* %7, null
br i1 %8, label %21, label %9
9: ; preds = %6
%10 = call i32* @strptime(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %2)
%11 = icmp eq i32* %10, null
br i1 %11, label %21, label %12
12: ; preds = %9
%13 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %2)
%14 = icmp eq i32* %13, null
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %2)
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), %struct.tm* %2)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18, %15, %12, %9, %6, %0
%22 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %1
br label %23
23: ; preds = %21, %18
%24 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 0
%25 = load i32, i32* %24
%26 = icmp ne i32 %25, 21
br i1 %26, label %55, label %27
27: ; preds = %23
%28 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 1
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, 13
br i1 %30, label %55, label %31
31: ; preds = %27
%32 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 2
%33 = load i32, i32* %32
%34 = icmp ne i32 %33, 16
br i1 %34, label %55, label %35
35: ; preds = %31
%36 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 3
%37 = load i32, i32* %36
%38 = icmp ne i32 %37, 12
br i1 %38, label %55, label %39
39: ; preds = %35
%40 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 4
%41 = load i32, i32* %40
%42 = icmp ne i32 %41, 1
br i1 %42, label %55, label %43
43: ; preds = %39
%44 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 5
%45 = load i32, i32* %44
%46 = icmp ne i32 %45, 107
br i1 %46, label %55, label %47
47: ; preds = %43
%48 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 6
%49 = load i32, i32* %48
%50 = icmp ne i32 %49, 1
br i1 %50, label %55, label %51
51: ; preds = %47
%52 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 7
%53 = load i32, i32* %52
%54 = icmp ne i32 %53, 42
br i1 %54, label %55, label %57
55: ; preds = %51, %47, %43, %39, %35, %31, %27, %23
%56 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %1
br label %57
57: ; preds = %55, %51
%58 = call i32* @strptime(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %2)
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %1
br label %62
62: ; preds = %60, %57
%63 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 0
%64 = load i32, i32* %63
%65 = icmp ne i32 %64, 21
br i1 %65, label %94, label %66
66: ; preds = %62
%67 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 1
%68 = load i32, i32* %67
%69 = icmp ne i32 %68, 13
br i1 %69, label %94, label %70
70: ; preds = %66
%71 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 2
%72 = load i32, i32* %71
%73 = icmp ne i32 %72, 16
br i1 %73, label %94, label %74
74: ; preds = %70
%75 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 3
%76 = load i32, i32* %75
%77 = icmp ne i32 %76, 8
br i1 %77, label %94, label %78
78: ; preds = %74
%79 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 4
%80 = load i32, i32* %79
%81 = icmp ne i32 %80, 1
br i1 %81, label %94, label %82
82: ; preds = %78
%83 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 5
%84 = load i32, i32* %83
%85 = icmp ne i32 %84, 107
br i1 %85, label %94, label %86
86: ; preds = %82
%87 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 6
%88 = load i32, i32* %87
%89 = icmp ne i32 %88, 4
br i1 %89, label %94, label %90
90: ; preds = %86
%91 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 7
%92 = load i32, i32* %91
%93 = icmp ne i32 %92, 38
br i1 %93, label %94, label %96
94: ; preds = %90, %86, %82, %78, %74, %70, %66, %62
%95 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %1
br label %96
96: ; preds = %94, %90
%97 = load i32, i32* %1
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
br label %101
101: ; preds = %99, %96
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"2007\00"
@.str.1 = [3 x i8] c"%Y\00"
@.str.2 = [3 x i8] c"12\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"Feb\00"
@.str.5 = [3 x i8] c"%b\00"
@.str.6 = [3 x i8] c"13\00"
@.str.7 = [3 x i8] c"%M\00"
@.str.8 = [3 x i8] c"21\00"
@.str.9 = [3 x i8] c"%S\00"
@.str.10 = [3 x i8] c"16\00"
@.str.11 = [3 x i8] c"%H\00"
@.str.12 = [17 x i8] c"strptimes failed\00"
@.str.13 = [22 x i8] c"unexpected tm content\00"
@.str.14 = [2 x i8] c"8\00"
@.str.15 = [16 x i8] c"strptime failed\00"
@.str.16 = [7 x i8] c"all OK\00"
define i32 @do_test() {
%1 = alloca <8 x i32>
%2 = bitcast <8 x i32>* %1 to %struct.tm*
%3 = bitcast <8 x i32>* %1 to i8*
%4 = call i32 @memset(%struct.tm* %2, i32 170, i32 32)
%5 = call i32* @strptime(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %2)
%6 = icmp eq i32* %5, null
br i1 %6, label %22, label %7
7: ; preds = %0
%8 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %2)
%9 = icmp eq i32* %8, null
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = call i32* @strptime(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %2)
%12 = icmp eq i32* %11, null
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %2)
%15 = icmp eq i32* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %2)
%18 = icmp eq i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = call i32* @strptime(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), %struct.tm* %2)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19, %16, %13, %10, %7, %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = phi i32 [ 1, %22 ], [ 0, %19 ]
%26 = load <8 x i32>, <8 x i32>* %1
%27 = freeze <8 x i32> %26
%28 = icmp ne <8 x i32> %27, <i32 21, i32 13, i32 16, i32 12, i32 1, i32 107, i32 1, i32 42>
%29 = bitcast <8 x i1> %28 to i8
%30 = icmp eq i8 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %24
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
br label %33
33: ; preds = %24, %31
%34 = phi i32 [ 1, %31 ], [ %25, %24 ]
%35 = call i32* @strptime(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %2)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
%40 = phi i32 [ 1, %37 ], [ %34, %33 ]
%41 = load <8 x i32>, <8 x i32>* %1
%42 = freeze <8 x i32> %41
%43 = icmp ne <8 x i32> %42, <i32 21, i32 13, i32 16, i32 8, i32 1, i32 107, i32 4, i32 38>
%44 = bitcast <8 x i1> %43 to i8
%45 = icmp eq i8 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = icmp eq i32 %40, 0
br i1 %47, label %48, label %51
48: ; preds = %46, %39
%49 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), %39 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), %46 ]
%50 = call i32 @puts(i8* dereferenceable(1) %49)
br label %51
51: ; preds = %48, %46
ret i32 0
}