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

/* Variables and functions */
int /*<<< orphan*/ __print_lz(int, char *, char);
void isotime_r(const struct tm *tmptr, char *buffer) {
  int i;
  i = tmptr->tm_year + 1900;
  __print_lz(i / 100, buffer, '-');
  buffer += 2;
  __print_lz(i % 100, buffer, '-');
  buffer += 3;
  i = tmptr->tm_mon + 1;
  __print_lz(i, buffer, '-');
  buffer += 3;
  i = tmptr->tm_mday;
  __print_lz(i, buffer, ' ');
  buffer += 3;
  i = tmptr->tm_hour;
  __print_lz(i, buffer, ':');
  buffer += 3;
  i = tmptr->tm_min;
  __print_lz(i, buffer, ':');
  buffer += 3;
  i = tmptr->tm_sec;
  __print_lz(i, buffer, 0);
}


x86 assembly (clang, -O0):
<isotime_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x76c,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    $0x2d,%edx
call   1030 <__print_lz@plt>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x10(%rbp),%rsi
mov    $0x2d,%edx
call   1030 <__print_lz@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x2d,%edx
call   1030 <__print_lz@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1030 <__print_lz@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x3a,%edx
call   1030 <__print_lz@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x3a,%edx
call   1030 <__print_lz@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <__print_lz@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isotime_r>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rdi),%r12d
lea    0x76c(%r12),%eax
cltq
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x25,%rbx
add    %eax,%ebx
mov    %ebx,%edi
mov    $0x2d,%edx
call   1030 <__print_lz@plt>
lea    0x2(%r15),%rsi
imul   $0x64,%ebx,%eax
neg    %eax
lea    (%r12,%rax,1),%edi
add    $0x76c,%edi
mov    $0x2d,%edx
call   1030 <__print_lz@plt>
lea    0x5(%r15),%rsi
mov    0x4(%r14),%edi
add    $0x1,%edi
mov    $0x2d,%edx
call   1030 <__print_lz@plt>
lea    0x8(%r15),%rsi
mov    0x8(%r14),%edi
mov    $0x20,%edx
call   1030 <__print_lz@plt>
lea    0xb(%r15),%rsi
mov    0xc(%r14),%edi
mov    $0x3a,%edx
call   1030 <__print_lz@plt>
lea    0xe(%r15),%rsi
mov    0x10(%r14),%edi
mov    $0x3a,%edx
call   1030 <__print_lz@plt>
add    $0x11,%r15
mov    0x14(%r14),%edi
mov    %r15,%rsi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <__print_lz@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define void @isotime_r(%struct.tm* %0, i8* %1) {
%3 = alloca %struct.tm*
%4 = alloca i8*
%5 = alloca i32
store %struct.tm* %0, %struct.tm** %3
store i8* %1, i8** %4
%6 = load %struct.tm*, %struct.tm** %3
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1900
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = sdiv i32 %10, 100
%12 = load i8*, i8** %4
%13 = call i32 @__print_lz(i32 %11, i8* %12, i8 signext 45)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 2
store i8* %15, i8** %4
%16 = load i32, i32* %5
%17 = srem i32 %16, 100
%18 = load i8*, i8** %4
%19 = call i32 @__print_lz(i32 %17, i8* %18, i8 signext 45)
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 3
store i8* %21, i8** %4
%22 = load %struct.tm*, %struct.tm** %3
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = load i8*, i8** %4
%28 = call i32 @__print_lz(i32 %26, i8* %27, i8 signext 45)
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 3
store i8* %30, i8** %4
%31 = load %struct.tm*, %struct.tm** %3
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 2
%33 = load i32, i32* %32
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = load i8*, i8** %4
%36 = call i32 @__print_lz(i32 %34, i8* %35, i8 signext 32)
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 3
store i8* %38, i8** %4
%39 = load %struct.tm*, %struct.tm** %3
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 3
%41 = load i32, i32* %40
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = load i8*, i8** %4
%44 = call i32 @__print_lz(i32 %42, i8* %43, i8 signext 58)
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 3
store i8* %46, i8** %4
%47 = load %struct.tm*, %struct.tm** %3
%48 = getelementptr inbounds %struct.tm, %struct.tm* %47, i32 0, i32 4
%49 = load i32, i32* %48
store i32 %49, i32* %5
%50 = load i32, i32* %5
%51 = load i8*, i8** %4
%52 = call i32 @__print_lz(i32 %50, i8* %51, i8 signext 58)
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 3
store i8* %54, i8** %4
%55 = load %struct.tm*, %struct.tm** %3
%56 = getelementptr inbounds %struct.tm, %struct.tm* %55, i32 0, i32 5
%57 = load i32, i32* %56
store i32 %57, i32* %5
%58 = load i32, i32* %5
%59 = load i8*, i8** %4
%60 = call i32 @__print_lz(i32 %58, i8* %59, i8 signext 0)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define void @isotime_r(%struct.tm* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = add nsw i32 %4, 1900
%6 = sdiv i32 %5, 100
%7 = tail call i32 @__print_lz(i32 %6, i8* %1, i8 signext 45)
%8 = getelementptr inbounds i8, i8* %1, i64 2
%9 = srem i32 %5, 100
%10 = tail call i32 @__print_lz(i32 %9, i8* %8, i8 signext 45)
%11 = getelementptr inbounds i8, i8* %1, i64 5
%12 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = tail call i32 @__print_lz(i32 %14, i8* %11, i8 signext 45)
%16 = getelementptr inbounds i8, i8* %1, i64 8
%17 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%18 = load i32, i32* %17
%19 = tail call i32 @__print_lz(i32 %18, i8* %16, i8 signext 32)
%20 = getelementptr inbounds i8, i8* %1, i64 11
%21 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%22 = load i32, i32* %21
%23 = tail call i32 @__print_lz(i32 %22, i8* %20, i8 signext 58)
%24 = getelementptr inbounds i8, i8* %1, i64 14
%25 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%26 = load i32, i32* %25
%27 = tail call i32 @__print_lz(i32 %26, i8* %24, i8 signext 58)
%28 = getelementptr inbounds i8, i8* %1, i64 17
%29 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%30 = load i32, i32* %29
%31 = tail call i32 @__print_lz(i32 %30, i8* %28, i8 signext 0)
ret void
}