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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int,
                            char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void getPictureName(char *Picture, int fmt) {
  char temp[80];
  char *myext[] = {"pnm", "jpg"};
  int i;
  time_t curdate;
  struct tm *tdate;
  memset(temp, '\0', sizeof(temp));
  time(&curdate);
  tdate = localtime(&curdate);
  snprintf(temp, 26, "P-%02d:%02d:%04d-%02d:%02d:%02d.%s\0", tdate->tm_mon + 1,
           tdate->tm_mday, tdate->tm_year + 1900, tdate->tm_hour, tdate->tm_min,
           tdate->tm_sec, myext[fmt]);
  memcpy(Picture, temp, strlen(temp));
}


x86 assembly (clang, -O0):
<getPictureName>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0xb8,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2c96(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0x2c93(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
lea    -0x88(%rbp),%rdi
call   1080 <time@plt>
lea    -0x88(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x90(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x90(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x90(%rbp),%rax
mov    0x8(%rax),%r9d
add    $0x76c,%r9d
mov    -0x90(%rbp),%rax
mov    0xc(%rax),%ebx
mov    -0x90(%rbp),%rax
mov    0x10(%rax),%r11d
mov    -0x90(%rbp),%rax
mov    0x14(%rax),%r10d
movslq -0x14(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rax
mov    $0x1a,%esi
lea    0xdee(%rip),%rdx
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
call   1070 <memcpy@plt>
add    $0xb8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPictureName>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %esi,%r12d
mov    %rdi,%r14
lea    0x10(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    0x4(%rax),%r8d
mov    $0x76c,%r9d
add    0x8(%rax),%r9d
add    $0x1,%ecx
mov    0xc(%rax),%r10d
mov    0x10(%rax),%ebp
mov    0x14(%rax),%eax
movslq %r12d,%rdx
lea    0xe46(%rip),%rsi
movslq (%rsi,%rdx,4),%rbx
add    %rsi,%rbx
lea    0xe40(%rip),%rdx
mov    %r15,%rdi
mov    $0x1a,%esi
push   %rbx
push   %rax
push   %rbp
push   %r10
call   1050 <snprintf@plt>
add    $0x20,%rsp
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1070 <memcpy@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [4 x i8] c"pnm\00"
@.str.1 = [4 x i8] c"jpg\00"
@__const.getPictureName.myext = [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [36 x i8] c"P-%02d:%02d:%04d-%02d:%02d:%02d.%s\00\00"
define void @getPictureName(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca [2 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.tm*
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = bitcast [2 x i8*]* %6 to i8*
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i8 signext 0, i32 80)
%13 = call i32 @time(i32* %8)
%14 = call %struct.tm* @localtime(i32* %8)
store %struct.tm* %14, %struct.tm** %9
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%16 = load %struct.tm*, %struct.tm** %9
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1
%20 = load %struct.tm*, %struct.tm** %9
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load %struct.tm*, %struct.tm** %9
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 2
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1900
%27 = load %struct.tm*, %struct.tm** %9
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 3
%29 = load i32, i32* %28
%30 = load %struct.tm*, %struct.tm** %9
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 4
%32 = load i32, i32* %31
%33 = load %struct.tm*, %struct.tm** %9
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 5
%35 = load i32, i32* %34
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @snprintf(i8* %15, i32 26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22, i32 %26, i32 %29, i32 %32, i32 %35, i8* %39)
%41 = load i8*, i8** %3
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = call i32 @memcpy(i8* %41, i8* %42, i32 %44)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [4 x i8] c"pnm\00"
@.str.1 = [4 x i8] c"jpg\00"
@reltable.getPictureName = [2 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([2 x i32]* @reltable.getPictureName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([2 x i32]* @reltable.getPictureName to i64)) to i32)]
@.str.2 = [36 x i8] c"P-%02d:%02d:%04d-%02d:%02d:%02d.%s\00\00"
define void @getPictureName(i8* %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = call i32 @memset(i8* %5, i8 signext 0, i32 80)
%8 = call i32 @time(i32* %4)
%9 = call %struct.tm* @localtime(i32* %4)
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
%13 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 2
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1900
%18 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 3
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 4
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 5
%23 = load i32, i32* %22
%24 = sext i32 %1 to i64
%25 = shl i64 %24, 2
%26 = call i8* @llvm.load.relative.i64(i8* bitcast ([2 x i32]* @reltable.getPictureName to i8*), i64 %25)
%27 = call i32 @snprintf(i8* %5, i32 26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %14, i32 %17, i32 %19, i32 %21, i32 %23, i8* %26)
%28 = call i32 @strlen(i8* %5)
%29 = call i32 @memcpy(i8* %0, i8* %5, i32 %28)
ret void
}