#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 */

/* Variables and functions */
int /*<<< orphan*/ dir_constrcut();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
int sscanf(char const *, char *, int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ system(char *);
int sys_datetime_set(const char *dateformat) {
  char buf[128];
  int c1, c2, c3, c4, c5, c6;
  if (NULL == dateformat)
    return -1;
  memset(buf, 0, 128);
  if (sscanf(dateformat, "%d-%d-%d %d:%d:%d", &c1, &c2, &c3, &c4, &c5, &c6) !=
      6)
    return -1;
  sprintf(buf, "/bin/date %02d%02d%02d%02d%04d.%02d", c2, c3, c4, c5, c1, c6);
  system(buf);
  system("/sbin/hwclock -w");
  dir_constrcut();
  return 0;
}


x86 assembly (clang, -O0):
<sys_datetime_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1177 <sys_datetime_set+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    124a <sys_datetime_set+0xfa>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    -0x94(%rbp),%rdx
lea    -0x98(%rbp),%rcx
lea    -0x9c(%rbp),%r8
lea    -0xa0(%rbp),%r9
lea    -0xa4(%rbp),%r10
lea    -0xa8(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <sscanf@plt>
cmp    $0x6,%eax
je     11e2 <sys_datetime_set+0x92>
movl   $0xffffffff,-0x4(%rbp)
jmp    124a <sys_datetime_set+0xfa>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    -0xa0(%rbp),%r8d
mov    -0xa4(%rbp),%r9d
mov    -0x94(%rbp),%r10d
mov    -0xa8(%rbp),%eax
lea    0xdfb(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1070 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <system@plt>
lea    0xdff(%rip),%rdi
call   1030 <system@plt>
mov    $0x0,%al
call   1060 <dir_constrcut@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_datetime_set>:
push   %rbp
push   %rbx
sub    $0xa8,%rsp
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1205 <sys_datetime_set+0xb5>
mov    %rdi,%rbx
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%r10
lea    0xe74(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rbx,%rdi
push   %rax
push   %r10
call   1050 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
jne    1205 <sys_datetime_set+0xb5>
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
mov    0x1c(%rsp),%eax
mov    0x8(%rsp),%ebp
lea    0xe3d(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
push   %rbp
push   %rax
call   1070 <sprintf@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
call   1030 <system@plt>
lea    0xe3f(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
call   1060 <dir_constrcut@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%d-%d-%d %d:%d:%d\00"
@.str.1 = [36 x i8] c"/bin/date %02d%02d%02d%02d%04d.%02d\00"
@.str.2 = [17 x i8] c"/sbin/hwclock -w\00"
define i32 @sys_datetime_set(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
%11 = load i8*, i8** %3
%12 = icmp eq i8* null, %11
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %34
14: ; preds = %1
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 128)
%17 = load i8*, i8** %3
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%19 = icmp ne i32 %18, 6
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 -1, i32* %2
br label %34
21: ; preds = %14
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = load i32, i32* %5
%28 = load i32, i32* %10
%29 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i32 %28)
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%31 = call i32 @system(i8* %30)
%32 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 (...) @dir_constrcut()
store i32 0, i32* %2
br label %34
34: ; preds = %21, %20, %13
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"%d-%d-%d %d:%d:%d\00"
@.str.1 = [36 x i8] c"/bin/date %02d%02d%02d%02d%04d.%02d\00"
@.str.2 = [17 x i8] c"/sbin/hwclock -w\00"
define i32 @sys_datetime_set(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = icmp eq i8* %0, null
br i1 %16, label %32, label %17
17: ; preds = %1
%18 = call i32 @memset(i8* %9, i32 0, i32 128)
%19 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%20 = icmp eq i32 %19, 6
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = load i32, i32* %3
%27 = load i32, i32* %8
%28 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24, i32 %25, i32 %26, i32 %27)
%29 = call i32 @system(i8* %9)
%30 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 (...) @dir_constrcut()
br label %32
32: ; preds = %17, %1, %21
%33 = phi i32 [ 0, %21 ], [ -1, %1 ], [ -1, %17 ]
ret i32 %33
}