#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 */
struct timeval {
  int tv_sec;
};
typedef int /*<<< orphan*/ file_path;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ die_with_error(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
void gen_timestamp(char *drohn_dir, struct timeval start) {
  char file_path[150];
  FILE *fp;
  snprintf(file_path, sizeof(file_path),
           "%s/dashboard/"
           "timestamp",
           drohn_dir);
  if ((fp = fopen(file_path, "w")) == NULL) {
    die_with_error("Error in opening timestamp file.");
  }
  fprintf(fp, "%d", start.tv_sec);
  fclose(fp);
}


x86 assembly (clang, -O0):
<gen_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %esi,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x96,%esi
lea    0xe87(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xb8(%rbp)
cmp    $0x0,%rax
jne    11ae <gen_timestamp+0x5e>
lea    0xe70(%rip),%rdi
call   1050 <die_with_error@plt>
mov    -0xb8(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe7b(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xb8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_timestamp>:
push   %rbp
push   %rbx
sub    $0x98,%rsp
mov    %esi,%ebp
mov    %rdi,%rcx
lea    0xe9b(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x96,%esi
call   1040 <snprintf@plt>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1198 <gen_timestamp+0x48>
lea    0xe86(%rip),%rdi
call   1050 <die_with_error@plt>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [23 x i8] c"%s/dashboard/timestamp\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"Error in opening timestamp file.\00"
@.str.3 = [3 x i8] c"%d\00"
define void @gen_timestamp(i8* %0, i32 %1) {
%3 = alloca %struct.timeval
%4 = alloca i8*
%5 = alloca [150 x i8]
%6 = alloca i32*
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
store i32 %1, i32* %7
store i8* %0, i8** %4
%8 = getelementptr inbounds [150 x i8], [150 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = call i32 @snprintf(i8* %8, i32 150, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [150 x i8], [150 x i8]* %5, i64 0, i64 0
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @die_with_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = load i32*, i32** %6
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %6
%22 = call i32 @fclose(i32* %21)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s/dashboard/timestamp\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"Error in opening timestamp file.\00"
@.str.3 = [3 x i8] c"%d\00"
define void @gen_timestamp(i8* %0, i32 %1) {
%3 = alloca [150 x i8]
%4 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 150, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @die_with_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%12 = call i32 @fclose(i32* %6)
ret void
}