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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int j, s, num_secs = 1;
  time_t old_time, new_time;
  float x = 45;
  float y = 23;
  float z = 256;
  int success = 1;
  if (argc >= 2) {
    num_secs = atoi(argv[1]);
  }
  if (num_secs < 1) {
    num_secs = 1;
  }
  old_time = time(NULL);
  s = 0;
  while (s < num_secs) {
    for (j = 0; j < 10000; j++) {
      if ((x + y) >= z) {
        printf("error: floating point comparison failed on "
               "sec: %d, j: %d\n",
               s, j);
        success = 0;
      }
    }
    new_time = time(NULL);
    if (new_time > old_time) {
      old_time = new_time;
      s++;
    }
  }
  if (success) {
    printf("Program completed successfully.\n");
    printf("Be sure that it checkpointed at least once.\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movss  0xeb3(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  0xe91(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1195 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    11a6 <main+0x76>
movl   $0x1,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    124d <main+0x11d>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    121c <main+0xec>
movss  -0x34(%rbp),%xmm0
addss  -0x38(%rbp),%xmm0
ucomiss -0x3c(%rbp),%xmm0
jb     1209 <main+0xd9>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x40(%rbp)
jmp    120e <main+0xde>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <main+0x9d>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    1248 <main+0x118>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ba <main+0x8a>
cmpl   $0x0,-0x40(%rbp)
je     127f <main+0x14f>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1286 <main+0x156>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%r14d
cmp    $0x2,%edi
jl     1154 <main+0x24>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
mov    $0x1,%r14d
cmovg  %eax,%r14d
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1040 <time@plt>
xor    %ecx,%ecx
cmp    %rbx,%rax
setg   %cl
cmovg  %rax,%rbx
add    %ecx,%ebp
cmp    %r14d,%ebp
jb     1160 <main+0x30>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"error: floating point comparison failed on sec: %d, j: %d\0A\00"
@.str.1 = [33 x i8] c"Program completed successfully.\0A\00"
@.str.2 = [45 x i8] c"Be sure that it checkpointed at least once.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
store float 4.500000e+01, float* %11
store float 2.300000e+01, float* %12
store float 2.560000e+02, float* %13
store i32 1, i32* %14
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %8
br label %22
22: ; preds = %17, %2
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 1, i32* %8
br label %26
26: ; preds = %25, %22
%27 = call i64 @time(i32* null)
store i64 %27, i64* %9
store i32 0, i32* %7
br label %28
28: ; preds = %59, %26
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %60
32: ; preds = %28
store i32 0, i32* %6
br label %33
33: ; preds = %47, %32
%34 = load i32, i32* %6
%35 = icmp slt i32 %34, 10000
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load float, float* %11
%38 = load float, float* %12
%39 = fadd float %37, %38
%40 = load float, float* %13
%41 = fcmp oge float %39, %40
br i1 %41, label %42, label %46
42: ; preds = %36
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %44)
store i32 0, i32* %14
br label %46
46: ; preds = %42, %36
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %33
50: ; preds = %33
%51 = call i64 @time(i32* null)
store i64 %51, i64* %10
%52 = load i64, i64* %10
%53 = load i64, i64* %9
%54 = icmp sgt i64 %52, %53
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i64, i64* %10
store i64 %56, i64* %9
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %59
59: ; preds = %55, %50
br label %28
60: ; preds = %28
%61 = load i32, i32* %14
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %67
66: ; preds = %60
store i32 1, i32* %3
br label %67
67: ; preds = %66, %63
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@str = [32 x i8] c"Program completed successfully.\00"
@str.3 = [44 x i8] c"Be sure that it checkpointed at least once.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp sgt i32 %7, 1
%9 = select i1 %8, i32 %7, i32 1
br label %10
10: ; preds = %4, %2
%11 = phi i32 [ 1, %2 ], [ %9, %4 ]
%12 = tail call i64 @time(i32* null)
br label %13
13: ; preds = %10, %13
%14 = phi i32 [ 0, %10 ], [ %20, %13 ]
%15 = phi i64 [ %12, %10 ], [ %18, %13 ]
%16 = tail call i64 @time(i32* null)
%17 = icmp sgt i64 %16, %15
%18 = select i1 %17, i64 %16, i64 %15
%19 = zext i1 %17 to i32
%20 = add nuw nsw i32 %14, %19
%21 = icmp ult i32 %20, %11
br i1 %21, label %13, label %22
22: ; preds = %13
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}