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

/* Variables and functions */
int /*<<< orphan*/ *fopen(char const *, char const *);
FILE *fopen_retry(const char *filename, const char *mode) {
  int try, Ntry = 10;
  FILE *fp;
  for (try = 0; try < Ntry; ++try) {
    fp = fopen(filename, mode);
    if (fp != NULL)
      return fp;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<fopen_retry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0xa,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1176 <fopen_retry+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1163 <fopen_retry+0x53>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117e <fopen_retry+0x6e>
jmp    1168 <fopen_retry+0x58>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <fopen_retry+0x1e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fopen_retry>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
jne    11a8 <fopen_retry+0x98>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fopen@plt>
test   %rax,%rax
je     11b0 <fopen_retry+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fopen@plt>

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

LLVM IR (-O2):
define noalias i32* @fopen_retry(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %31
5: ; preds = %2
%6 = tail call i32* @fopen(i8* %0, i8* %1)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %31
8: ; preds = %5
%9 = tail call i32* @fopen(i8* %0, i8* %1)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = tail call i32* @fopen(i8* %0, i8* %1)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = tail call i32* @fopen(i8* %0, i8* %1)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = tail call i32* @fopen(i8* %0, i8* %1)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = tail call i32* @fopen(i8* %0, i8* %1)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = tail call i32* @fopen(i8* %0, i8* %1)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = tail call i32* @fopen(i8* %0, i8* %1)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32* @fopen(i8* %0, i8* %1)
br label %31
31: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %5, %2
%32 = phi i32* [ %3, %2 ], [ %6, %5 ], [ %9, %8 ], [ %12, %11 ], [ %15, %14 ], [ %18, %17 ], [ %21, %20 ], [ %24, %23 ], [ %27, %26 ], [ %30, %29 ]
ret i32* %32
}