char *fd2ofd(string)
char *string;
{
  int iyr, imon, iday, ihr, imn;
  double sec;
  fd2i(string, &iyr, &imon, &iday, &ihr, &imn, &sec, 3);
  string = (char *)calloc(32, sizeof(char));
  if (iyr < 1900)
    sprintf(string, "*** date out of range ***");
  else if (iyr < 2000)
    sprintf(string, "%02d/%02d/%02d", iday, imon, iyr - 1900);
  else if (iyr < 2900.0)
    sprintf(string, "%02d/%02d/%3d", iday, imon, iyr - 1900);
  else
    sprintf(string, "*** date out of range ***");
  return (string);
}


x86 assembly (clang, -O0):
<fd2ofd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
lea    -0x1c(%rbp),%r9
lea    -0x28(%rbp),%rax
mov    %rax,(%rsp)
movl   $0x3,0x8(%rsp)
mov    $0x0,%al
call   1050 <fd2i@plt>
mov    $0x20,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x8(%rbp)
cmpl   $0x76c,-0xc(%rbp)
jge    11a2 <fd2ofd+0x72>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1232 <fd2ofd+0x102>
cmpl   $0x7d0,-0xc(%rbp)
jge    11d7 <fd2ofd+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
sub    $0x76c,%r8d
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    122d <fd2ofd+0xfd>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe1c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1216 <fd2ofd+0xe6>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
sub    $0x76c,%r8d
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1228 <fd2ofd+0xf8>
mov    -0x8(%rbp),%rdi
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    122d <fd2ofd+0xfd>
jmp    1232 <fd2ofd+0x102>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fd2ofd>:
push   %rbx
sub    $0x20,%rsp
lea    0x18(%rsp),%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
xor    %eax,%eax
push   $0x3
push   %rbx
call   1050 <fd2i@plt>
add    $0x10,%rsp
mov    $0x20,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%r8d
cmp    $0x76b,%r8d
jle    11cd <fd2ofd+0x9d>
cmp    $0x7cf,%r8d
ja     11a2 <fd2ofd+0x72>
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
add    $0xfffff894,%r8d
lea    0xe7a(%rip),%rsi
jmp    11c1 <fd2ofd+0x91>
cmp    $0xb53,%r8d
ja     11cd <fd2ofd+0x9d>
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
add    $0xfffff894,%r8d
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    11e2 <fd2ofd+0xb2>
movups 0xe36(%rip),%xmm0
movups %xmm0,0xa(%rbx)
movups 0xe21(%rip),%xmm0
movups %xmm0,(%rbx)
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"*** date out of range ***\00"
@.str.1 = [15 x i8] c"%02d/%02d/%02d\00"
@.str.2 = [14 x i8] c"%02d/%02d/%3d\00"
define i8* @fd2ofd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 (i8*, i32*, i32*, i32*, i32*, i32*, double*, i32, ...) bitcast (i32 (...)* @fd2i to i32 (i8*, i32*, i32*, i32*, i32*, i32*, double*, i32, ...)*)(i8* %9, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, double* %8, i32 3)
%11 = call i8* @calloc(i64 32, i64 1)
store i8* %11, i8** %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 1900
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %43
17: ; preds = %1
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 2000
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i8*, i8** %2
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1900
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %25)
br label %42
27: ; preds = %17
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = fcmp olt double %29, 2.900000e+03
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i8*, i8** %2
%33 = load i32, i32* %5
%34 = load i32, i32* %4
%35 = load i32, i32* %3
%36 = sub nsw i32 %35, 1900
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %33, i32 %34, i32 %36)
br label %41
38: ; preds = %27
%39 = load i8*, i8** %2
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %38, %31
br label %42
42: ; preds = %41, %20
br label %43
43: ; preds = %42, %14
%44 = load i8*, i8** %2
ret i8* %44
}

LLVM IR (-O2):
@.str = [26 x i8] c"*** date out of range ***\00"
@.str.1 = [15 x i8] c"%02d/%02d/%02d\00"
@.str.2 = [14 x i8] c"%02d/%02d/%3d\00"
define i8* @fd2ofd(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast double* %7 to i8*
%14 = call i32 (i8*, i32*, i32*, i32*, i32*, i32*, double*, i32, ...) bitcast (i32 (...)* @fd2i to i32 (i8*, i32*, i32*, i32*, i32*, i32*, double*, i32, ...)*)(i8* %0, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, double* %7, i32 3)
%15 = call dereferenceable_or_null(32) i8* @calloc(i64 32, i64 1)
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 1900
br i1 %17, label %18, label %19
18: ; preds = %1
br label %34
19: ; preds = %1
%20 = icmp ult i32 %16, 2000
br i1 %20, label %21, label %26
21: ; preds = %19
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = add nsw i32 %16, -1900
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
br label %34
26: ; preds = %19
%27 = icmp ult i32 %16, 2900
br i1 %27, label %28, label %33
28: ; preds = %26
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = add nsw i32 %16, -1900
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
br label %34
33: ; preds = %26
br label %34
34: ; preds = %21, %33, %28, %18
ret i8* %15
}