#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ atol(char *);
int /*<<< orphan*/ display_stop_time_to_stderr(char *, int /*<<< orphan*/,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ remove_tmp_file(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(long *);
int main(int argc, char **argv) {
  FILE *tmp_file;
  char tmp_file_name[128];
  char input_buffer[128];
  time_t now, start_time;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s key\n", argv[0]);
    exit(1);
  }
  now = time((long *)0);
  sprintf(tmp_file_name, "/tmp/time_%s.tmp", argv[1]);
  tmp_file = fopen(tmp_file_name, "r");
  if (!tmp_file) {
    fprintf(stderr,
            "%s: Cannot open \"%s\" for read. Did you \"start_time.e\"?\n",
            argv[0], tmp_file_name);
    exit(1);
  }
  if (!get_line(input_buffer, tmp_file)) {
    fprintf(stderr,
            "%s: %s is empty. Did \"start_time.e\" complete successfully?\n",
            argv[0], tmp_file_name);
    exit(1);
  }
  fclose(tmp_file);
  start_time = atol(input_buffer);
  display_stop_time_to_stderr(argv[1], start_time, now);
  remove_tmp_file(tmp_file_name);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11eb <main+0x4b>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x124(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdff(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1266 <main+0xc6>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0xa0(%rbp),%rcx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <get_line@plt>
cmp    $0x0,%eax
jne    12ae <main+0x10e>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0xa0(%rbp),%rcx
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x120(%rbp),%rdi
call   1090 <atol@plt>
mov    %eax,-0x128(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x128(%rbp),%esi
mov    -0x124(%rbp),%edx
call   1050 <display_stop_time_to_stderr@plt>
lea    -0xa0(%rbp),%rdi
call   1060 <remove_tmp_file@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    123b <main+0x9b>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rdx
lea    0xe43(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
call   10b0 <sprintf@plt>
lea    0xe42(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     125f <main+0xbf>
mov    %rax,%rbp
lea    0x80(%rsp),%rdi
mov    %rax,%rsi
call   1030 <get_line@plt>
test   %eax,%eax
je     1274 <main+0xd4>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0x80(%rsp),%rdi
call   1090 <atol@plt>
mov    0x8(%rbx),%rdi
mov    %eax,%esi
mov    %r14d,%edx
call   1050 <display_stop_time_to_stderr@plt>
mov    %rsp,%rdi
call   1060 <remove_tmp_file@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdb2(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdb0(%rip),%rsi
jmp    1287 <main+0xe7>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdd3(%rip),%rsi
mov    %rsp,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Usage: %s key\0A\00"
@.str.1 = [17 x i8] c"/tmp/time_%s.tmp\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [56 x i8] c"%s: Cannot open \22%s\22 for read. Did you \22start_time.e\22?\0A\00"
@.str.4 = [60 x i8] c"%s: %s is empty. Did \22start_time.e\22 complete successfully?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = call i32 @time(i64* null)
store i32 %21, i32* %9
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %28, i32** %6
%29 = load i32*, i32** %6
%30 = icmp ne i32* %29, null
br i1 %30, label %39, label %31
31: ; preds = %20
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%37 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i8* %35, i8* %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %20
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%41 = load i32*, i32** %6
%42 = call i32 @get_line(i8* %40, i32* %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %52, label %44
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%50 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i8* %48, i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %39
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%56 = call i32 @atol(i8* %55)
store i32 %56, i32* %10
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = load i32, i32* %10
%61 = load i32, i32* %9
%62 = call i32 @display_stop_time_to_stderr(i8* %59, i32 %60, i32 %61)
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%64 = call i32 @remove_tmp_file(i8* %63)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Usage: %s key\0A\00"
@.str.1 = [17 x i8] c"/tmp/time_%s.tmp\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [56 x i8] c"%s: Cannot open \22%s\22 for read. Did you \22start_time.e\22?\0A\00"
@.str.4 = [60 x i8] c"%s: %s is empty. Did \22start_time.e\22 complete successfully?\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = tail call i32 @time(i64* null)
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %1
%23 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* %5)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %13
%26 = call i32 @get_line(i8* %6, i32* %18)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %1
%31 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* %5)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %25
%34 = call i32 @fclose(i32* %18)
%35 = call i32 @atol(i8* %6)
%36 = load i8*, i8** %15
%37 = call i32 @display_stop_time_to_stderr(i8* %36, i32 %35, i32 %14)
%38 = call i32 @remove_tmp_file(i8* %5)
ret i32 0
}