int dcraw_set_time(struct ccd_frame *frame, char *month, int day, int year,
                   char *timestr) {
  char mon_map[12][3] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  int i;
  int mon = 0;
  char date[15], timestr1[15];
  for (i = 0; i < 12; i++) {
    if (strncmp(month, mon_map[i], 3) == 0) {
      mon = i + 1;
      break;
    }
  }
  sprintf(date, "\"%04d/%02d/%02d\"", year, mon, day);
  sprintf(timestr1, "\"%s\"", timestr);
  fits_add_keyword(frame, "TIME-OBS", timestr1);
  fits_add_keyword(frame, "DATE-OBS", date);
  return 0;
}


x86 assembly (clang, -O0):
<dcraw_set_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe98(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0xc,-0x54(%rbp)
jge    11d1 <dcraw_set_time+0x91>
mov    -0x10(%rbp),%rdi
movslq -0x54(%rbp),%rax
lea    -0x50(%rbp),%rsi
imul   $0x3,%rax,%rax
add    %rax,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11be <dcraw_set_time+0x7e>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11d1 <dcraw_set_time+0x91>
jmp    11c3 <dcraw_set_time+0x83>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1180 <dcraw_set_time+0x40>
lea    -0x67(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x58(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x76(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x76(%rbp),%rdx
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1050 <fits_add_keyword@plt>
mov    -0x8(%rbp),%rdi
lea    -0x67(%rbp),%rdx
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1050 <fits_add_keyword@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcraw_set_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r13
lea    0xeac(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     129b <dcraw_set_time+0x16b>
lea    0xe93(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12a2 <dcraw_set_time+0x172>
lea    0xe7a(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12a9 <dcraw_set_time+0x179>
lea    0xe61(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12b0 <dcraw_set_time+0x180>
lea    0xe48(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12b7 <dcraw_set_time+0x187>
lea    0xe2f(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12be <dcraw_set_time+0x18e>
lea    0xe16(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12c5 <dcraw_set_time+0x195>
lea    0xdfd(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12cc <dcraw_set_time+0x19c>
lea    0xde4(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12d3 <dcraw_set_time+0x1a3>
lea    0xdcb(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12da <dcraw_set_time+0x1aa>
lea    0xdb6(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     12e1 <dcraw_set_time+0x1b1>
lea    0xda1(%rip),%rsi
mov    $0x3,%edx
mov    %rbp,%rdi
call   1030 <strncmp@plt>
xor    %edx,%edx
test   %eax,%eax
mov    $0xc,%ecx
cmovne %edx,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x1,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x2,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x3,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x4,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x5,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x6,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x7,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x8,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0x9,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0xa,%ecx
jmp    12e6 <dcraw_set_time+0x1b6>
mov    $0xb,%ecx
lea    0xd37(%rip),%rsi
lea    0x19(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12d,%edx
mov    %r15d,%r8d
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xd2c(%rip),%rsi
lea    0xa(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xd18(%rip),%rsi
mov    %r13,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fits_add_keyword@plt>
lea    0xd0d(%rip),%rsi
mov    %r13,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fits_add_keyword@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ccd_frame = type opaque
@__const.dcraw_set_time.mon_map = [12 x [3 x i8]] [[3 x i8] c"Jan", [3 x i8] c"Feb", [3 x i8] c"Mar", [3 x i8] c"Apr", [3 x i8] c"May", [3 x i8] c"Jun", [3 x i8] c"Jul", [3 x i8] c"Aug", [3 x i8] c"Sep", [3 x i8] c"Oct", [3 x i8] c"Nov", [3 x i8] c"Dec"]
@.str = [17 x i8] c"\22%04d/%02d/%02d\22\00"
@.str.1 = [5 x i8] c"\22%s\22\00"
@.str.2 = [9 x i8] c"TIME-OBS\00"
@.str.3 = [9 x i8] c"DATE-OBS\00"
define i32 @dcraw_set_time(%struct.ccd_frame* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca %struct.ccd_frame*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [12 x [3 x i8]]
%12 = alloca i32
%13 = alloca i32
%14 = alloca [15 x i8]
%15 = alloca [15 x i8]
store %struct.ccd_frame* %0, %struct.ccd_frame** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%16 = bitcast [12 x [3 x i8]]* %11 to i8*
store i32 0, i32* %13
store i32 0, i32* %12
br label %17
17: ; preds = %32, %5
%18 = load i32, i32* %12
%19 = icmp slt i32 %18, 12
br i1 %19, label %20, label %35
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = load i32, i32* %12
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [12 x [3 x i8]], [12 x [3 x i8]]* %11, i64 0, i64 %23
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %24, i64 0, i64 0
%26 = call i32 @strncmp(i8* %21, i8* %25, i64 3)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = load i32, i32* %12
%30 = add nsw i32 %29, 1
store i32 %30, i32* %13
br label %35
31: ; preds = %20
br label %32
32: ; preds = %31
%33 = load i32, i32* %12
%34 = add nsw i32 %33, 1
store i32 %34, i32* %12
br label %17
35: ; preds = %28, %17
%36 = getelementptr inbounds [15 x i8], [15 x i8]* %14, i64 0, i64 0
%37 = load i32, i32* %9
%38 = load i32, i32* %13
%39 = load i32, i32* %8
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38, i32 %39)
%41 = getelementptr inbounds [15 x i8], [15 x i8]* %15, i64 0, i64 0
%42 = load i8*, i8** %10
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = load %struct.ccd_frame*, %struct.ccd_frame** %6
%45 = getelementptr inbounds [15 x i8], [15 x i8]* %15, i64 0, i64 0
%46 = call i32 (%struct.ccd_frame*, i8*, i8*, ...) bitcast (i32 (...)* @fits_add_keyword to i32 (%struct.ccd_frame*, i8*, i8*, ...)*)(%struct.ccd_frame* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load %struct.ccd_frame*, %struct.ccd_frame** %6
%48 = getelementptr inbounds [15 x i8], [15 x i8]* %14, i64 0, i64 0
%49 = call i32 (%struct.ccd_frame*, i8*, i8*, ...) bitcast (i32 (...)* @fits_add_keyword to i32 (%struct.ccd_frame*, i8*, i8*, ...)*)(%struct.ccd_frame* %47, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %48)
ret i32 0
}

LLVM IR (-O2):
%struct.ccd_frame = type opaque
@__const.dcraw_set_time.mon_map = [12 x [3 x i8]] [[3 x i8] c"Jan", [3 x i8] c"Feb", [3 x i8] c"Mar", [3 x i8] c"Apr", [3 x i8] c"May", [3 x i8] c"Jun", [3 x i8] c"Jul", [3 x i8] c"Aug", [3 x i8] c"Sep", [3 x i8] c"Oct", [3 x i8] c"Nov", [3 x i8] c"Dec"]
@.str = [17 x i8] c"\22%04d/%02d/%02d\22\00"
@.str.1 = [5 x i8] c"\22%s\22\00"
@.str.2 = [9 x i8] c"TIME-OBS\00"
@.str.3 = [9 x i8] c"DATE-OBS\00"
define i32 @dcraw_set_time(%struct.ccd_frame* %0, i8* nocapture %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [15 x i8]
%7 = alloca [15 x i8]
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%10 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 0, i64 0), i64 3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %46, label %12
12: ; preds = %5
%13 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 1, i64 0), i64 3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %46, label %15
15: ; preds = %12
%16 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 2, i64 0), i64 3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %46, label %18
18: ; preds = %15
%19 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 3, i64 0), i64 3)
%20 = icmp eq i32 %19, 0
br i1 %20, label %46, label %21
21: ; preds = %18
%22 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 4, i64 0), i64 3)
%23 = icmp eq i32 %22, 0
br i1 %23, label %46, label %24
24: ; preds = %21
%25 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 5, i64 0), i64 3)
%26 = icmp eq i32 %25, 0
br i1 %26, label %46, label %27
27: ; preds = %24
%28 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 6, i64 0), i64 3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %46, label %30
30: ; preds = %27
%31 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 7, i64 0), i64 3)
%32 = icmp eq i32 %31, 0
br i1 %32, label %46, label %33
33: ; preds = %30
%34 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 8, i64 0), i64 3)
%35 = icmp eq i32 %34, 0
br i1 %35, label %46, label %36
36: ; preds = %33
%37 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 9, i64 0), i64 3)
%38 = icmp eq i32 %37, 0
br i1 %38, label %46, label %39
39: ; preds = %36
%40 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 10, i64 0), i64 3)
%41 = icmp eq i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* getelementptr inbounds ([12 x [3 x i8]], [12 x [3 x i8]]* @__const.dcraw_set_time.mon_map, i64 0, i64 11, i64 0), i64 3)
%44 = icmp eq i32 %43, 0
%45 = select i1 %44, i32 12, i32 0
br label %46
46: ; preds = %42, %5, %12, %15, %18, %21, %24, %27, %30, %33, %36, %39
%47 = phi i32 [ 1, %5 ], [ 2, %12 ], [ 3, %15 ], [ 4, %18 ], [ 5, %21 ], [ 6, %24 ], [ 7, %27 ], [ 8, %30 ], [ 9, %33 ], [ 10, %36 ], [ 11, %39 ], [ %45, %42 ]
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %47, i32 %2)
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%50 = call i32 (%struct.ccd_frame*, i8*, i8*, ...) bitcast (i32 (...)* @fits_add_keyword to i32 (%struct.ccd_frame*, i8*, i8*, ...)*)(%struct.ccd_frame* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%51 = call i32 (%struct.ccd_frame*, i8*, i8*, ...) bitcast (i32 (...)* @fits_add_keyword to i32 (%struct.ccd_frame*, i8*, i8*, ...)*)(%struct.ccd_frame* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %8)
ret i32 0
}