#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 atoi(char *);
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *, char *,
                         void *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, unsigned long *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int *);
int main(int argc, char *argv[]) {
  unsigned long iter = 0;
  char *ptr;
  char *fullpath;
  int duration;
  char count_str[12], start_str[24], path_str[256], *dur_str;
  time_t start_time, this_time;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s duration\n", argv[0]);
    exit(1);
  }
  duration = atoi(argv[1]);
  if (duration > 0) {
    dur_str = argv[1];
    if ((ptr = getenv("UB_BINDIR")) != NULL)
      sprintf(path_str, "%s/execl", ptr);
    fullpath = path_str;
    time(&start_time);
  } else {
    duration = atoi(argv[2]);
    dur_str = argv[2];
    iter = (unsigned long)atoi(argv[3]);
    sscanf(argv[4], "%lu", (unsigned long *)&start_time);
    fullpath = argv[0];
  }
  sprintf(count_str, "%lu", ++iter);
  sprintf(start_str, "%lu", (unsigned long)start_time);
  time(&this_time);
  if (this_time - start_time >= duration) {
    fprintf(stderr, "COUNT|%lu|1|lps\n", iter);
    exit(0);
  }
  execl(fullpath, fullpath, "0", dur_str, count_str, start_str, (void *)0);
  fprintf(stderr, "Exec failed at iteration %lu\n", iter);
  perror("Reason");
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11e3 <main+0x53>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    125b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x158(%rbp)
lea    0xe01(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     123f <main+0xaf>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x150(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x15c(%rbp),%rdi
call   1050 <time@plt>
jmp    12b3 <main+0x123>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x158(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x15c(%rbp),%rdx
lea    0xd84(%rip),%rsi
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
lea    0xd5d(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x50(%rbp),%rdi
movslq -0x15c(%rbp),%rdx
lea    0xd44(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x160(%rbp),%rdi
call   1050 <time@plt>
mov    -0x160(%rbp),%eax
sub    -0x15c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jl     132d <main+0x19d>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x158(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x50(%rbp),%r9
lea    0xcf1(%rip),%rdx
xor    %eax,%eax
movq   $0x0,(%rsp)
call   10b0 <execl@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xcd0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xce0(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jg     11cc <main+0x3c>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xe45(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x8(%rbp),%r14
mov    %r14,%rdi
call   1080 <atoi@plt>
test   %eax,%eax
jle    121c <main+0x8c>
mov    %eax,%r12d
lea    0xe2e(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1206 <main+0x76>
lea    0xe27(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
lea    0x40(%rsp),%r15
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
mov    $0x1,%ebx
jmp    1254 <main+0xc4>
mov    0x10(%rbp),%r14
mov    %r14,%rdi
call   1080 <atoi@plt>
mov    %eax,%r12d
mov    0x18(%rbp),%rdi
call   1080 <atoi@plt>
movslq %eax,%rbx
mov    0x20(%rbp),%rdi
lea    0xde5(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0x0(%rbp),%r15
add    $0x1,%rbx
lea    0xdcc(%rip),%rbp
lea    0x14(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
movslq 0xc(%rsp),%rdx
lea    0x20(%rsp),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
lea    0x10(%rsp),%rdi
call   1050 <time@plt>
mov    0x10(%rsp),%eax
sub    0xc(%rsp),%eax
cmp    %r12d,%eax
jge    12ef <main+0x15f>
movq   $0x0,(%rsp)
lea    0xd95(%rip),%rdx
lea    0x14(%rsp),%r8
lea    0x20(%rsp),%r9
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r14,%rcx
call   10b0 <execl@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    0xd6f(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xd7c(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s duration\0A\00"
@.str.1 = [10 x i8] c"UB_BINDIR\00"
@.str.2 = [9 x i8] c"%s/execl\00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [17 x i8] c"COUNT|%lu|1|lps\0A\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [30 x i8] c"Exec failed at iteration %lu\0A\00"
@.str.7 = [7 x i8] c"Reason\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [12 x i8]
%11 = alloca [24 x i8]
%12 = alloca [256 x i8]
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %25
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
store i8* %35, i8** %13
%36 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %36, i8** %7
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %42
38: ; preds = %32
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%40 = load i8*, i8** %7
%41 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %38, %32
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
store i8* %43, i8** %8
%44 = call i32 @time(i32* %14)
br label %66
45: ; preds = %25
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %9
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
store i8* %52, i8** %13
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 3
%55 = load i8*, i8** %54
%56 = call i32 @atoi(i8* %55)
%57 = sext i32 %56 to i64
store i64 %57, i64* %6
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 4
%60 = load i8*, i8** %59
%61 = bitcast i32* %14 to i64*
%62 = call i32 @sscanf(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %61)
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
store i8* %65, i8** %8
br label %66
66: ; preds = %45, %42
%67 = getelementptr inbounds [12 x i8], [12 x i8]* %10, i64 0, i64 0
%68 = load i64, i64* %6
%69 = add i64 %68, 1
store i64 %69, i64* %6
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %69)
%71 = getelementptr inbounds [24 x i8], [24 x i8]* %11, i64 0, i64 0
%72 = load i32, i32* %14
%73 = sext i32 %72 to i64
%74 = call i32 (i8*, i8*, ...) @sprintf(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %73)
%75 = call i32 @time(i32* %15)
%76 = load i32, i32* %15
%77 = load i32, i32* %14
%78 = sub nsw i32 %76, %77
%79 = load i32, i32* %9
%80 = icmp sge i32 %78, %79
br i1 %80, label %81, label %86
81: ; preds = %66
%82 = load i32, i32* @stderr
%83 = load i64, i64* %6
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %83)
%85 = call i32 @exit(i32 0)
unreachable
86: ; preds = %66
%87 = load i8*, i8** %8
%88 = load i8*, i8** %8
%89 = load i8*, i8** %13
%90 = getelementptr inbounds [12 x i8], [12 x i8]* %10, i64 0, i64 0
%91 = getelementptr inbounds [24 x i8], [24 x i8]* %11, i64 0, i64 0
%92 = call i32 @execl(i8* %87, i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %89, i8* %90, i8* %91, i8* null)
%93 = load i32, i32* @stderr
%94 = load i64, i64* %6
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i64 %94)
%96 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%97 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s duration\0A\00"
@.str.1 = [10 x i8] c"UB_BINDIR\00"
@.str.2 = [9 x i8] c"%s/execl\00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [17 x i8] c"COUNT|%lu|1|lps\0A\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [30 x i8] c"Exec failed at iteration %lu\0A\00"
@.str.7 = [7 x i8] c"Reason\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i8]
%4 = alloca [24 x i8]
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [24 x i8], [24 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = icmp slt i32 %0, 2
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %29
29: ; preds = %27, %24
%30 = call i32 @time(i32* %6)
br label %45
31: ; preds = %19
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32 @atoi(i8* %33)
%35 = getelementptr inbounds i8*, i8** %1, i64 3
%36 = load i8*, i8** %35
%37 = tail call i32 @atoi(i8* %36)
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %1, i64 4
%40 = load i8*, i8** %39
%41 = bitcast i32* %6 to i64*
%42 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %41)
%43 = load i8*, i8** %1
%44 = add nsw i64 %38, 1
br label %45
45: ; preds = %31, %29
%46 = phi i64 [ 1, %29 ], [ %44, %31 ]
%47 = phi i8* [ %10, %29 ], [ %43, %31 ]
%48 = phi i32 [ %22, %29 ], [ %34, %31 ]
%49 = phi i8* [ %21, %29 ], [ %33, %31 ]
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %46)
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %52)
%54 = call i32 @time(i32* %7)
%55 = load i32, i32* %7
%56 = load i32, i32* %6
%57 = sub nsw i32 %55, %56
%58 = icmp slt i32 %57, %48
br i1 %58, label %63, label %59
59: ; preds = %45
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %46)
%62 = call i32 @exit(i32 0)
unreachable
63: ; preds = %45
%64 = call i32 @execl(i8* %47, i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %49, i8* %8, i8* %9, i8* null)
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i64 %46)
%67 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
}