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

/* Variables and functions */
int /*<<< orphan*/ *connectMysql();
int /*<<< orphan*/ sleep(int);
MYSQL *connectMysqlCheck(MYSQL *conn) {
  if (conn == NULL) {
    int i = 0;
    for (i = 0; i < 3; i++) {
      MYSQL *conn = connectMysql();
      if (conn != NULL) {
        return conn;
      }
      sleep(1);
    }
  }
  return conn;
}


x86 assembly (clang, -O0):
<connectMysqlCheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118f <connectMysqlCheck+0x6f>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    118a <connectMysqlCheck+0x6a>
mov    $0x0,%al
call   1030 <connectMysql@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1172 <connectMysqlCheck+0x52>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1197 <connectMysqlCheck+0x77>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <connectMysqlCheck+0x25>
jmp    118f <connectMysqlCheck+0x6f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connectMysqlCheck>:
push   %rax
mov    %rdi,%rax
test   %rdi,%rdi
je     112b <connectMysqlCheck+0xb>
pop    %rcx
ret
xor    %eax,%eax
call   1030 <connectMysql@plt>
test   %rax,%rax
jne    1129 <connectMysqlCheck+0x9>
mov    $0x1,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
call   1030 <connectMysql@plt>
test   %rax,%rax
jne    1129 <connectMysqlCheck+0x9>
mov    $0x1,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
call   1030 <connectMysql@plt>
test   %rax,%rax
jne    1129 <connectMysqlCheck+0x9>
mov    $0x1,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32* @connectMysqlCheck(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %24
8: ; preds = %1
store i32 0, i32* %4
store i32 0, i32* %4
br label %9
9: ; preds = %20, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = call i32* (...) @connectMysql()
store i32* %13, i32** %5
%14 = load i32*, i32** %5
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i32*, i32** %5
store i32* %17, i32** %2
br label %26
18: ; preds = %12
%19 = call i32 @sleep(i32 1)
br label %20
20: ; preds = %18
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %9
23: ; preds = %9
br label %24
24: ; preds = %23, %1
%25 = load i32*, i32** %3
store i32* %25, i32** %2
br label %26
26: ; preds = %24, %16
%27 = load i32*, i32** %2
ret i32* %27
}

LLVM IR (-O2):
define i32* @connectMysqlCheck(i32* readnone %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %3, label %16
3: ; preds = %1
%4 = tail call i32* (...) @connectMysql()
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32* (...) @connectMysql()
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32* (...) @connectMysql()
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @sleep(i32 1)
br label %16
16: ; preds = %3, %6, %10, %14, %1
%17 = phi i32* [ %0, %1 ], [ %4, %3 ], [ %8, %6 ], [ %12, %10 ], [ null, %14 ]
ret i32* %17
}