#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 uint8_t;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int send_packet(int, int, int, int *, int);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int init_camera_time_bcd(int fd) {
  uint8_t buf[15], i;
  time_t t;
  struct tm *tm;
  time(&t);
  tm = localtime(&t);
  strftime((char *)buf, sizeof(buf), "%y20%m%d%H%M%S", tm);
  for (i = 0; i < 7; i++)
    buf[i] = buf[2 * i] << 4 | (buf[2 * i + 1] & 0x0f);
  return send_packet(fd, 0x08, 0x20, buf, 7);
}


x86 assembly (clang, -O0):
<init_camera_time_bcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x48(%rbp),%rdi
call   1040 <time@plt>
lea    -0x48(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rcx
mov    $0x3c,%esi
lea    0xe8b(%rip),%rdx
call   1060 <strftime@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x7,-0x44(%rbp)
jge    11c4 <init_camera_time_bcd+0x84>
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
cltq
mov    -0x40(%rbp,%rax,4),%ecx
shl    $0x4,%ecx
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
mov    -0x40(%rbp,%rax,4),%eax
and    $0xf,%eax
or     %eax,%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1181 <init_camera_time_bcd+0x41>
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rcx
mov    $0x8,%esi
mov    $0x20,%edx
mov    $0x7,%r8d
call   1050 <send_packet@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_camera_time_bcd>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebp
lea    0x3c(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe9a(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3c,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
shl    $0x4,%eax
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,(%rsp)
mov    0x8(%rsp),%eax
shl    $0x4,%eax
mov    0xc(%rsp),%ecx
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,0x4(%rsp)
mov    0x10(%rsp),%eax
shl    $0x4,%eax
mov    0x14(%rsp),%ecx
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,0x8(%rsp)
mov    0x18(%rsp),%eax
shl    $0x4,%eax
mov    0x1c(%rsp),%ecx
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,0xc(%rsp)
mov    0x20(%rsp),%eax
shl    $0x4,%eax
mov    0x24(%rsp),%ecx
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,0x10(%rsp)
mov    0x28(%rsp),%eax
shl    $0x4,%eax
mov    0x2c(%rsp),%ecx
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,0x14(%rsp)
mov    0x30(%rsp),%eax
mov    0x34(%rsp),%ecx
shl    $0x4,%eax
and    $0xf,%ecx
or     %eax,%ecx
mov    %ecx,0x18(%rsp)
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x20,%edx
mov    %r14,%rcx
mov    $0x7,%r8d
call   1050 <send_packet@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [15 x i8] c"%y20%m%d%H%M%S\00"
define i32 @init_camera_time_bcd(i32 %0) {
%2 = alloca i32
%3 = alloca [15 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.tm*
store i32 %0, i32* %2
%7 = call i32 @time(i32* %5)
%8 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %8, %struct.tm** %6
%9 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 0
%10 = bitcast i32* %9 to i8*
%11 = load %struct.tm*, %struct.tm** %6
%12 = call i32 @strftime(i8* %10, i32 60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
store i32 0, i32* %4
br label %13
13: ; preds = %34, %1
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 7
br i1 %15, label %16, label %37
16: ; preds = %13
%17 = load i32, i32* %4
%18 = mul nsw i32 2, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = shl i32 %21, 4
%23 = load i32, i32* %4
%24 = mul nsw i32 2, %23
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = and i32 %28, 15
%30 = or i32 %22, %29
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 %32
store i32 %30, i32* %33
br label %34
34: ; preds = %16
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %13
37: ; preds = %13
%38 = load i32, i32* %2
%39 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 0
%40 = call i32 @send_packet(i32 %38, i32 8, i32 32, i32* %39, i32 7)
ret i32 %40
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [15 x i8] c"%y20%m%d%H%M%S\00"
define i32 @init_camera_time_bcd(i32 %0) {
%2 = alloca [15 x i32]
%3 = alloca i32
%4 = bitcast [15 x i32]* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @time(i32* %3)
%7 = call %struct.tm* @localtime(i32* %3)
%8 = call i32 @strftime(i8* %4, i32 60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%9 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %9
%11 = shl i32 %10, 4
%12 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 1
%13 = load i32, i32* %12
%14 = and i32 %13, 15
%15 = or i32 %14, %11
store i32 %15, i32* %9
%16 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 2
%17 = load i32, i32* %16
%18 = shl i32 %17, 4
%19 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 3
%20 = load i32, i32* %19
%21 = and i32 %20, 15
%22 = or i32 %21, %18
store i32 %22, i32* %12
%23 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 4
%24 = load i32, i32* %23
%25 = shl i32 %24, 4
%26 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 5
%27 = load i32, i32* %26
%28 = and i32 %27, 15
%29 = or i32 %28, %25
store i32 %29, i32* %16
%30 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 6
%31 = load i32, i32* %30
%32 = shl i32 %31, 4
%33 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 7
%34 = load i32, i32* %33
%35 = and i32 %34, 15
%36 = or i32 %35, %32
store i32 %36, i32* %19
%37 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 8
%38 = load i32, i32* %37
%39 = shl i32 %38, 4
%40 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 9
%41 = load i32, i32* %40
%42 = and i32 %41, 15
%43 = or i32 %42, %39
store i32 %43, i32* %23
%44 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 10
%45 = load i32, i32* %44
%46 = shl i32 %45, 4
%47 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 11
%48 = load i32, i32* %47
%49 = and i32 %48, 15
%50 = or i32 %49, %46
store i32 %50, i32* %26
%51 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 12
%52 = load i32, i32* %51
%53 = shl i32 %52, 4
%54 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 13
%55 = load i32, i32* %54
%56 = and i32 %55, 15
%57 = or i32 %56, %53
store i32 %57, i32* %30
%58 = call i32 @send_packet(i32 %0, i32 8, i32 32, i32* %9, i32 7)
ret i32 %58
}