#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 scalar_t__ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
char *getenv(char *);
scalar_t__ mktime(struct tm *);
int /*<<< orphan*/ strptime(char *, char *, struct tm *);
int mod_time_check(time_t mod) {
  struct tm tm;
  char *a;
  if (!(a = getenv("IF_MODIFIED_SINCE")))
    return 0;
  if (!strptime(a, "%a,%n%d%n%b%n%Y%n%H:%M:%S%n%Z", &tm))
    return 0;
  if (mod > mktime(&tm))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<mod_time_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1162 <mod_time_check+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11bf <mod_time_check+0x8f>
mov    -0x20(%rbp),%rdi
lea    0xea5(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <strptime@plt>
cmp    $0x0,%eax
jne    118b <mod_time_check+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11bf <mod_time_check+0x8f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <mktime@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jle    11b8 <mod_time_check+0x88>
movl   $0x0,-0x4(%rbp)
jmp    11bf <mod_time_check+0x8f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_time_check>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1170 <mod_time_check+0x40>
lea    0xec2(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1050 <strptime@plt>
test   %eax,%eax
je     1170 <mod_time_check+0x40>
mov    %rsp,%rdi
call   1040 <mktime@plt>
xor    %ebp,%ebp
cmp    %rbx,%rax
setge  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"IF_MODIFIED_SINCE\00"
@.str.1 = [30 x i8] c"%a,%n%d%n%b%n%Y%n%H:%M:%S%n%Z\00"
define i32 @mod_time_check(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca %struct.tm
%5 = alloca i8*
store i64 %0, i64* %3
%6 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %20
9: ; preds = %1
%10 = load i8*, i8** %5
%11 = call i32 @strptime(i8* %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %4)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 0, i32* %2
br label %20
14: ; preds = %9
%15 = load i64, i64* %3
%16 = call i64 @mktime(%struct.tm* %4)
%17 = icmp sgt i64 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 0, i32* %2
br label %20
19: ; preds = %14
store i32 1, i32* %2
br label %20
20: ; preds = %19, %18, %13, %8
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"IF_MODIFIED_SINCE\00"
@.str.1 = [30 x i8] c"%a,%n%d%n%b%n%Y%n%H:%M:%S%n%Z\00"
define i32 @mod_time_check(i64 %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %1
%7 = call i32 @strptime(i8* %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = call i64 @mktime(%struct.tm* %2)
%11 = icmp sge i64 %10, %0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %9, %6, %1
%14 = phi i32 [ 0, %1 ], [ 0, %6 ], [ %12, %9 ]
ret i32 %14
}