#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 {
  char tm_year;
  int tm_mon;
  char tm_mday;
  char tm_hour;
  char tm_min;
  char tm_sec;
  char tm_yday;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int iso9660_date(char *result, time_t ctime) {
  struct tm *local;
  local = localtime(&ctime);
  result[0] = local->tm_year;
  result[1] = local->tm_mon + 1;
  result[2] = local->tm_mday;
  result[3] = local->tm_hour;
  result[4] = local->tm_min;
  result[5] = local->tm_sec;
  result[6] = local->tm_yday;
  local = gmtime(&ctime);
  local->tm_year -= result[0];
  local->tm_yday -= result[6];
  local->tm_hour -= result[3];
  local->tm_min -= result[4];
  if (local->tm_year < 0) {
    local->tm_yday = -1;
  } else {
    if (local->tm_year > 0)
      local->tm_yday = 1;
  }
  result[6] =
      -(local->tm_min + 60 * (local->tm_hour + 24 * local->tm_yday)) / 15;
  return 0;
}


x86 assembly (clang, -O0):
<iso9660_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x1,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
mov    0x9(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
mov    0xa(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0xb(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
lea    -0xc(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
sub    %edx,%ecx
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%edx
mov    -0x18(%rbp),%rax
movsbl 0xc(%rax),%ecx
sub    %edx,%ecx
mov    %cl,0xc(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edx
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%ecx
sub    %edx,%ecx
mov    %cl,0x9(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%edx
mov    -0x18(%rbp),%rax
movsbl 0xa(%rax),%ecx
sub    %edx,%ecx
mov    %cl,0xa(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jge    121c <iso9660_date+0xfc>
mov    -0x18(%rbp),%rax
movb   $0xff,0xc(%rax)
jmp    1239 <iso9660_date+0x119>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jle    1234 <iso9660_date+0x114>
mov    -0x18(%rbp),%rax
movb   $0x1,0xc(%rax)
jmp    1239 <iso9660_date+0x119>
mov    -0x18(%rbp),%rax
movsbl 0xa(%rax),%ecx
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%eax
mov    -0x18(%rbp),%rdx
movsbl 0xc(%rdx),%edx
imul   $0x18,%edx,%edx
add    %edx,%eax
imul   $0x3c,%eax,%eax
add    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iso9660_date>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %esi,0x4(%rsp)
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    (%rax),%cl
mov    %cl,(%rbx)
mov    0x4(%rax),%cl
add    $0x1,%cl
mov    %cl,0x1(%rbx)
mov    0x8(%rax),%cl
mov    %cl,0x2(%rbx)
mov    0x9(%rax),%cl
mov    %cl,0x3(%rbx)
mov    0xa(%rax),%cl
mov    %cl,0x4(%rbx)
mov    0xb(%rax),%cl
mov    %cl,0x5(%rbx)
mov    0xc(%rax),%al
mov    %al,0x6(%rbx)
mov    %r14,%rdi
call   1040 <gmtime@plt>
mov    (%rax),%dil
mov    0x9(%rax),%sil
mov    (%rbx),%r8b
mov    %edi,%ecx
sub    %r8b,%cl
mov    %cl,(%rax)
mov    0xc(%rax),%dl
sub    0x6(%rbx),%dl
mov    %dl,0xc(%rax)
sub    0x3(%rbx),%sil
mov    %sil,0x9(%rax)
mov    0xa(%rax),%cl
sub    0x4(%rbx),%cl
sub    %r8b,%dil
mov    %cl,0xa(%rax)
js     11a2 <iso9660_date+0x82>
mov    $0x1,%dil
jne    11a5 <iso9660_date+0x85>
jmp    11ab <iso9660_date+0x8b>
mov    $0xff,%dil
mov    %dil,0xc(%rax)
mov    %edi,%edx
movsbl %cl,%eax
movsbl %sil,%ecx
movsbl %dl,%edx
lea    (%rdx,%rdx,2),%edx
lea    (%rcx,%rdx,8),%ecx
imul   $0xffffffc4,%ecx,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
shr    $0x3,%eax
add    %ecx,%eax
mov    %al,0x6(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i8, i32, i8, i8, i8, i8, i8 }
define i32 @iso9660_date(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.tm*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %6, %struct.tm** %5
%7 = load %struct.tm*, %struct.tm** %5
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%9 = load i8, i8* %8
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 %9, i8* %11
%12 = load %struct.tm*, %struct.tm** %5
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8 %16, i8* %18
%19 = load %struct.tm*, %struct.tm** %5
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 2
%21 = load i8, i8* %20
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8 %21, i8* %23
%24 = load %struct.tm*, %struct.tm** %5
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 3
%26 = load i8, i8* %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 3
store i8 %26, i8* %28
%29 = load %struct.tm*, %struct.tm** %5
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 4
%31 = load i8, i8* %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 4
store i8 %31, i8* %33
%34 = load %struct.tm*, %struct.tm** %5
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 5
%36 = load i8, i8* %35
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 5
store i8 %36, i8* %38
%39 = load %struct.tm*, %struct.tm** %5
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 6
%41 = load i8, i8* %40
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 6
store i8 %41, i8* %43
%44 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %44, %struct.tm** %5
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = load %struct.tm*, %struct.tm** %5
%50 = getelementptr inbounds %struct.tm, %struct.tm* %49, i32 0, i32 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = sub nsw i32 %52, %48
%54 = trunc i32 %53 to i8
store i8 %54, i8* %50
%55 = load i8*, i8** %3
%56 = getelementptr inbounds i8, i8* %55, i64 6
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = load %struct.tm*, %struct.tm** %5
%60 = getelementptr inbounds %struct.tm, %struct.tm* %59, i32 0, i32 6
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = sub nsw i32 %62, %58
%64 = trunc i32 %63 to i8
store i8 %64, i8* %60
%65 = load i8*, i8** %3
%66 = getelementptr inbounds i8, i8* %65, i64 3
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = load %struct.tm*, %struct.tm** %5
%70 = getelementptr inbounds %struct.tm, %struct.tm* %69, i32 0, i32 3
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = sub nsw i32 %72, %68
%74 = trunc i32 %73 to i8
store i8 %74, i8* %70
%75 = load i8*, i8** %3
%76 = getelementptr inbounds i8, i8* %75, i64 4
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = load %struct.tm*, %struct.tm** %5
%80 = getelementptr inbounds %struct.tm, %struct.tm* %79, i32 0, i32 4
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = sub nsw i32 %82, %78
%84 = trunc i32 %83 to i8
store i8 %84, i8* %80
%85 = load %struct.tm*, %struct.tm** %5
%86 = getelementptr inbounds %struct.tm, %struct.tm* %85, i32 0, i32 0
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %2
%91 = load %struct.tm*, %struct.tm** %5
%92 = getelementptr inbounds %struct.tm, %struct.tm* %91, i32 0, i32 6
store i8 -1, i8* %92
br label %103
93: ; preds = %2
%94 = load %struct.tm*, %struct.tm** %5
%95 = getelementptr inbounds %struct.tm, %struct.tm* %94, i32 0, i32 0
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %93
%100 = load %struct.tm*, %struct.tm** %5
%101 = getelementptr inbounds %struct.tm, %struct.tm* %100, i32 0, i32 6
store i8 1, i8* %101
br label %102
102: ; preds = %99, %93
br label %103
103: ; preds = %102, %90
%104 = load %struct.tm*, %struct.tm** %5
%105 = getelementptr inbounds %struct.tm, %struct.tm* %104, i32 0, i32 4
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = load %struct.tm*, %struct.tm** %5
%109 = getelementptr inbounds %struct.tm, %struct.tm* %108, i32 0, i32 3
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = load %struct.tm*, %struct.tm** %5
%113 = getelementptr inbounds %struct.tm, %struct.tm* %112, i32 0, i32 6
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = mul nsw i32 24, %115
%117 = add nsw i32 %111, %116
%118 = mul nsw i32 60, %117
%119 = add nsw i32 %107, %118
%120 = sub nsw i32 0, %119
%121 = sdiv i32 %120, 15
%122 = trunc i32 %121 to i8
%123 = load i8*, i8** %3
%124 = getelementptr inbounds i8, i8* %123, i64 6
store i8 %122, i8* %124
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i8, i32, i8, i8, i8, i8, i8 }
define i32 @iso9660_date(i8* nocapture %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = call %struct.tm* @localtime(i32* %3)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i8, i8* %5
store i8 %6, i8* %0
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%8 = load i32, i32* %7
%9 = trunc i32 %8 to i8
%10 = add i8 %9, 1
%11 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %10, i8* %11
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %13, i8* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %16, i8* %17
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %19, i8* %20
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%22 = load i8, i8* %21
%23 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %22, i8* %23
%24 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 6
%25 = load i8, i8* %24
%26 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %25, i8* %26
%27 = call %struct.tm* @gmtime(i32* %3)
%28 = load i8, i8* %0
%29 = getelementptr inbounds %struct.tm, %struct.tm* %27, i64 0, i32 0
%30 = load i8, i8* %29
%31 = sub i8 %30, %28
store i8 %31, i8* %29
%32 = load i8, i8* %26
%33 = getelementptr inbounds %struct.tm, %struct.tm* %27, i64 0, i32 6
%34 = load i8, i8* %33
%35 = sub i8 %34, %32
store i8 %35, i8* %33
%36 = load i8, i8* %17
%37 = getelementptr inbounds %struct.tm, %struct.tm* %27, i64 0, i32 3
%38 = load i8, i8* %37
%39 = sub i8 %38, %36
store i8 %39, i8* %37
%40 = load i8, i8* %20
%41 = getelementptr inbounds %struct.tm, %struct.tm* %27, i64 0, i32 4
%42 = load i8, i8* %41
%43 = sub i8 %42, %40
store i8 %43, i8* %41
%44 = icmp slt i8 %31, 0
br i1 %44, label %47, label %45
45: ; preds = %2
%46 = icmp eq i8 %31, 0
br i1 %46, label %49, label %47
47: ; preds = %45, %2
%48 = phi i8 [ -1, %2 ], [ 1, %45 ]
store i8 %48, i8* %33
br label %49
49: ; preds = %47, %45
%50 = phi i8 [ %35, %45 ], [ %48, %47 ]
%51 = sext i8 %43 to i32
%52 = sext i8 %39 to i32
%53 = sext i8 %50 to i32
%54 = mul nsw i32 %53, 24
%55 = add nsw i32 %54, %52
%56 = mul nsw i32 %55, -60
%57 = sub nsw i32 %56, %51
%58 = sdiv i32 %57, 15
%59 = trunc i32 %58 to i8
store i8 %59, i8* %26
ret i32 0
}