#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 dummy;
};
struct ar_hdr {
  char *ar_date;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int);
struct tm *_ar_get_date(struct ar_hdr *ar) {
  struct tm *ret;
  char buf[sizeof(ar->ar_date) + 1];
  time_t date;
  if (ar->ar_date[0] == '\0')
    return NULL;
  memcpy(buf, ar->ar_date, sizeof(ar->ar_date));
  buf[sizeof(buf) - 1] = '\0';
  date = strtol(buf, NULL, 10);
  if ((ret = gmtime(&date)) == NULL)
    return NULL;
  return ret;
}


x86 assembly (clang, -O0):
<_ar_get_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115c <_ar_get_date+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <_ar_get_date+0x86>
lea    -0x21(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
movb   $0x0,-0x19(%rbp)
lea    -0x21(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ae <_ar_get_date+0x7e>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <_ar_get_date+0x86>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ar_get_date>:
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%rsi
cmpb   $0x0,(%rsi)
je     1170 <_ar_get_date+0x40>
lea    0x7(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
movb   $0x0,0xf(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,(%rsp)
mov    %rsp,%rdi
call   1050 <gmtime@plt>
jmp    1172 <_ar_get_date+0x42>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.ar_hdr = type { i8* }
define %struct.tm* @_ar_get_date(%struct.ar_hdr* %0) {
%2 = alloca %struct.tm*
%3 = alloca %struct.ar_hdr*
%4 = alloca %struct.tm*
%5 = alloca [9 x i8]
%6 = alloca i32
store %struct.ar_hdr* %0, %struct.ar_hdr** %3
%7 = load %struct.ar_hdr*, %struct.ar_hdr** %3
%8 = getelementptr inbounds %struct.ar_hdr, %struct.ar_hdr* %7, i32 0, i32 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store %struct.tm* null, %struct.tm** %2
br label %29
15: ; preds = %1
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%17 = load %struct.ar_hdr*, %struct.ar_hdr** %3
%18 = getelementptr inbounds %struct.ar_hdr, %struct.ar_hdr* %17, i32 0, i32 0
%19 = load i8*, i8** %18
%20 = call i32 @memcpy(i8* %16, i8* %19, i32 8)
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 8
store i8 0, i8* %21
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%23 = call i32 @strtol(i8* %22, i32* null, i32 10)
store i32 %23, i32* %6
%24 = call %struct.tm* @gmtime(i32* %6)
store %struct.tm* %24, %struct.tm** %4
%25 = icmp eq %struct.tm* %24, null
br i1 %25, label %26, label %27
26: ; preds = %15
store %struct.tm* null, %struct.tm** %2
br label %29
27: ; preds = %15
%28 = load %struct.tm*, %struct.tm** %4
store %struct.tm* %28, %struct.tm** %2
br label %29
29: ; preds = %27, %26, %14
%30 = load %struct.tm*, %struct.tm** %2
ret %struct.tm* %30
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.ar_hdr = type { i8* }
define %struct.tm* @_ar_get_date(%struct.ar_hdr* nocapture %0) {
%2 = alloca [9 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds %struct.ar_hdr, %struct.ar_hdr* %0, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = call i32 @memcpy(i8* %4, i8* %7, i32 8)
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
store i8 0, i8* %12
%13 = call i32 @strtol(i8* nocapture %4, i32* null, i32 10)
store i32 %13, i32* %3
%14 = call %struct.tm* @gmtime(i32* %3)
br label %15
15: ; preds = %10, %1
%16 = phi %struct.tm* [ null, %1 ], [ %14, %10 ]
ret %struct.tm* %16
}