#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getCalenderDate(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int testAP() {
  int i = 0;
  char currentDate[64];
  fprintf(stderr, "Testing telescope's connection...\n");
  for (i = 0; i < 2; i++) {
    if (!getCalenderDate(currentDate))
      return 0;
    usleep(50000);
  }
  return -1;
}


x86 assembly (clang, -O0):
<testAP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x8(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119b <testAP+0x6b>
lea    -0x50(%rbp),%rdi
call   1030 <getCalenderDate@plt>
cmp    $0x0,%eax
jne    1183 <testAP+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <testAP+0x72>
mov    $0xc350,%edi
call   1050 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <testAP+0x2b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testAP>:
push   %rbx
sub    $0x40,%rsp
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rsp,%rdi
call   1030 <getCalenderDate@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     117d <testAP+0x4d>
mov    $0xc350,%edi
call   1050 <usleep@plt>
mov    %rsp,%rdi
call   1030 <getCalenderDate@plt>
test   %eax,%eax
je     117d <testAP+0x4d>
mov    $0xc350,%edi
call   1050 <usleep@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Testing telescope's connection...\0A\00"
define i32 @testAP() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [64 x i8]
store i32 0, i32* %2
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i32 @getCalenderDate(i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 0, i32* %1
br label %20
14: ; preds = %9
%15 = call i32 @usleep(i32 50000)
br label %16
16: ; preds = %14
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %6
19: ; preds = %6
store i32 -1, i32* %1
br label %20
20: ; preds = %19, %13
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Testing telescope's connection...\0A\00"
define i32 @testAP() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @getCalenderDate(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = call i32 @usleep(i32 50000)
%9 = call i32 @getCalenderDate(i8* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 @usleep(i32 50000)
br label %13
13: ; preds = %11, %7, %0
%14 = phi i32 [ 0, %0 ], [ 0, %7 ], [ -1, %11 ]
ret i32 %14
}