#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int erzeugeLogfileName(int for_csv, char *pLogFileName, int anz_regler) {
  int erg = 0;
  char csv_endung[] = ".csv", winsol_endung[] = ".log";
  char monat[256], jahr[256];
  struct tm *zeit;
  time_t sekunde;
  time(&sekunde);
  zeit = localtime(&sekunde);
  strftime(monat, 10, "%m", zeit);
  strftime(jahr, 10, "%y", zeit);
  if (for_csv == 1) {
    if (anz_regler == 1)
      erg = sprintf(pLogFileName, "E%s%s%s", jahr, monat, csv_endung);
    else if (anz_regler == 2)
      erg = sprintf(pLogFileName, "E%s%s_2%s", jahr, monat, csv_endung);
  } else {
    erg = sprintf(pLogFileName, "Y20%s%s%s", jahr, monat, winsol_endung);
  }
  fprintf(stderr, " logfilename: %s\n", pLogFileName);
  return erg;
}


x86 assembly (clang, -O0):
<erzeugeLogfileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0xe8e(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    0xe89(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe81(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    0xe7c(%rip),%al
mov    %al,-0x1e(%rbp)
lea    -0x23c(%rbp),%rdi
call   1050 <time@plt>
lea    -0x23c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x238(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x238(%rbp),%rcx
mov    $0xa,%esi
lea    0xe41(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x230(%rbp),%rdi
mov    -0x238(%rbp),%rcx
mov    $0xa,%esi
lea    0xe25(%rip),%rdx
call   1060 <strftime@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1264 <erzeugeLogfileName+0x114>
cmpl   $0x1,-0x14(%rbp)
jne    122b <erzeugeLogfileName+0xdb>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    -0x130(%rbp),%rcx
lea    -0x1d(%rbp),%r8
lea    0xdf2(%rip),%rsi
call   1070 <sprintf@plt>
mov    %eax,-0x18(%rbp)
jmp    125f <erzeugeLogfileName+0x10f>
cmpl   $0x2,-0x14(%rbp)
jne    125a <erzeugeLogfileName+0x10a>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    -0x130(%rbp),%rcx
lea    -0x1d(%rbp),%r8
lea    0xdc6(%rip),%rsi
call   1070 <sprintf@plt>
mov    %eax,-0x18(%rbp)
jmp    125f <erzeugeLogfileName+0x10f>
jmp    1289 <erzeugeLogfileName+0x139>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    -0x130(%rbp),%rcx
lea    -0x22(%rbp),%r8
lea    0xda1(%rip),%rsi
call   1070 <sprintf@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd8f(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erzeugeLogfileName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x228,%rsp
mov    %edx,%r15d
mov    %rsi,%r14
mov    %edi,%ebx
movb   $0x0,0x10(%rsp)
movl   $0x7673632e,0xc(%rsp)
76
movb   $0x0,0x18(%rsp)
movl   $0x676f6c2e,0x14(%rsp)
67
lea    0x1c(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <time@plt>
mov    %rbp,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbp
lea    0xe6c(%rip),%rdx
lea    0x120(%rsp),%rdi
mov    $0xa,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
lea    0xe53(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0xa,%esi
mov    %rbp,%rcx
call   1060 <strftime@plt>
cmp    $0x1,%ebx
jne    11e8 <erzeugeLogfileName+0x98>
cmp    $0x2,%r15d
je     1203 <erzeugeLogfileName+0xb3>
xor    %ebx,%ebx
cmp    $0x1,%r15d
jne    1226 <erzeugeLogfileName+0xd6>
lea    0xe2a(%rip),%rsi
jmp    120a <erzeugeLogfileName+0xba>
lea    0xe33(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x120(%rsp),%rcx
lea    0x14(%rsp),%r8
jmp    121c <erzeugeLogfileName+0xcc>
lea    0xe0e(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x120(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %r14,%rdi
call   1070 <sprintf@plt>
mov    %eax,%ebx
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@__const.erzeugeLogfileName.csv_endung = [5 x i8] c".csv\00"
@__const.erzeugeLogfileName.winsol_endung = [5 x i8] c".log\00"
@.str = [3 x i8] c"%m\00"
@.str.1 = [3 x i8] c"%y\00"
@.str.2 = [8 x i8] c"E%s%s%s\00"
@.str.3 = [10 x i8] c"E%s%s_2%s\00"
@.str.4 = [10 x i8] c"Y20%s%s%s\00"
@stderr = global i32 0
@.str.5 = [18 x i8] c" logfilename: %s\0A\00"
define i32 @erzeugeLogfileName(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x i8]
%9 = alloca [5 x i8]
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca %struct.tm*
%13 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%14 = bitcast [5 x i8]* %8 to i8*
%15 = bitcast [5 x i8]* %9 to i8*
%16 = call i32 @time(i32* %13)
%17 = call %struct.tm* @localtime(i32* %13)
store %struct.tm* %17, %struct.tm** %12
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%19 = load %struct.tm*, %struct.tm** %12
%20 = call i32 @strftime(i8* %18, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %19)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%22 = load %struct.tm*, %struct.tm** %12
%23 = call i32 @strftime(i8* %21, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %22)
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %46
26: ; preds = %3
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i8*, i8** %5
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%34 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32, i8* %33)
store i32 %34, i32* %7
br label %45
35: ; preds = %26
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i8*, i8** %5
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%43 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %40, i8* %41, i8* %42)
store i32 %43, i32* %7
br label %44
44: ; preds = %38, %35
br label %45
45: ; preds = %44, %29
br label %52
46: ; preds = %3
%47 = load i8*, i8** %5
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%50 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%51 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %48, i8* %49, i8* %50)
store i32 %51, i32* %7
br label %52
52: ; preds = %46, %45
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %5
%55 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i32, i32* %7
ret i32 %56
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@__const.erzeugeLogfileName.csv_endung = [5 x i8] c".csv\00"
@__const.erzeugeLogfileName.winsol_endung = [5 x i8] c".log\00"
@.str = [3 x i8] c"%m\00"
@.str.1 = [3 x i8] c"%y\00"
@.str.2 = [8 x i8] c"E%s%s%s\00"
@.str.3 = [10 x i8] c"E%s%s_2%s\00"
@.str.4 = [10 x i8] c"Y20%s%s%s\00"
@stderr = global i32 0
@.str.5 = [18 x i8] c" logfilename: %s\0A\00"
define i32 @erzeugeLogfileName(i32 %0, i8* %1, i32 %2) {
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = bitcast i32* %8 to i8*
%14 = call i32 @time(i32* %8)
%15 = call %struct.tm* @localtime(i32* %8)
%16 = call i32 @strftime(i8* %11, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %15)
%17 = call i32 @strftime(i8* %12, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %15)
%18 = icmp eq i32 %0, 1
br i1 %18, label %19, label %24
19: ; preds = %3
switch i32 %2, label %26 [
i32 1, label %20
i32 2, label %22
]
20: ; preds = %19
%21 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %11, i8* %9)
br label %26
22: ; preds = %19
%23 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %12, i8* %11, i8* %9)
br label %26
24: ; preds = %3
%25 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %11, i8* %10)
br label %26
26: ; preds = %19, %20, %22, %24
%27 = phi i32 [ %21, %20 ], [ %23, %22 ], [ %25, %24 ], [ 0, %19 ]
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %1)
ret i32 %27
}