#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 i, 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, i: %d, j: %d\n",
               s, i, 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,-0x20(%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,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jge    11a6 <main+0x76>
movl   $0x1,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1250 <main+0x120>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    121f <main+0xef>
movss  -0x34(%rbp),%xmm0
addss  -0x38(%rbp),%xmm0
ucomiss -0x3c(%rbp),%xmm0
jb     120c <main+0xdc>
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x40(%rbp)
jmp    1211 <main+0xe1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%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    124b <main+0x11b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ba <main+0x8a>
cmpl   $0x0,-0x40(%rbp)
je     1282 <main+0x152>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1289 <main+0x159>
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 = [66 x i8] c"error: floating point comparison failed on sec: %d, i: %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 i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
store float 4.500000e+01, float* %12
store float 2.300000e+01, float* %13
store float 2.560000e+02, float* %14
store i32 1, i32* %15
%16 = load i32, i32* %4
%17 = icmp sge i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %9
br label %23
23: ; preds = %18, %2
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 1, i32* %9
br label %27
27: ; preds = %26, %23
%28 = call i64 @time(i32* null)
store i64 %28, i64* %10
store i32 0, i32* %8
br label %29
29: ; preds = %61, %27
%30 = load i32, i32* %8
%31 = load i32, i32* %9
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %62
33: ; preds = %29
store i32 0, i32* %7
br label %34
34: ; preds = %49, %33
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 10000
br i1 %36, label %37, label %52
37: ; preds = %34
%38 = load float, float* %12
%39 = load float, float* %13
%40 = fadd float %38, %39
%41 = load float, float* %14
%42 = fcmp oge float %40, %41
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = load i32, i32* %8
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
store i32 0, i32* %15
br label %48
48: ; preds = %43, %37
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %34
52: ; preds = %34
%53 = call i64 @time(i32* null)
store i64 %53, i64* %11
%54 = load i64, i64* %11
%55 = load i64, i64* %10
%56 = icmp sgt i64 %54, %55
br i1 %56, label %57, label %61
57: ; preds = %52
%58 = load i64, i64* %11
store i64 %58, i64* %10
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %61
61: ; preds = %57, %52
br label %29
62: ; preds = %29
%63 = load i32, i32* %15
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%67 = 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 %69
68: ; preds = %62
store i32 1, i32* %3
br label %69
69: ; preds = %68, %65
%70 = load i32, i32* %3
ret i32 %70
}

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
}