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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int /*<<< orphan*/ write_png_file_from_yuv_buffer(char *, unsigned char const *,
                                                  int, int, char *);
void process_image(const unsigned char *p, int width, int height) {
  time_t now = time(0);
  struct tm *ltm = localtime(&now);
  char png_name[100];
  int size = width * height * 2;
  sprintf(png_name, "%d_%d_%04d%02d%02d_%02d%02d%02d.png", width, height,
          ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour,
          ltm->tm_min, ltm->tm_sec);
  printf("png_name = %s, size = %d\n", png_name, size);
  write_png_file_from_yuv_buffer(png_name, p, width, height,
                                 "From YUYV Camera");
}


x86 assembly (clang, -O0):
<process_image>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0xb8,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    (%rax),%r8d
add    $0x76c,%r8d
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%r9d
add    $0x1,%r9d
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%ebx
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%r11d
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%eax
lea    0xe27(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1070 <sprintf@plt>
lea    -0x90(%rbp),%rsi
mov    -0x94(%rbp),%edx
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe1e(%rip),%r8
call   1050 <write_png_file_from_yuv_buffer@plt>
add    $0xb8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_image>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %edx,%r15d
mov    %esi,%r13d
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %r13d,%ebp
imul   %r15d,%ebp
add    %ebp,%ebp
mov    $0x76c,%r8d
add    (%rax),%r8d
mov    0x4(%rax),%r9d
mov    0x8(%rax),%r10d
add    $0x1,%r9d
mov    0xc(%rax),%r11d
mov    0x14(%rax),%ebx
mov    0x10(%rax),%eax
lea    0xe55(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %r13d,%edx
mov    %r15d,%ecx
push   %rax
push   %rbx
push   %r11
push   %r10
call   1070 <sprintf@plt>
add    $0x20,%rsp
lea    0xe55(%rip),%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <printf@plt>
lea    0xe5e(%rip),%r8
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %r15d,%ecx
call   1050 <write_png_file_from_yuv_buffer@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [36 x i8] c"%d_%d_%04d%02d%02d_%02d%02d%02d.png\00"
@.str.1 = [26 x i8] c"png_name = %s, size = %d\0A\00"
@.str.2 = [17 x i8] c"From YUYV Camera\00"
define void @process_image(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.tm*
%9 = alloca [100 x i8]
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32 @time(i32 0)
store i32 %11, i32* %7
%12 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %12, %struct.tm** %8
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = mul nsw i32 %13, %14
%16 = mul nsw i32 %15, 2
store i32 %16, i32* %10
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = load %struct.tm*, %struct.tm** %8
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1900
%24 = load %struct.tm*, %struct.tm** %8
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
%28 = load %struct.tm*, %struct.tm** %8
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 2
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %8
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 3
%33 = load i32, i32* %32
%34 = load %struct.tm*, %struct.tm** %8
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 5
%36 = load i32, i32* %35
%37 = load %struct.tm*, %struct.tm** %8
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 4
%39 = load i32, i32* %38
%40 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %23, i32 %27, i32 %30, i32 %33, i32 %36, i32 %39)
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%42 = load i32, i32* %10
%43 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %41, i32 %42)
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%45 = load i8*, i8** %4
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = call i32 @write_png_file_from_yuv_buffer(i8* %44, i8* %45, i32 %46, i32 %47, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [36 x i8] c"%d_%d_%04d%02d%02d_%02d%02d%02d.png\00"
@.str.1 = [26 x i8] c"png_name = %s, size = %d\0A\00"
@.str.2 = [17 x i8] c"From YUYV Camera\00"
define void @process_image(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @time(i32 0)
store i32 %7, i32* %4
%8 = call %struct.tm* @localtime(i32* %4)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%10 = shl i32 %1, 1
%11 = mul i32 %10, %2
%12 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1900
%15 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
%25 = load i32, i32* %24
%26 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 %14, i32 %17, i32 %19, i32 %21, i32 %23, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %11)
%28 = call i32 @write_png_file_from_yuv_buffer(i8* %9, i8* %0, i32 %1, i32 %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret void
}