#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 tm {
  int dummy;
};
typedef int /*<<< orphan*/ cur_date;

/* Variables and functions */
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int print_gal_header(struct tm *rectime, char *sysname, char *release,
                     char *nodename, char *machine) {
  char cur_date[64];
  char *e;
  int rc = 0;
  if (((e = getenv("S_TIME_FORMAT")) != NULL) && !strcmp(e, "ISO")) {
    strftime(cur_date, sizeof(cur_date), "%Y-%m-%d", rectime);
    rc = 1;
  } else {
    strftime(cur_date, sizeof(cur_date), "%x", rectime);
  }
  printf("%s %s (%s) \t%s \t_%s_\n", sysname, release, nodename, cur_date,
         machine);
  return rc;
}


x86 assembly (clang, -O0):
<print_gal_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x7c(%rbp)
lea    0xe93(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
je     11be <print_gal_header+0x7e>
mov    -0x78(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11be <print_gal_header+0x7e>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x40,%esi
lea    0xe65(%rip),%rdx
call   1060 <strftime@plt>
movl   $0x1,-0x7c(%rbp)
jmp    11d7 <print_gal_header+0x97>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x40,%esi
lea    0xe49(%rip),%rdx
call   1060 <strftime@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x70(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x7c(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_gal_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xe9a(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1183 <print_gal_header+0x43>
lea    0xe97(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     118e <print_gal_header+0x4e>
xor    %ebp,%ebp
lea    0xe8f(%rip),%rdx
jmp    119a <print_gal_header+0x5a>
mov    $0x1,%ebp
lea    0xe78(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
lea    0xe68(%rip),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    0x8(%rsp),%r9
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [14 x i8] c"S_TIME_FORMAT\00"
@.str.1 = [4 x i8] c"ISO\00"
@.str.2 = [9 x i8] c"%Y-%m-%d\00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [22 x i8] c"%s %s (%s) \09%s \09_%s_\0A\00"
define i32 @print_gal_header(%struct.tm* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca %struct.tm*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [64 x i8]
%12 = alloca i8*
%13 = alloca i32
store %struct.tm* %0, %struct.tm** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i32 0, i32* %13
%14 = call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %12
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %24
16: ; preds = %5
%17 = load i8*, i8** %12
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%22 = load %struct.tm*, %struct.tm** %6
%23 = call i32 @strftime(i8* %21, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %22)
store i32 1, i32* %13
br label %28
24: ; preds = %16, %5
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%26 = load %struct.tm*, %struct.tm** %6
%27 = call i32 @strftime(i8* %25, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %26)
br label %28
28: ; preds = %24, %20
%29 = load i8*, i8** %7
%30 = load i8*, i8** %8
%31 = load i8*, i8** %9
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%33 = load i8*, i8** %10
%34 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %29, i8* %30, i8* %31, i8* %32, i8* %33)
%35 = load i32, i32* %13
ret i32 %35
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [14 x i8] c"S_TIME_FORMAT\00"
@.str.1 = [4 x i8] c"ISO\00"
@.str.2 = [9 x i8] c"%Y-%m-%d\00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [22 x i8] c"%s %s (%s) \09%s \09_%s_\0A\00"
define i32 @print_gal_header(%struct.tm* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [64 x i8]
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %10, %5
br label %14
14: ; preds = %10, %13
%15 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %10 ]
%16 = phi i32 [ 0, %13 ], [ 1, %10 ]
%17 = call i32 @strftime(i8* %7, i32 64, i8* %15, %struct.tm* %0)
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2, i8* %3, i8* %7, i8* %4)
ret i32 %16
}