#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_isdst;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ mktime(struct tm *);
int sscanf(char const *, char *, int *, char *, int /*<<< orphan*/ *, char *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *);
time_t jpeg_time(const char *d) {
  struct tm tm = {0};
  char dummy;
  if (sscanf(d, "%d%c%d%c%d %d:%d:%d", &tm.tm_year, &dummy, &tm.tm_mon, &dummy,
             &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 8)
    return 0;
  tm.tm_year -= 1900;
  tm.tm_isdst = -1;
  return mktime(&tm);
}


x86 assembly (clang, -O0):
<jpeg_time>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    %rdi,-0x18(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    -0x38(%rbp),%rdx
lea    -0x38(%rbp),%r8
add    $0x18,%r8
lea    -0x38(%rbp),%rbx
add    $0x14,%rbx
lea    -0x38(%rbp),%r11
add    $0x10,%r11
lea    -0x38(%rbp),%r10
add    $0xc,%r10
lea    -0x38(%rbp),%rax
add    $0x8,%rax
lea    0xe7c(%rip),%rsi
lea    -0x39(%rbp),%r9
mov    %r9,%rcx
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1040 <sscanf@plt>
cmp    $0x8,%eax
je     11b8 <jpeg_time+0x88>
movl   $0x0,-0xc(%rbp)
jmp    11d6 <jpeg_time+0xa6>
mov    -0x38(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x38(%rbp)
movl   $0xffffffff,-0x34(%rbp)
lea    -0x38(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<jpeg_time>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x20(%rsp),%r11
lea    0x28(%rsp),%r8
lea    0x24(%rsp),%r10
lea    0x1c(%rsp),%rax
lea    0x18(%rsp),%rbx
lea    0xeae(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xf(%rsp),%rcx
mov    %rcx,%r9
push   %rbx
push   %rax
push   %r11
push   %r10
call   1030 <sscanf@plt>
add    $0x20,%rsp
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x8,%ecx
jne    1191 <jpeg_time+0x71>
addl   $0xfffff894,0x10(%rsp)
ff
movl   $0xffffffff,0x14(%rsp)
ff
lea    0x10(%rsp),%rdi
call   1040 <mktime@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [20 x i8] c"%d%c%d%c%d %d:%d:%d\00"
define i32 @jpeg_time(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.tm
%5 = alloca i8
store i8* %0, i8** %3
%6 = bitcast %struct.tm* %4 to i8*
%7 = load i8*, i8** %3
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 6
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 5
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 4
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 3
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
%14 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %8, i8* %5, i32* %9, i8* %5, i32* %10, i32* %11, i32* %12, i32* %13)
%15 = icmp ne i32 %14, 8
br i1 %15, label %16, label %17
16: ; preds = %1
store i32 0, i32* %2
br label %23
17: ; preds = %1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%19 = load i32, i32* %18
%20 = sub nsw i32 %19, 1900
store i32 %20, i32* %18
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i32 -1, i32* %21
%22 = call i32 @mktime(%struct.tm* %4)
store i32 %22, i32* %2
br label %23
23: ; preds = %17, %16
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [20 x i8] c"%d%c%d%c%d %d:%d:%d\00"
define i32 @jpeg_time(i8* nocapture %0) {
%2 = alloca %struct.tm
%3 = alloca i8
%4 = bitcast %struct.tm* %2 to i8*
%5 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%6 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 6
%7 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 5
%8 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
%10 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
%11 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %5, i8* %3, i32* %6, i8* %3, i32* %7, i32* %8, i32* %9, i32* %10)
%12 = icmp eq i32 %11, 8
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load i32, i32* %5
%15 = add nsw i32 %14, -1900
store i32 %15, i32* %5
%16 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
store i32 -1, i32* %16
%17 = call i32 @mktime(%struct.tm* %2)
br label %18
18: ; preds = %1, %13
%19 = phi i32 [ %17, %13 ], [ 0, %1 ]
ret i32 %19
}