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

/* Variables and functions */
int /*<<< orphan*/ mktime(struct tm *);
int strlen(char *);
int strtol(char *, char **, int);
time_t get_revs_date(char *mirror) {
  int i = 0;
  int factors[8];
  char *current = mirror + strlen("mirror_metadata.");
  char *next = 0;
  struct tm rev_time;
  if (mirror[35] == 'Z')
    for (i = 0; i < 6; i++) {
      factors[i] = strtol(current, &next, 10);
      current = next + 1;
    }
  else
    for (i = 0; i < 8; i++) {
      factors[i] = strtol(current, &next, 10);
      current = next + 1;
    };
  rev_time.tm_year = factors[0] - 1900;
  rev_time.tm_mon = factors[1] - 1;
  rev_time.tm_mday = factors[2];
  rev_time.tm_hour = factors[3];
  rev_time.tm_min = factors[4];
  rev_time.tm_sec = factors[5];
  rev_time.tm_isdst = -1;
  return mktime(&rev_time);
}


x86 assembly (clang, -O0):
<get_revs_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    0xeae(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x23(%rax),%eax
cmp    $0x5a,%eax
jne    11cc <get_revs_date+0x9c>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    11c7 <get_revs_date+0x97>
mov    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1187 <get_revs_date+0x57>
jmp    1218 <get_revs_date+0xe8>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1213 <get_revs_date+0xe3>
mov    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d3 <get_revs_date+0xa3>
jmp    1218 <get_revs_date+0xe8>
mov    -0x30(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0xffffffff,-0x48(%rbp)
lea    -0x60(%rbp),%rdi
call   1050 <mktime@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_revs_date>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
lea    0xeb8(%rip),%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
movq   $0x0,0x8(%rsp)
mov    0x23(%rbx),%r14b
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%r12d
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%r13d
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ebx
cmp    $0x5a,%r14b
je     1228 <get_revs_date+0xf8>
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
add    $0xfffff894,%r12d
mov    %r12d,0x18(%rsp)
add    $0xffffffff,%ebp
mov    %ebp,0x1c(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    %r15d,0x24(%rsp)
mov    %r13d,0x28(%rsp)
mov    %ebx,0x2c(%rsp)
movl   $0xffffffff,0x30(%rsp)
ff
lea    0x18(%rsp),%rdi
call   1050 <mktime@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [17 x i8] c"mirror_metadata.\00"
define i32 @get_revs_date(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.tm
store i8* %0, i8** %2
store i32 0, i32* %3
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
store i8* %11, i8** %5
store i8* null, i8** %6
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 35
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 90
br i1 %16, label %17, label %33
17: ; preds = %1
store i32 0, i32* %3
br label %18
18: ; preds = %29, %17
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 6
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = call i32 @strtol(i8* %22, i8** %6, i32 10)
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %25
store i32 %23, i32* %26
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %5
br label %29
29: ; preds = %21
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %18
32: ; preds = %18
br label %49
33: ; preds = %1
store i32 0, i32* %3
br label %34
34: ; preds = %45, %33
%35 = load i32, i32* %3
%36 = icmp slt i32 %35, 8
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = load i8*, i8** %5
%39 = call i32 @strtol(i8* %38, i8** %6, i32 10)
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %41
store i32 %39, i32* %42
%43 = load i8*, i8** %6
%44 = getelementptr inbounds i8, i8* %43, i64 1
store i8* %44, i8** %5
br label %45
45: ; preds = %37
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %34
48: ; preds = %34
br label %49
49: ; preds = %48, %32
%50 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%51 = load i32, i32* %50
%52 = sub nsw i32 %51, 1900
%53 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
store i32 %52, i32* %53
%54 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 1
%55 = load i32, i32* %54
%56 = sub nsw i32 %55, 1
%57 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 1
store i32 %56, i32* %57
%58 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 2
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 2
store i32 %59, i32* %60
%61 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 3
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 3
store i32 %62, i32* %63
%64 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 4
%65 = load i32, i32* %64
%66 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 4
store i32 %65, i32* %66
%67 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 5
%68 = load i32, i32* %67
%69 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 5
store i32 %68, i32* %69
%70 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 6
store i32 -1, i32* %70
%71 = call i32 @mktime(%struct.tm* %7)
ret i32 %71
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [17 x i8] c"mirror_metadata.\00"
define i32 @get_revs_date(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%8 = bitcast %struct.tm* %3 to i8*
%9 = getelementptr inbounds i8, i8* %0, i64 35
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 90
%12 = call i32 @strtol(i8* %6, i8** %2, i32 10)
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = call i32 @strtol(i8* %14, i8** %2, i32 10)
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i32 @strtol(i8* %17, i8** %2, i32 10)
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i32 @strtol(i8* %20, i8** %2, i32 10)
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = call i32 @strtol(i8* %23, i8** %2, i32 10)
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i32 @strtol(i8* %26, i8** %2, i32 10)
br i1 %11, label %35, label %28
28: ; preds = %1
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i32 @strtol(i8* %30, i8** %2, i32 10)
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i32 @strtol(i8* %33, i8** %2, i32 10)
br label %35
35: ; preds = %1, %28
%36 = add nsw i32 %12, -1900
%37 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 %36, i32* %37
%38 = add nsw i32 %15, -1
%39 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
store i32 %38, i32* %39
%40 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
store i32 %18, i32* %40
%41 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
store i32 %21, i32* %41
%42 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
store i32 %24, i32* %42
%43 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
store i32 %27, i32* %43
%44 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 6
store i32 -1, i32* %44
%45 = call i32 @mktime(%struct.tm* %3)
ret i32 %45
}