#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 Collatz(int);
scalar_t__ simerror(char *, int);
int /*<<< orphan*/ simfix(char *);
int retry() {
  int ret;
  if (simerror("retry", 4))
    return -1;
  while ((ret = Collatz(500)) < 0) {
    simfix("If at first you don't succeed, try again.");
  }
  return ret;
}


x86 assembly (clang, -O0):
<retry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x4,%esi
call   1030 <simerror@plt>
cmp    $0x0,%rax
je     115f <retry+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <retry+0x61>
jmp    1164 <retry+0x34>
mov    $0x1f4,%edi
call   1050 <Collatz@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    118b <retry+0x5b>
lea    0xe85(%rip),%rdi
call   1040 <simfix@plt>
jmp    1164 <retry+0x34>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<retry>:
push   %rbx
lea    0xec8(%rip),%rdi
mov    $0x4,%esi
call   1030 <simerror@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1186 <retry+0x56>
mov    $0x1f4,%edi
call   1050 <Collatz@plt>
test   %eax,%eax
jns    1186 <retry+0x56>
lea    0xea2(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <simfix@plt>
mov    $0x1f4,%edi
call   1050 <Collatz@plt>
test   %eax,%eax
js     1170 <retry+0x40>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"retry\00"
@.str.1 = [42 x i8] c"If at first you don't succeed, try again.\00"
define i32 @retry() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 @simerror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 4)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 -1, i32* %1
br label %14
6: ; preds = %0
br label %7
7: ; preds = %10, %6
%8 = call i32 @Collatz(i32 500)
store i32 %8, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @simfix(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %7
12: ; preds = %7
%13 = load i32, i32* %2
store i32 %13, i32* %1
br label %14
14: ; preds = %12, %5
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [6 x i8] c"retry\00"
@.str.1 = [42 x i8] c"If at first you don't succeed, try again.\00"
define i32 @retry() {
%1 = tail call i64 @simerror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 4)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i32 @Collatz(i32 500)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3, %6
%7 = tail call i32 @simfix(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @Collatz(i32 500)
%9 = icmp slt i32 %8, 0
br i1 %9, label %6, label %10
10: ; preds = %6, %3, %0
%11 = phi i32 [ -1, %0 ], [ %4, %3 ], [ %8, %6 ]
ret i32 %11
}