#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 time_t;

/* Variables and functions */
int dune_init_and_enter();
int /*<<< orphan*/ printf(char *);
int time(int *);
int main(int argc, char *argv[]) {
  time_t t = -1;
  int ret = dune_init_and_enter();
  if (ret) {
    printf("Failed to enter dune mode\n");
    return ret;
  }
  t = time(&t);
  if (t == -1) {
    printf("Error calling time(&t)!\n");
    return 1;
  }
  t = -1;
  t = time(NULL);
  if (t == -1) {
    printf("Error calling time(NULL)!\n");
    return 1;
  }
  printf("Success!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    $0x0,%al
call   1040 <dune_init_and_enter@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1178 <main+0x48>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xbe>
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11a6 <main+0x76>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ee <main+0xbe>
movl   $0xffffffff,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11db <main+0xab>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ee <main+0xbe>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
xor    %eax,%eax
call   1040 <dune_init_and_enter@plt>
test   %eax,%eax
je     1158 <main+0x28>
mov    %eax,%ebx
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
jmp    11a8 <main+0x78>
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     118e <main+0x5e>
movl   $0xffffffff,0xc(%rsp)
ff
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     1197 <main+0x67>
lea    0xe74(%rip),%rdi
jmp    1151 <main+0x21>
lea    0xe8e(%rip),%rdi
jmp    119e <main+0x6e>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Failed to enter dune mode\0A\00"
@.str.1 = [25 x i8] c"Error calling time(&t)!\0A\00"
@.str.2 = [27 x i8] c"Error calling time(NULL)!\0A\00"
@.str.3 = [10 x i8] c"Success!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%8 = call i32 (...) @dune_init_and_enter()
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %7
store i32 %13, i32* %3
br label %28
14: ; preds = %2
%15 = call i32 @time(i32* %6)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %28
20: ; preds = %14
store i32 -1, i32* %6
%21 = call i32 @time(i32* null)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %28
26: ; preds = %20
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %28
28: ; preds = %26, %24, %18, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@str = [9 x i8] c"Success!\00"
@str.4 = [26 x i8] c"Error calling time(NULL)!\00"
@str.5 = [24 x i8] c"Error calling time(&t)!\00"
@str.6 = [26 x i8] c"Failed to enter dune mode\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%5 = tail call i32 (...) @dune_init_and_enter()
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
br label %21
9: ; preds = %2
%10 = call i32 @time(i32* %3)
store i32 %10, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.5, i64 0, i64 0))
br label %21
14: ; preds = %9
store i32 -1, i32* %3
%15 = call i32 @time(i32* null)
store i32 %15, i32* %3
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
br label %21
19: ; preds = %14
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %12, %7
%22 = phi i32 [ %5, %7 ], [ 1, %12 ], [ 1, %17 ], [ 0, %19 ]
ret i32 %22
}