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

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *strptime(char const *, char const *, struct tm *);
int _strptime(char const *progname) {
  char const buf[] = "1970/01/01 00:00:00";
  char const format[] = "%Y/%m/%d %H:%M:%S";
  struct tm tm;
  printf("%s: Testing strptime()\n", progname);
  if (strptime(buf, format, &tm) == NULL) {
    perror("strptime");
    return -1;
  }
  if (tm.tm_year != 0 || tm.tm_mon != 0 || tm.tm_mday != 1 || tm.tm_hour != 0 ||
      tm.tm_min != 0 || tm.tm_sec != 0) {
    fputs("strptime: Invalid conversion\n", stderr);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_strptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xea5(%rip),%ax
mov    %ax,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1060 <strptime@plt>
cmp    $0x0,%rax
jne    11d2 <_strptime+0x92>
lea    0xe89(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <_strptime+0xfb>
cmpq   $0x0,-0x80(%rbp)
jne    1213 <_strptime+0xd3>
cmpq   $0x0,-0x78(%rbp)
jne    1213 <_strptime+0xd3>
cmpl   $0x1,-0x70(%rbp)
jne    1213 <_strptime+0xd3>
cmpq   $0x0,-0x68(%rbp)
jne    1213 <_strptime+0xd3>
cmpq   $0x0,-0x60(%rbp)
jne    1213 <_strptime+0xd3>
cmpq   $0x0,-0x58(%rbp)
je     1234 <_strptime+0xf4>
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
lea    0xe30(%rip),%rdi
call   1040 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <_strptime+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_strptime>:
sub    $0x68,%rsp
mov    %rdi,%rsi
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x30303a,0x30(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x53,0x10(%rsp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
lea    0x38(%rsp),%rdx
call   1060 <strptime@plt>
test   %rax,%rax
je     11e5 <_strptime+0xa5>
cmpq   $0x0,0x38(%rsp)
jne    11c6 <_strptime+0x86>
cmpq   $0x0,0x40(%rsp)
jne    11c6 <_strptime+0x86>
cmpl   $0x1,0x48(%rsp)
jne    11c6 <_strptime+0x86>
cmpq   $0x0,0x50(%rsp)
jne    11c6 <_strptime+0x86>
cmpq   $0x0,0x58(%rsp)
jne    11c6 <_strptime+0x86>
xor    %eax,%eax
cmpq   $0x0,0x60(%rsp)
jne    11c6 <_strptime+0x86>
add    $0x68,%rsp
ret
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
lea    0xe7d(%rip),%rdi
call   1040 <fputs@plt>
mov    $0xffffffff,%eax
add    $0x68,%rsp
ret
lea    0xe5e(%rip),%rdi
call   1050 <perror@plt>
jmp    11db <_strptime+0x9b>

LLVM IR (-O0):
%struct.tm = type { i64, i64, i32, i64, i64, i64 }
@__const._strptime.buf = [20 x i8] c"1970/01/01 00:00:00\00"
@__const._strptime.format = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@.str = [24 x i8] c"%s: Testing strptime()\0A\00"
@.str.1 = [9 x i8] c"strptime\00"
@.str.2 = [30 x i8] c"strptime: Invalid conversion\0A\00"
@stderr = global i32 0
define i32 @_strptime(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [20 x i8]
%5 = alloca [18 x i8]
%6 = alloca %struct.tm
store i8* %0, i8** %3
%7 = bitcast [20 x i8]* %4 to i8*
%8 = bitcast [18 x i8]* %5 to i8*
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 0
%13 = call i32* @strptime(i8* %11, i8* %12, %struct.tm* %6)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %45
17: ; preds = %1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%19 = load i64, i64* %18
%20 = icmp ne i64 %19, 0
br i1 %20, label %41, label %21
21: ; preds = %17
%22 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 1
%23 = load i64, i64* %22
%24 = icmp ne i64 %23, 0
br i1 %24, label %41, label %25
25: ; preds = %21
%26 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 2
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, 1
br i1 %28, label %41, label %29
29: ; preds = %25
%30 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 3
%31 = load i64, i64* %30
%32 = icmp ne i64 %31, 0
br i1 %32, label %41, label %33
33: ; preds = %29
%34 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 4
%35 = load i64, i64* %34
%36 = icmp ne i64 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %33
%38 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 5
%39 = load i64, i64* %38
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37, %33, %29, %25, %21, %17
%42 = load i32, i32* @stderr
%43 = call i32 @fputs(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %42)
store i32 -1, i32* %2
br label %45
44: ; preds = %37
store i32 0, i32* %2
br label %45
45: ; preds = %44, %41, %15
%46 = load i32, i32* %2
ret i32 %46
}

LLVM IR (-O2):
%struct.tm = type { i64, i64, i32, i64, i64, i64 }
@__const._strptime.buf = [20 x i8] c"1970/01/01 00:00:00\00"
@__const._strptime.format = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@.str = [24 x i8] c"%s: Testing strptime()\0A\00"
@.str.1 = [9 x i8] c"strptime\00"
@.str.2 = [30 x i8] c"strptime: Invalid conversion\0A\00"
@stderr = global i32 0
define i32 @_strptime(i8* %0) {
%2 = alloca [20 x i8]
%3 = alloca [18 x i8]
%4 = alloca %struct.tm
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.tm* %4 to i8*
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32* @strptime(i8* %5, i8* %6, %struct.tm* %4)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %40
13: ; preds = %1
%14 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%15 = load i64, i64* %14
%16 = icmp ne i64 %15, 0
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%18 = load i64, i64* %17
%19 = icmp ne i64 %18, 0
%20 = select i1 %16, i1 true, i1 %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, 1
%24 = select i1 %20, i1 true, i1 %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%26 = load i64, i64* %25
%27 = icmp ne i64 %26, 0
%28 = select i1 %24, i1 true, i1 %27
%29 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%30 = load i64, i64* %29
%31 = icmp ne i64 %30, 0
%32 = select i1 %28, i1 true, i1 %31
%33 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%34 = load i64, i64* %33
%35 = icmp ne i64 %34, 0
%36 = select i1 %32, i1 true, i1 %35
br i1 %36, label %37, label %40
37: ; preds = %13
%38 = load i32, i32* @stderr
%39 = call i32 @fputs(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %13, %37, %11
%41 = phi i32 [ -1, %11 ], [ -1, %37 ], [ 0, %13 ]
ret i32 %41
}