#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ System_SetTime(char *);
int execve(char *, char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  char *dt = "2016-4-15 21:00:00";
  pid_t fpid;
  fpid = fork();
  if (fpid < 0)
    printf("error\n");
  else if (fpid == 0) {
    char *args[] = {"/home/nfsroot/hwclock.sh", NULL};
    if (-1 == (execve("/home/nfsroot/hwclock.sh", args, NULL))) {
      perror("execve");
      exit(EXIT_FAILURE);
    }
    exit(EXIT_SUCCESS);
  } else {
    System_SetTime(dt);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    11a1 <main+0x41>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    121b <main+0xbb>
cmpq   $0x0,-0x18(%rbp)
jne    120d <main+0xad>
mov    0x2c4d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c4a(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <execve@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11ff <main+0x9f>
lea    0xe47(%rip),%rdi
call   1050 <perror@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1070 <System_SetTime@plt>
jmp    121b <main+0xbb>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
js     1180 <main+0x20>
je     1193 <main+0x33>
lea    0xe87(%rip),%rdi
call   1070 <System_SetTime@plt>
jmp    118c <main+0x2c>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
movaps 0x2c66(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe6e(%rip),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   1040 <execve@plt>
cmp    $0xffffffff,%eax
jne    11ce <main+0x6e>
lea    0xe71(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"2016-4-15 21:00:00\00"
@.str.1 = [7 x i8] c"error\0A\00"
@.str.2 = [25 x i8] c"/home/nfsroot/hwclock.sh\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [7 x i8] c"execve\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca [2 x i8*]
store i32 0, i32* %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = call i64 (...) @fork()
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %29
10: ; preds = %0
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = bitcast [2 x i8*]* %4 to i8*
%15 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%16 = call i32 @execve(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8** %15, i32* null)
%17 = icmp eq i32 -1, %16
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %13
%23 = load i32, i32* @EXIT_SUCCESS
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %10
%26 = load i8*, i8** %2
%27 = call i32 @System_SetTime(i8* %26)
br label %28
28: ; preds = %25
br label %29
29: ; preds = %28, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"2016-4-15 21:00:00\00"
@.str.2 = [25 x i8] c"/home/nfsroot/hwclock.sh\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [7 x i8] c"execve\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca [2 x i8*]
%2 = tail call i64 (...) @fork()
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %22
6: ; preds = %0
%7 = icmp eq i64 %2, 0
br i1 %7, label %8, label %20
8: ; preds = %6
%9 = bitcast [2 x i8*]* %1 to i8*
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%11 = call i32 @execve(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8** %10, i32* null)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %8
%18 = load i32, i32* @EXIT_SUCCESS
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %6
%21 = tail call i32 @System_SetTime(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %4
ret i32 0
}